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

Brian Carrier commented on PDFBOX-435:
--------------------------------------

We do not seem to have permission to include this patch unless the submitter 
grants a license to ASF.   If the diff were added as an attachment to the 
report, the following should have been checked:

Grant license to ASF for inclusion in ASF works (as per the Apache License ยง5)
Contributions intended for inclusion in ASF products (eg. patches, code) must 
be licensed to ASF under the terms of the Apache License. Other attachments 
(eg. log dumps, test cases) need not be.


> Handling of trailers
> --------------------
>
>                 Key: PDFBOX-435
>                 URL: https://issues.apache.org/jira/browse/PDFBOX-435
>             Project: PDFBox
>          Issue Type: Improvement
>          Components: Parsing
>    Affects Versions: 0.8.0-incubator
>            Reporter: Anonymous
>            Priority: Minor
>         Attachments: trailerNoEOL.pdf
>
>
> Some PDF generating tools seem to produce invalid trailers but can 
> nevertheless be displayed e.g. by Acrobat Reader.
> Therefore, it would be nice if PDFBox could also process these documents.
> Example 1 (no EOL behind "trailer", as generated by "ScanSoft PDF Create! 4", 
> attached you will find an example):
> trailer<</Root 4 0 R/Info 1 0 R/Size 10/Prev 
> 2979/ID[<00000000000000000000000000000000><215eab4c095713feb4cdbb15a9eba968>]>>
> Example 2 (not EOL but just a blank behind "trailer", cannot publish my 
> example):
> trailer <<
> /Size 26
> /Root 24 0 R
> /Info 25 0 R
> /ID[<98fc28410100000042090000d1d1a606><98fc28410100000042090000d1d1a606>]
> >>: 
> Here is a fix proposal:
>     private boolean parseTrailer() throws IOException
>     {
>         if(pdfSource.peek() != 't'){
>             return false;
>         }
>         //read "trailer"
>         String nextLine = readLine();
>         if( !nextLine.equals( "trailer" ) ) {
>               // fix for example no 1 and no 2
>               // in some cases the EOL is missing and the trailer immediately 
> continues with "<<" or with a blank character
>               // even if this does not comply with PDF reference we want to 
> support as many PDFs as possible
>               // Acrobat reader can also deal with this.
>               if (nextLine.startsWith("trailer"))
>               {
>                       byte[] b = nextLine.getBytes();
>                       int len = "trailer".length();
>                       pdfSource.unread(b, len, b.length-len);
>               } 
>               else 
>               {
>             return false;
>               }
>         }
>         // fix for example no2
>         // in some cases the EOL is missing and the trailer continues with " 
> <<"
>         // even if this does not comply with PDF reference we want to support 
> as many PDFs as possible
>         // Acrobat reader can also deal with this.
>         skipSpaces();
>         
>         COSDictionary parsedTrailer = parseCOSDictionary();
>         COSDictionary docTrailer = document.getTrailer();
>         if( docTrailer == null )
>         {
>             document.setTrailer( parsedTrailer );
>         }
>         else
>         {
>             docTrailer.addAll( parsedTrailer );
>         }
>         skipSpaces();
>         return true;
>     }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to