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

alexcher at ghostscript.com alexcher at ghostscript.com
Tue Apr 22 17:30:10 PDT 2008


Author: alexcher
Date: 2008-04-22 17:30:10 -0700 (Tue, 22 Apr 2008)
New Revision: 8658

Modified:
   trunk/gs/lib/pdfopt.ps
   trunk/gs/lib/pdfwrite.ps
Log:
Since we always write a complete "classic" xref, the Trailer may need to be
adjusted: (1) remove keys that pertain to xref-streams and hybrid-xref PDFs;
(2) if it's a PDF stream, turn it into a PDF dict by removing keys used for
PDF streams (both standard and GS-specific), and the executable attribute.
Thanks to SaGS for the patch. Bug 688152.


Modified: trunk/gs/lib/pdfopt.ps
===================================================================
--- trunk/gs/lib/pdfopt.ps	2008-04-22 17:18:03 UTC (rev 8657)
+++ trunk/gs/lib/pdfopt.ps	2008-04-23 00:30:10 UTC (rev 8658)
@@ -684,7 +684,7 @@
 /writePart3 {		% <xrefstart> writePart3 -
   {
     FirstPageXN NObjects 1 add 1 index sub pdfwritexref
-    Trailer dup length 1 add dict copy
+    Trailer dup length 1 add dict copy Trailer xcheck { cvx } if
     dup /Size NObjects 1 add put
     dup /Prev 4 -1 roll put
     pdfwritetrailer

Modified: trunk/gs/lib/pdfwrite.ps
===================================================================
--- trunk/gs/lib/pdfwrite.ps	2008-04-22 17:18:03 UTC (rev 8657)
+++ trunk/gs/lib/pdfwrite.ps	2008-04-23 00:30:10 UTC (rev 8658)
@@ -335,7 +335,20 @@
   } for
 } bind def
 /pdfwritetrailer {	% <trailer> pdfwritetrailer -
-  (trailer\n) ows pdfwritevalue (\n) ows
+  (trailer\n) ows
+  % Since we always write a complete "classic" xref, the Trailer may need to be adjusted:
+  % - remove keys that pertain to xref-streams and hybrid-xref PDFs;
+  % - if it's a PDF stream, turn it into a PDF dict by removing keys used for 
+  %   PDF streams (both standard and GS-specific), and the executable attribute
+  dup /XRefStm known 1 index xcheck or {
+    dup length dict copy
+    dup {/Type/Index/W /XRefStm /Filter/DecodeParms/Length/File/FilePosition} {
+      undef dup
+    } forall pop
+    % note: the executable attribute is "removed" by not being copied
+  } if
+  pdfwritevalue
+  (\n) ows
 } bind def
 /pdfwritestartxref {	% <startpos> pdfwritestartxref -
   (startxref\n) ows OFile exch write=
@@ -374,7 +387,7 @@
 
   /xref OFile fileposition def
   0 XRef ld_length 1 add pdfwritexref
-  trailer dup length 1 add dict copy
+  trailer dup length 1 add dict copy trailer xcheck { cvx } if
   dup /Size XRef ld_length 1 add put pdfwritetrailer
   xref pdfwritestartxref
 



More information about the gs-cvs mailing list