Bug 687557 - EndPage not called (with a reason code of 2) at end of job
Summary: EndPage not called (with a reason code of 2) at end of job
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Interpreter (show other bugs)
Version: master
Hardware: PC All
: P2 normal
Assignee: Ray Johnston
URL:
Keywords:
Depends on:
Blocks: 688318
  Show dependency tree
 
Reported: 2004-07-05 10:25 UTC by SaGS
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments
Short file to reproduce the problem. (465 bytes, application/postscript)
2004-07-05 10:32 UTC, SaGS
Details

Note You need to log in before you can comment on or make changes to this bug.
Description SaGS 2004-07-05 10:25:29 UTC
The attached file produces only 1 page of output, but it should 
produce 2. While /EndPage is set to force printing the final, 
incomplete (= without showpage) page, it is not called at end of 
job so this page does not appear in the output. Sometimes, 
/EndPage has to accomplish non-trivial tasks, like flushing the 
last sheet of paper for n-up printing, calling pdfmark, etc.
Comment 1 SaGS 2004-07-05 10:32:47 UTC
Created attachment 784 [details]
Short file to reproduce the problem.

Command lines (Windows version):

    gswin32c -q -dNOPAUSE -dBATCH -sOutputFile=Bug687557.pdf
	     -sDEVICE=pdfwrite -c .setpdfwrite -f Bug687557.ps

and

    gswin32c -q -dNOPAUSE -dBATCH -sOutputFile=Bug687557-%d.jpg
	     -sDEVICE=jpeg Bug687557.ps
Comment 2 Ray Johnston 2004-07-19 22:46:43 UTC
The .endpage was not being invoked when GS did the final closedevice.

I haven't investigated whether or not this used to work, but the
patch makes sure that the .uninstallpagedevice gets interpreted
before the final closedevice, so the .endpage gets run.

No regression changes result.

The patch is:

*** src/imain.c 27 Oct 2003 10:45:18 -0000      1.37
--- src/imain.c 20 Jul 2004 05:45:09 -0000
***************
*** 827,832 ****
--- 827,837 ----
        if (i_ctx_p->pgs != NULL && i_ctx_p->pgs->device != NULL) {
            gx_device *pdev = i_ctx_p->pgs->device;

+           /* deactivate the device just before we close it for the last time */
+           gs_main_run_string(minst,
+               ".uninstallpagedevice "
+               "serverdict /.jobsavelevel get 0 eq {/quit} {/stop} ifelse
.systemvar exec",
+               0 , &exit_code, &error_object);
            code = gs_closedevice(pdev);
            if (code < 0)
                eprintf2("ERROR %d closing the device. See gs/src/ierrors.h for
code explanation.\n", code, i_ctx_p->pgs->device->dname);