[ 
https://issues.apache.org/jira/browse/PDFBOX-1822?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13879862#comment-13879862
 ] 

Andreas Lehmkühler commented on PDFBOX-1822:
--------------------------------------------

The origin issue is that PDFBox changes the kind of the trailer xref under 
special circumstances which leads to mixed up xref types in the origin pdf and 
the appended part after signing. According to 
[http://stackoverflow.com/questions/21257507/attachment-damages-singature/21260292?noredirect=1#21260292|http://stackoverflow.com/questions/21257507/attachment-damages-singature/21260292?noredirect=1#21260292]
 that's not allowed and leads to the described issue.

The given pdf is malformed as it contains a somehow merged trailer dictionary, 
so that we can't rely on the /Type value of that dictionary. My idea was to 
determine the xref type when the trailer xref is read. The non-sequential 
parser starts with reading the trailer so that it is easy to determine if it 
uses a xref table or a stream. The "old" parser on the contrary starts from the 
beginning, reads all objects and tries to figure out their meaning at the end 
and I didn't found a way to determine the trailer xref type.

[~tboehme] I agree there is gap and I already reopened the issue. But your 
proposal would lead to the same issue when using the old parser, as the 
fallback again relies on the /Type value which is wrong in the given pdf. IMO 
the only solution for the "old" parser is to find a way to detect the xref type 
when reading/using the first trailer similar to the non-sequential solution. 
Any ideas on how to do that?

> Signature byte range is Invalid
> -------------------------------
>
>                 Key: PDFBOX-1822
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-1822
>             Project: PDFBox
>          Issue Type: Bug
>          Components: Parsing, PDModel, PDModel.AcroForm, Signing
>    Affects Versions: 1.8.3, 1.8.4, 2.0.0
>            Reporter: vakhtang koroghlishvili
>            Assignee: Andreas Lehmkühler
>             Fix For: 1.8.4, 2.0.0
>
>         Attachments: araxis-merge - compare two document.jpg, 
> damaged-sig.jpg, unsigned-signed.pdf, unsigned.pdf, unsigned_signed_fix.pdf
>
>
> On person send me a unsigned PDF document. He wanted to sign it. When I try 
> to sign it (using pad box), I have some problem.
> After signing adobe reader tells me "The signature byre range is invalid".  
> I will attach original and signed document.
> I think, it is PDF box parser error. another signature libraries sign 
> document very well. I'm searching the problem at the moment, in order to fix 
> it.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to