Created attachment 20189 [details] example ps file Hello, honourable ghostscript developers. I have several ps documents, created circa 1993 by "%%Creator: dvips 5.518 Copyright 1986, 1993 Radical Eye Software". They have in common the fact that pages are ordered inversely in them, which is indicated by the following header: %!PS-Adobe-2.0 %%Creator: dvips 5.518 Copyright 1986, 1993 Radical Eye Software %%Title: /home/eyalk/COMM_COMP/FKNN/FKNN.dvi %%Pages: 18 -1 %%PageOrder: Descend %%BoundingBox: 0 0 596 842 %%EndComments %DVIPSCommandLine: dvips /home/eyalk/COMM_COMP/FKNN/FKNN.dvi %DVIPSSource: TeX output 1995.08.02:0332 %%BeginProcSet: tex.pro GV interprets this header correctly and renders the document pages in the correct order. ps2pdf and ghostscript, however, do not do that, and, for example, gs -q -sDEVICE=ps2write -sOutputFile=pag%02d.ps FKNN.ps , where FKNN.ps is the file in question, generates a pdf file with reversed pages. Can suport for such kind of ps files be added?
Postscript, unlike PDF cannot be processed in any order except forward. GV may be re-interpreting the PostScript from the last page to the first, but Ghostscript doesn't deal with that since the input may come from a source that cannot be positioned (seeked). Converting the input to PDF first will yield a file that is page-independent and can be processed in arbitrary order (to ps2write or any device). There is an enhancement bug (IIRC) for processing PDF file pages in other than increasing order that is not yet complete. For raster image devices, the --saved-pages= option can be used to process all of the pages from any source (including PostScript) and then can be emitted from the collected command list files (clist) in arbitrary order, including reverse. I did confirm that --saved-pages= option works on this file with: gs --saved-pages=begin -sDEVICE=ppmraw -o x-%d.ppm Bug703147.ps \ --saved-pages="print reverse"
Is this a "wontfix" resolution, or a question? I was thinking that ps2pdf was intended to be a "high-level" command, a front-end to a more low-level gs engine, and is such, can possibly buffer the whole input (if it is standard input), and is even more likely to be launched with two file names as arguments. If the typical use-case is to convert streams of data, this request is probably out of place.
Created attachment 20389 [details] Adobe_Distiller_result.pdf
Since Acrobat Distiller does not honor these comments, implementing them in Ghostscript would deviate from industry practice. The PDF can be post-processed with a separate tool to change the page order if truly necessary; I recommend closing this bug.
I tend to concur with Peter, that we should close this, but passing it along to one of the pdfwrite developers to see if they want to implement this (possible since pdfwrite collects all of the pages before emitting the actual PDF). I also marked it as enhancement.