PDF generation using PostScript and Distiller just stops - how do I debug?
I know very little about PostScript and Adobe Distiller so please bear with me and if I'm in the wrong place, suggest where I need to be.
At a very high level, I have inherited and am supporting an application that generates PostScript files and then asks Distiller to generate PDFs from these.
- For each user transaction, 2 PDFs are expected.
- The application generates multiple PostScript files.
- There are several PostScript files, each that represent the content of a "chapter".
- There is one top-level PostScript file that references each "chapter" PostScript file in order. The application asks Distiller to print this PostScript file and the result is the entire "book" as a PDF. This is PDF #1.
- There is a second top-level PostScript file that references a subset of pages from each "chapter" PostScript file. The application also asks Distiller to print this PostScript file and the result is a subset of the book as a PDF. This is PDF #2.
In most cases (for many years), both PDFs generate successfully. We have now encountered a case where PDF #1 generates successfully but PDF #2 does not. When the application asks Distiller to print PDF #2, Distiller starts to do so but stops prematurely. The application thinks the PDF generation was successful because it received no error/exception, there is no error/exception in the LOG file generated by Distiller, yet PDF #2 only contains the first N pages.
If anyone can tell me what we're doing wrong or at least tell me how I can better troubleshoot this, any and all help is greatly appreciated.
Some more detail about the data and what I've already tried/learned so far...
The pages in the book can contain text or full page graphics. The standard page size for the book is 8x11. The page size for full page graphics include 11x17 and 11x24 (i.e., foldouts). We thought this may be the first case where the book contains graphics requiring 11x24 page size and that the root case had something to do with this.
- The last PostScript command processed by Distiller before ending prematurely is the first set of pages that includes an 11x24 graphic.
- If we try generating PDF #2 from a page after page N, Distiller starts but again ends prematurely with the last PostScript command processed as one that includes an 11x24 graphic.
But...
- PDF #1 prints successfully and is complete. It includes the 11x24 graphics pages just fine.
- I modified the source data that indicates which graphics are 11x24 to be 11x17. The problem still remained.
- I replaced the 11x24 graphics with 11x17 graphics. The problem still remained.
Distiller is run with the -F parameter.
PostScript for "chapter" files - Our code does not actually generate this PostScript. Our code executes in a 3rd party environment that takes care of this. Sending these files to Distiller individually results in a PDF with the correct number of pages, the correct content, the correct page sizes, and correct content/page orientation (i.e., graphics were properly rotated on 11x17 and 11x24 pages).
PDF #1 PostScript Sample:
/prun { /mysave save def
dup = flush
RunFile
clear cleardictstack
mysave restore
} def
(path/to/chapter1.ps) prun
(path/to/chapter2.ps) prun
...
PDF #2 PostScript Sample:
/ch1 (path/to/chapter1.ps) def
/ch2 (path/to/chapter2.ps) def
...
/prun { /mysave save def
dup = flush
<</StartPage 1>> setdistillerparams
<</EndPage 2>> setdistillerparams
RunFile
clear cleardictstack
mysave restore
} def
ch1 prun
/prun { /mysave save def
dup = flush
<</StartPage 5>> setdistillerparams
<</EndPage 6>> setdistillerparams
RunFile
clear cleardictstack
mysave restore
} def
ch1 prun
/prun { /mysave save def
dup = flush
<</StartPage 13>> setdistillerparams
<</EndPage 14>> setdistillerparams
RunFile
clear cleardictstack
mysave restore
} def
ch2 prun
... (pattern repeats w/ different start/end page numbers
The start/end page counters for the PDF #2 PostScript seemed odd to me but in general the formula in use works. I wondered if something would be different for 11x24 pages but when we print the "chapter" PostScript file, the 11x24 page is considered one page (per the log file).
What I tried with the PDF #2 PostScript...
- If I reduce it to just the chapter that contains the first 11x24 graphic (e.g., Chapter 15), Distiller still stopped prematurely.
- The iteration of calls to prun are done in sets of 2 book pages (or 1 physical page, front and back). I tried reducing the number of calls by adjusting the start/end page counts (e.g., if page 1, 2, 3 and 4 need to be included, instead of 2 Distiller calls, one for pages 1-2 and one for pages 3-4, only have one for pages 1-4). Distiller still stopped prematurely but included any addition pages in the last set processed.
- I tried changing the PostScript itself (see below) such that a call to Distiller only prints one page at a time and we iterate over an array (vs. repeat prun definitions). This actually resulted in a limit check error message prior to even reaching the point where Distiller typically stops prematurely. Several attempts were made at trying to solve this issue w/ no luck.
- Thinking any/all of the above was the result of a memory issue, added "false 0 startjob pop" after "RunFile" (per some other post I found) to both the current implementation and the alternative below. Distiller still stopped prematurely.
Alternative PDF #2 PostScript Sample:
/prun {
<</StartPage currentpage>> setdistillerparams
<</EndPage currentpage>> setdistillerparams
dup = flush
RunFile
} bind def
/processch {
LOCAL begin
/FILE exch def
/PAGES exch def
PAGES {
/currentpage exch def
FILE prun
} forall
end
} dup 0 1 dict put def
/ch1 (path/to/chapter1.ps) def
/ch1pgs [1 3 6 10] def
/ch2 (path/to/chapter2.ps) def
/ch2pgs [15 21] def
...
ch1pgs ch1 processch
ch2pgs ch2 processch
...
Thanks,
Kelly
