[gs-cvs] rev 6920 - trunk/gs/lib

dan at ghostscript.com dan at ghostscript.com
Wed Jul 19 15:38:15 PDT 2006


Author: dan
Date: 2006-07-19 15:38:15 -0700 (Wed, 19 Jul 2006)
New Revision: 6920

Modified:
   trunk/gs/lib/pdf_rbld.ps
Log:
Fix for 688787 /undefined in /BXlevel.

DETAILS:

The given test file has definite problems.  Most of the
xref entries are off by one byte.  Several of the xref
entries are off by thousands of bytes.  However the worst
problem is the value given for startxref.  This value
is off by tens of thousands of bytes.

The xref rebuild logic needs to find the final trailer
dictionary.  It uses the startxref value to find this
dictionary.  Since the file is damaged the rebuild logic
does not simply assume that the trailer dictionary is at
the given location.  Instead this logic compares ithe value
to the size of the file.  If less than one half of the size
of the file then we search at the beginning of the file.
This generally works for 'linearized' PDF files.  Othewise
the rebuild logic search for the last trailer dict in the
file.  This works for most non linearized files.

This file indicates that the trailer dict should be at
the start of the file.  However the trailer dict is at
the end of the file.  The fix consists of searching at
the end of the file when a trailer dict is not found at
the start of a file.


Modified: trunk/gs/lib/pdf_rbld.ps
===================================================================
--- trunk/gs/lib/pdf_rbld.ps	2006-07-17 19:11:34 UTC (rev 6919)
+++ trunk/gs/lib/pdf_rbld.ps	2006-07-19 22:38:15 UTC (rev 6920)
@@ -126,7 +126,10 @@
 /search_start_trailer		% - search_start_trailer <trailer loc>
 { % Read the first 300 bytes and check for xref
   PDFfile 0 setfileposition
-  300 string 0 1 299 { 2 copy PDFfile read pop put pop } for
+  PDFfile bytesavailable post_eof_count sub	% location of end of data
+  300 .min			% block size to read
+  dup string 0 1 4 -1 roll 1 sub
+  { 2 copy PDFfile read pop put pop } for
   (xref) search {
     % found 'xref'
     exch pop exch pop length 4 add PDFfile exch setfileposition
@@ -142,7 +145,7 @@
       PDFfile fileposition	% get file position
     } if
   } {
-    pop 0			% no xref - should not happen
+    pop search_end_trailer	% no xref, should not happen, search end of file
   } ifelse
 } bind def
 
@@ -154,7 +157,7 @@
   % anything past the last %%EOF since this is not PDF data.
   PDFfile 0 setfileposition
   PDFfile bytesavailable post_eof_count sub	% location of end of data
-  dup 4096 .min			% block size to read
+  dup 65535 .min		% block size to read
 				% stack: <file end pos> <block size>
   % move file position to the start of the block
   2 copy sub PDFfile exch setfileposition



More information about the gs-cvs mailing list