PDF文档是否已被另一个修订版修改? [英] PDF document is modified by another revision?

查看:360
本文介绍了PDF文档是否已被另一个修订版修改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PDFbox来签名PDF。效果很好。我可以在一个文档中添加多个签名,并且一切正常。

I use PDFbox in order to sign PDF. It works very well. I can add several signature to one document, and everything works well.

现在,有人给我签名了一个文档(她由另一个软件签名),这个签名也起作用了。但是当我在他的文档中添加另一个修订版(通过pdfbox)时,Adobe Reader告诉我PDF已被修改。

Now, someone sign me a document(she sign by another software), this signature was working too. but when I add another revision (by pdfbox) to his document now Adobe reader tells me that PDF was modified.


  1. 原始文档:

这是由另一软件完成的签名文档:链接

this is signed document which was done by another software: link

当我向签名的pdf添加其他修订时,我收到了此文档,该文档存在问题:链接

when I add another revision to the signed pdf, I get this document, which have problems: link

如果我在软件签名的PDF中添加了另一个修订,则链接

If I add another revision to the PDF that was signed by my software, there is no problem link


推荐答案

简而言之:



您的代码无需应用

In Short:

Your code applies unnecessary changes to existing PDF objects.

某些更改只是结构性的,而不是更改实际内容。 Acrobat Reader可能会也可能不会忽略这些结构更改。但是,在此过程中,您会引入舍入错误,并且它们最终会构成更改。

Some changes merely are structural, not changing the actual content. Acrobat Reader might or might not ignore those structural changes. But in the process you introduce rounding errors, and they definitively constitute a change.

结构性更改可能是由于PDFBox的怪癖导致迫使其优先选择哪种类型的

The structural changes probably are caused by the quirk of PDFBox to force its preference of which kinds of objects should be direct or indirect onto existing objects it touches.

并且实际上,在涉及安全功能时,舍入错误在实践中几乎不相关,因此绝对不是可行的。

And the rounding errors while in practice hardly relevant are definitively a no-go when security features are concerned.

p>

当您使用PDFBox签名文档两次时,初始签名过程已经将PDFBox的首选项强加到文档中,因此,第二个签名过程不会通过再次强制PDFBox破坏任何东西。

When you sign a document twice with PDFBox, the initial signing process already forces PDFBox' preferences into the document and, thus, the second signing process does not destroy anything by again forcing the same preferences into its result.

来自原始签名-old.pdf

3 0 obj
<<
  /DefaultGray 11 0 R
  /Type/Catalog
  /DefaultRGB 12 0 R
  /AcroForm
  <<
    /Fields[15 0 R]
    /DR<</Font<</Helv 16 0 R/ZaDb 17 0 R>>>>
    /DA(/Helv 0 Tf 0 g )
    /SigFlags 3
  >>
  /Pages 5 0 R>>
endobj 
11 0 obj
[
  /CalGray
  <<
    /WhitePoint [0.9505 1 1.0891 ]
    /Gamma 0.2468
  >>
]
endobj
12 0 obj
[
  /CalRGB
  <<
    /WhitePoint [0.9505 1 1.0891 ]
    /Gamma [0.2468 0.2468 0.2468 ]
    /Matrix [0.4361 0.2225 0.0139 0.3851 0.7169 0.0971 0.1431 0.0606 0.7141 ]
  >>
]
endobj

您重新签名的original-signed-signed-old new.pdf

3 0 obj
<<
  /DefaultGray [/CalGray 18 0 R]
  /Type /Catalog
  /DefaultRGB [/CalRGB 19 0 R]
  /AcroForm
  <<
    /Fields [15 0 R 20 0 R]
    /DA (/Helv 0 Tf 0 g )
    /SigFlags 3
  >>
  /Pages 5 0 R
>>
endobj
18 0 obj
<<
  /WhitePoint [0.9505000114 1 1.0891000032]
  /Gamma 0.2468000054
>>
endobj
19 0 obj
<<
  /WhitePoint [0.9505000114 1 1.0891000032]
  /Gamma [0.2468000054 0.2468000054 0.2468000054]
  /Matrix [0.4361000061 0.2224999964 0.0138999997 0.3851000071 0.716899991 0.0970999971 0.1430999935 0.0606000014 0.7141000032]
>>
endobj 

从本质上讲,您的代码更改了direct的间接数组(对象11和12)将字典分解为间接字典(新对象18和19)的直接数组(在新对象3中)。这是不必要的,因此Adobe Reader无需接受它。但是如果替换是相同的,它可能会接受(我不知道,必须检查)。

So in essence your code changed indirect arrays (objects 11 and 12) of direct dictionaries into direct arrays (in your new object 3) of indirect dictionaries (your new objects 18 and 19). This is unnecessary and, therefore, there is no need for Adobe Reader to accept it. But it probably would accept this (I don't know, one has to check) if the replacements were identical.

但是它们确实不相同!您的代码在这些颜色定义中引入了舍入错误。因此,它更改了内容。

此外,您的代码还对

4 0 obj
<<
  /Parent 5 0 R
  /Contents 9 0 R
  /Type/Page
  /Resources<</ProcSet 2 0 R/Font<</F0 6 0 R/F1 7 0 R>>>>
  /MediaBox[0 0 612 792]
  /Annots[15 0 R]
>>
endobj
2 0 obj
[ /PDF /Text  ]
endobj

要更改为

4 0 obj
<<
  /Parent 5 0 R
  /Contents 9 0 R
  /Type /Page
  /Resources<</ProcSet [/PDF /Text] /Font 23 0 R >>
  /MediaBox [0 0 612 792]
  /Annots [15 0 R 20 0 R]
>>
endobj 
23 0 obj
<<
  /F0 6 0 R
  /F1 7 0 R
>>
endobj 

在这里,您将间接名称数组更改为直接名称和直接字典变成间接的。

Here you change an indirect array of names into a direct one and a direct dictionary into an indirect one.

这篇关于PDF文档是否已被另一个修订版修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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