Fix for 688675 Reading / Converting PDF File created with Adobe Lifecycle Designer 7.0

"Dan Coby" <[email protected]> Mon, 15 May 2006 14:00:00 -0700
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------=_NextPart_000_006B_01C67827.DB1B87B0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit


I thought that I would send this out for comments.  The basic problem
is that the file is broken.  It has xref tables with entries that have
incorrect generation number values.

Message:

Fix for 688675  Reading / Converting PDF File created with Adobe 
Lifecycle Designer 7.0.

DETAILS:

The test file has xref tables with incorrect generation numbers for
serveral entries.  The xref verification logic finds the mismatch
between the generation numbers specified in the xref and the generation
numbers in the objects.  It then attempts to requild the xref table.
This fails since the xref rebuild logic does not handle rebuilding
compressed object streams.  As a result the file cannot be displayed.

The fix consists of three parts.

1.  Change the xref verification logic to exit if compressed object
streams are detected.  I am not attempting to recover objects in
compressed object streams since anything that damages a file will
generally trash any compressed data.

2.  Change the logic which checks the generation number to simply
print a warning but to continue.  Previously this logic would print
a warning and then reject the object. Rejecting an object generally
causes an error to occur as the PDF interpreter attempts to use the
object.  The warning message was also enhanced to print both the
expected and actually generation numbers.  The given test file
produces about 400 warning messages.

3.  Enhance the comments for the print_xref.


------=_NextPart_000_006B_01C67827.DB1B87B0
Content-Type: text/plain;
	name="dif.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="dif.txt"

Index: lib/pdf_base.ps
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- lib/pdf_base.ps	(revision 6725)
+++ lib/pdf_base.ps	(working copy)
@@ -418,15 +418,23 @@
     QUIET not {				% Create warning message if not QUIET=0A=
       Generations 2 index lget 0 eq {	% Check if object is free ...=0A=
 	(   **** Warning: reference to free object: )=0A=
+        2 index =3Dstring cvs concatstrings ( ) concatstrings	% put obj =
#=0A=
+        exch =3Dstring cvs concatstrings ( R\n) concatstrings	% put gen =
#=0A=
       } {=0A=
 	(   **** Warning: wrong generation: )=0A=
+        2 index =3Dstring cvs concatstrings ( ) concatstrings	% put obj =
#=0A=
+        exch =3Dstring cvs concatstrings				% put gen #=0A=
+       	(, xref gen#: ) concatstrings 1 index Generations  % put xref =
gen #=0A=
+       	exch lget 1 sub =3Dstring cvs concatstrings (\n) concatstrings=0A=
       } ifelse=0A=
-      2 index =3Dstring cvs concatstrings ( ) concatstrings	% put obj #=0A=
-      exch =3Dstring cvs concatstrings ( R\n) concatstrings	% put gen #=0A=
       pdfformaterror			% Output warning message=0A=
     } {					% Else QUIET ...=0A=
-      pop				% Pop generation umber=0A=
-    } ifelse false			% Return false if gen # not match=0A=
+      pop				% Pop generation number=0A=
+    } ifelse=0A=
+    % We should return false for an incorrect generation number, however=0A=
+    % we are simply printing a warning and then returning true.  This =
makes=0A=
+    % Ghostscript tolerant of of bad generation numbers.=0A=
+    true=0A=
   } ifelse=0A=
 } bind def=0A=
 /R {		% <object#> <generation#> R <object>=0A=
Index: lib/pdf_main.ps
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- lib/pdf_main.ps	(revision 6725)
+++ lib/pdf_main.ps	(working copy)
@@ -497,7 +497,12 @@
 	  search_objects=0A=
 	  exit=0A=
 	} if				% If the entry is invalid=0A=
-      } if				% If not in an object stream=0A=
+      } {=0A=
+	      % The object is in an object stream.  We currently do not rebuild=0A=
+	      % objects in an object stream.  So If we find one, then abort the=0A=
+	      % verification of the xref table entries.=0A=
+	pop exit			% Pop object number and then exit loop=0A=
+      } ifelse				% If not in an object stream=0A=
     } if				% If object entry is not free=0A=
     pop					% Remove object number=0A=
   } for=0A=
Index: lib/pdf_rbld.ps
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- lib/pdf_rbld.ps	(revision 6725)
+++ lib/pdf_rbld.ps	(working copy)
@@ -73,10 +73,10 @@
   } ifelse=0A=
 } bind def=0A=
 =0A=
-% Print the contents of the xref array.  This actually consists of two=0A=
-% arrays (Objects and Generations).  Both are larrays.  larrays are a=0A=
-% special Ghostscript object which can be arrays with more than 64k=0A=
-% elements.=0A=
+% Print the contents of the xref array.  This actually consists of three=0A=
+% arrays (Objects, Generations, and ObjectStream).  All three are =
larrays.=0A=
+% larrays are a special Ghostscript object which can be arrays with more=0A=
+% than 64k elements.=0A=
 /print_xref				% - print_xref -=0A=
 { 0 1 Objects llength 1 sub		% stack: 0 1 <number of objects - 1>=0A=
   { dup =3Donly				% print object number=0A=

------=_NextPart_000_006B_01C67827.DB1B87B0
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review

------=_NextPart_000_006B_01C67827.DB1B87B0--