Summary: | ViewingOrientation is not honored if multiple PostScript documents are combined | ||
---|---|---|---|
Product: | Ghostscript | Reporter: | BOFH <raphael.affolter> |
Component: | PS Interpreter | Assignee: | Ken Sharp <ken.sharp> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | ghostscript_bugs, henry.stiles, ken.sharp, tpannier |
Priority: | P4 | ||
Version: | 9.02 | ||
Hardware: | PC | ||
OS: | Windows 7 | ||
Customer: | Word Size: | --- | |
Attachments: |
PostScript with one Portrait and one Landscape page
PostScript with one Landscape and one Portrait page Sample files for orientation issue between GS 8.54 and GS 9.06 |
Description
BOFH
2011-05-17 10:54:10 UTC
Please attach a PS file that is not converted correctly. Construction of a sample file based on your description adds to the workload of GS developers. Even a PFY should understand this. Created attachment 7512 [details]
PostScript with one Portrait and one Landscape page
File 1
Created attachment 7513 [details]
PostScript with one Landscape and one Portrait page
File 2
Greetings from the PFY, I'm glad you know me :-) I have attached two PostScript files. If they are converted to one PDF, the resulting PDF will be Portrait/Landscape/Portrait/Portrait instead of Portrait/Landscape/Landscape/Portrait Command: set GS=C:\PROGRA~1\GS\gs9.02\bin\gswin64c.exe "%GS%" -dNOPAUSE -dBATCH -dAutoRotatePages=/PageByPage -dDEBUG -sDEVICE=pdfwrite -sOutputFile=GhostscriptPDF.pdf -f PL.ps -f LP.ps To be more specific, only the first %%ViewingOrientation between %%BeginDefaults and %%EndDefaults is used. The %%ViewingOrientation of the individual page e.g. after %%Page: 2 2 is correctly read. Best Regards copy in ken to also work on this. I am having a similar issue when creating a PDF file from multiple post script files. I have a VB.NET application that will create a post script file for many different individual Word documents and/or Excel documents. The application then concatenates all the postscript files into one and then uses Ghostscript to convert the combined postscript file to a PDF. The command the application uses is gswin32c.exe -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=foo.pdf -sDEVICE=pdfwrite -c .setpdfwrite -f PsConcat.ps The application has been using Ghostscript 8.54 and I want to update to the latest version of 9.06. The problem I am seeing is when I open the PDF created all the pages are displayed in the orientation that the first postscript file is. This was not an issue when using Ghostscript 8.54. I have tested this with various versions of Ghostscript and found out any version after 8.54 causes all the pages of the PDF to display as the same orientation as the first post script file. I created some test files that I will attached. The test files are a Word document that is portrait and an Excel document that is Landscape. Both documents were printed using the Ghostscript PDF printer to produce the postscript files. For my test files I did not combine the postscript files like my application does since this did not affect the output. The command I used on my test files were gswin32c.exe -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=foo.pdf -sDEVICE=pdfwrite -c .setpdfwrite -f WordDoc_PortraitTest.ps -f ExcelDoc_LandscapeTest.ps and gswin32c.exe -q -dSAFER -dNOPAUSE -dBATCH -sOutputFile=foo1.pdf -sDEVICE=pdfwrite -c .setpdfwrite -f ExcelDoc_LandscapeTest.ps -f WordDoc_PortraitTest.ps When using Ghostscript 8.54 the first command produces a PDF with the first page displayed portrait and the second page displayed landscaped. The second command produces a PDF with the first page displayed landscaped and the second page portrait. When using Ghostscript 9.06 the first command produces a PDF with the first page displayed portrait and the second page displayed portrait and the text runs bottom to top. The second command produces a PDF with the first page displayed landscaped and the second page landscape with the text running from top to bottom. I am wondering if there was a change in the versions of Ghostscript after 8.54 to impact the display orientation of the PDFs generated or if I need some additional options in my command to get the same results that Ghostscript 8.54 produce? I hope this is an appropriate place to post this. If there is another place that would be better to post please let me know. Thanks in advance for any help. Created attachment 8890 [details]
Sample files for orientation issue between GS 8.54 and GS 9.06
Zip file contains postscript files used in my test and PDF output from both GS8.54 and GS9.06
There are (at least) 2 distinct problems here. The first one is that the PostScript DSC comments in the file(s) supplied by BOFH are incorrect. A single DSC-conforming PostScript file should only contain *one* %%Orientation comment which defines the 'document' orientation. If individual pages differ then each page should have a %%PageOrientation comment. From page 43 of the DSC 3 specification: %%Orientation: { <orientation> ... } | (atend) <orientation> ::= Portrait | Landscape This comment indicates the orientation of the pages in the document. It can be used by previewing applications and post-processors to determine how to orient the viewing window. A portrait orientation indicates that the longest edge of the paper is parallel to the vertical (y) axis. A landscape orientation indicates that the longest edge of the paper is parallel to the horizontal (x) axis. If more than one orientation applies to the document, an individual page should specify its orientation by using the %%PageOrientation: comment Note that the %%ViewingOrientation comment is not documented in the DSC 3.0 specification and so can't be considered a DSC comment. However we do process it, and indeed if we find one in a %%Pages section we alter it into a %%PageViewingOrientation so that we know it only affects this page, and isn't a document level comment. So, this means that, individually, both files work. What prevents them working when run one after another is that there is no provision for altering the document level DSC setup, We don't reset this between jobs. This causes a problem, because on the second document, the document orientation is incorrect, and causes us to rotate a page which doesn't need to be rotated. Note that, in contrast to the bug title, we *do* honour the %%ViewingOrientation comment, this is actually what causes the trouble. The reason that altering the scan trailer works is because this actually resets the scanning of the document level keys, in particular %%Orientation. In general DSC parsing doesn't have any effect on the output, the pdfwrite device is unusual in this respect. I'm not keen on altering the DSC parser, as it does in fact behave as intended at present. My suggestion would instead be to *disable* DSC processing when running multiple input files by adding to the command line: -c "<</ProcessDSCComment null>> setuserparams" -f The test files supplied by the BOFH work as expected with this. Alternatively convert each file individually to PDF, then run one 'combine' operation to stitch all the (now PDF files) together. I changed my mind :-) Commit 32df3bf46606f697d7deae86211c897be63a0764 resets portions of the DSC parser if it encounters a new DSC header while processing a trailer *and* we have already encountered a %%Trailer or %%EOF to close the job. Sorry for warming up this old bug, but to me it seems like ViewingOrientation is still (any maybe was never) honored. As soon as I specify the option AutoRotatePages=/None the first page of the attached example LP.ps will again be portrait instead of landscape. My commandline: gswin32c.exe -q -dSAFER -dNOPAUSE -dBATCH -dAutoRotatePages=/None -sOutputFile=foo.pdf -sDEVICE=pdfwrite -c .setpdfwrite -f PsConcat.ps Feel free to correct me in case I make wrong assumptions. Thank you in advance and best regards. (In reply to mw from comment #10) > Sorry for warming up this old bug, Please don't do this, especially after such a long time with the bug being closed. If you are going to reopen a bug report, you need to actually reopen it, not just post a comment (that is, change the status) or its very likely it will not get any attention. > but to me it seems like > ViewingOrientation is still (any maybe was never) honored. As soon as I > specify the option AutoRotatePages=/None the first page of the attached > example LP.ps will again be portrait instead of landscape. That's because setting auto-rotation to /None turns off auto-rotation. All of it. That includes automatic rotation from processing DSC comments. If you turn off auto-rotation you get exactly what the PostScript program executes. (Note that DSC comments are just that, comments, they don't form an active part of the PostScript program). If you run the programs in the way described in the original report, using an old version of Ghostscript (anything prior to 9.14) and currrent code, or anything from 9.14 onwards, you can see the actual effect. Thank you for the advice! Actually I was unsure what the correct procedure is. Reopening seems not to be an option, as I think bugzilla does not allow it for me. At least I see no way of doing ist. And thank you for explaining the connection between DSC and AutorotatePages. It is indeed documented but I overread it. Kind regards! (In reply to mw from comment #12) > Thank you for the advice! Actually I was unsure what the correct procedure > is. > Reopening seems not to be an option, as I think bugzilla does not allow it > for me. At least I see no way of doing ist. You should simply be able to click the dropdown menu for 'status' and change it to something else, eg UNCONFIRMED. As far as I know any registered user can do this. Obviously I can, but I've seen other (non staff) users reopen bugs so I believe it ought to be possible for you. The reason for changing it is that open bugs are tabulated internally on a regular email, and in Bugzilla itself bug owners can choose search criteria to view the bugs they own. Bugzilla says there are currently 1736 bugs assigned to me, all but 20 of which are resolved in some fashion. I only look at bugs assigned to me which are not resolved because it wouldn't be possible to look at all 1700+ of them. > You should simply be able to click the dropdown menu > for 'status' and change it to something else, eg UNCONFIRMED. I have seen the dropdown on other bugs (I just opened one), but on this one there is no dropdown for me. > I only look at bugs assigned to me which are not resolved > because it wouldn't be possible to look at all 1700+ of them. Another reason for me to say thank you :-) |