删除嵌入在pdf中的javascript打印代码 [英] Removing javascript print code embedded in pdf

查看:501
本文介绍了删除嵌入在pdf中的javascript打印代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台生成PDF的服务器,我无法访问或无法更改服务器上的设置。

I have a server that generates a PDF, I have no access or ability to change the settings on the server.

当服务器生成pdf时,它嵌入了将javascript代码放入文件中,以便在任何PDF阅读器/查看器打开时,PRINT DOCUMENT屏幕自动打开。这非常不方便且令人沮丧。

When the server produces the pdf it embeds the following javascript code into the file so that when any PDF reader/viewer opens it, the PRINT DOCUMENT screen automatically opens. This is very inconvenient and frustrating.

文件中的代码一开始就是这样的:

The code inside the file at the very start looks like this:

%PDF-1.4
%â€Ó
1 0 obj
<< / S / JavaScript / JS(this.print \(true,0,this。 NUMPAGES-1,false\); \r)GT;>
endobj
3 0 obj
<< / Length 10 / Filter / FlateDecode>> stream
xœ+ä
SNIP

我认为删除javascript行并防止弹出自动打印屏幕将是一件容易的事。

I thought it would be an easy task just to remove the javascript line and prevent the auto print screen from popping up.

我试过这个(只是进行了字符串搜索并替换并删除了第4行)。这会停止出现打印屏幕 - 但是当在几个PDF查看器中打开时(goodreader等)会立即标记为损坏的PDF格式。

I have tried this (just did a string search and replace and removed line 4). This DOES stop the print screen appearing - BUT when opened in a few PDF viewers (goodreader etc) instantly flags up as a corrupted PDF.

我可以单击修复选项一切正常,但我想知道,有什么我可以用一些NOOP代码替换javascript代码,以防止文件损坏同时仍然阻止打印页面?

I can click the repair option and everything works fine, but I would like to know, is there anything I could do to replace the javascript code with some sort of NOOP code to keep the file from being corrupt whilst still preventing the print page?

以下是源文件的链接: https: //www.dropbox.com/s/kziy6evi57cfhb3/2014-04-04_EIKY.pdf (800k)

Here's a link to a source file: https://www.dropbox.com/s/kziy6evi57cfhb3/2014-04-04_EIKY.pdf (800k)

有没有办法让pdf对象无效或类似的东西?

Is there a way to nullify a pdf object or something similar?

谢谢。

推荐答案

由于PDF已有检查以确保内容长度在某些点没有更改,您无法添加或删除字符。但你可以改变它们。您可以这样更改:

Since PDF has checks to make sure that the content length hasn't changed at certain points, you can't add or remove characters. But you can change them. You can change it like this:

<</S/JavaScript/JS(this.print\(true , 0,this.numPages-1,false\);\r)>>

到此

<</S/JavaScript/JS(;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r)>>

例如。

这篇关于删除嵌入在pdf中的javascript打印代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆