Patch for 689413, running default file from PDF collection

Alex Cherepanov <[email protected]> Tue, 23 Oct 2007 22:49:35 -0400
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------010102050503020600090004
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Display the default file in PDF file by extracting it from the embedded
file stream to a temporary file and re-starting the PDF interpreter.

The patch is quite straightforward but there are a few issues related
to the PDF file collection I'd like to discuss.

1. The patch doesn't delete the temp file. An simple appoach would
    be saving the file and the file name and delete the file
    in runpdfend procedure.

    Alternatively, we can create a file that deletes itself from
    disk when it is closed.

2. Currently, there's no way to select non-default files from the
    collection. The content of the collection is not listed either.
    Suggestions about the user's interface are welcome.

3. The current code location is inconvenient for rendering of
    multiple files from the collection. Do we need this feature?

Regards,
Alex Cherepanov


--------------010102050503020600090004
Content-Type: text/plain;
 name="689413.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="689413.diff"

Index: gs/lib/pdf_main.ps
===================================================================
--- gs/lib/pdf_main.ps	(revision 8312)
+++ gs/lib/pdf_main.ps	(working copy)
@@ -467,6 +467,40 @@
     }
    if
   pdfopenfile begin
+  Trailer /Root oget /Collection knownoget {
+    /D knownoget { % We have default document in the collection
+      Trailer /Root oget /Names knownoget {
+        /EmbeddedFiles knownoget {
+          exch nameoget dup //null ne {
+            /EF knownoget {
+              /F knownoget {
+                //true resolvestream    % strm
+                //null (w+) .tempfile   % strm (name) file
+                3 -1 roll               % (name) file strm
+	        32768 string            % (name) file strm (buf)
+	        { 3 copy readstring     % (name) file strm (buf) file (data) bool
+                  3 1 roll              % (name) file strm (buf) bool file (data)
+                  writestring           % (name) file strm (buf) bool
+ 	    	  not { exit } if
+	        } loop                  
+                pop closefile           % (name) file
+                exch pop                % file   %  can't delete temp file here
+	        dup 0 setfileposition
+                end  % old state
+                pdfopenfile begin
+              } if
+            } if
+          } {
+            pop
+          } ifelse
+        } {
+          pop
+        } ifelse
+      } {
+        pop
+      } ifelse
+    } if
+  } if
   pdfopencache
   writeoutputintents
   .writepdfmarks {

--------------010102050503020600090004
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

--------------010102050503020600090004--