You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by ca...@apache.org on 2009/04/08 15:42:26 UTC
svn commit: r763243 -
/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
Author: carrier
Date: Wed Apr 8 13:42:25 2009
New Revision: 763243
URL: http://svn.apache.org/viewvc?rev=763243&view=rev
Log:
Patch for PDFBOX-435 to handle trailers that are missing a newline. Patch by michael dot gesmann at gmx dot de.
Modified:
incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
Modified: incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java
URL: http://svn.apache.org/viewvc/incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java?rev=763243&r1=763242&r2=763243&view=diff
==============================================================================
--- incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java (original)
+++ incubator/pdfbox/trunk/src/main/java/org/apache/pdfbox/pdfparser/PDFParser.java Wed Apr 8 13:42:25 2009
@@ -549,8 +549,24 @@
//read "trailer"
String nextLine = readLine();
if( !nextLine.equals( "trailer" ) ) {
- return false;
+ // 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;
+ }
}
+
+ // 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 )