Some details in the behaviour of /AutoRotatePages are different in Ghostscript than in Distiller. (My tests were with Distiller 4.05.) There is mention of one in bug #689267 "File converted to PDF displays badly in Acrobat", from which this report is a spin off. Note: /AutoRotatePages does not have an exact definition. As a result, one can find endless factors that potentially influence the final page rotation. The sample and patch below concern only things I considered most important: Type 1 and Type 3 fonts, text rotation in multiples of 90deg, and mirroring.
Created attachment 3308 [details] Sample/ test pack (ZIP file). Attached ZIP includes the following files: Bug999093-[autorot]-test.ps File that shows the differences in AutoRotatePages behaviour, also used for testing. Contains 1024 cases, all combinations of: - Type 1 or Type 3 font; - mirroring and/or 0/90/180/270deg rotation in the original FontMatrix (at definefont time); - same, in the matrix passed to makefont when creating the font used to draw the text; - same, in the PS current->default user space transform. Convert to PDF using "/AutoRotatePages = /PageByPage" and compare results from different converters. The file uses pdfmarks to store all above information in the output PDF. Bug999093-[autorot]-testinfo.ps Extracts the info about mirroring/rotation stored in the PDF plus the resulting page /Rotate and dumps them to a tab-delimited text file for easy comparison. For usage, see comments in file. Bug999093-[autorot]-test-Distiller4,05.pdf Bug999093-[autorot]-test-gs8204EX.pdf PDF files created by Distiller 4.05 and unpatched Ghostscript rev 8204 from the test file. The big red arrows indicate the PS user space orientation at distill-time. Note: The "EX" means "with an unrelated [for bug #689267] patch applied". That patch does not influence rotation, but fixes glyphs placement to make visual/ raster comparison possible.
Created attachment 3309 [details] Suggested patch. Distiller's rules for AutoRotatePages are weird, but this patch makes Ghostscript produce the same output as Distiller. The cases taken in consideration are those mentioned in comment #1.
Created attachment 5374 [details] 689418.ps.gz PS file from the ZIP archive with a fix for misplaced bind operator.
(In reply to comment #0) > Some details in the behaviour of /AutoRotatePages are different in > Ghostscript than in Distiller. (My tests were with Distiller 4.05.) > There is mention of one in bug #689267 "File converted to PDF displays > badly in Acrobat", from which this report is a spin off. > > Note: > /AutoRotatePages does not have an exact definition. As a result, > one can find endless factors that potentially influence the final > page rotation. The sample and patch below concern only things I > considered most important: Type 1 and Type 3 fonts, text rotation > in multiples of 90deg, and mirroring. I haven't looked at all 1024 (!) pages of output produced by the PostScript file, but.... On the whole I personally prefer the behaviour of pdfwrite, I think its more consistent since the text is more frequently presented running left to right. At times Distiller produces text which runs in every possible direction, and on some occasions the text doesn't run left to right, and the CTM is not 'upright' either. I don't think there's any need for us to conform exactly to the way Adobe works, and our users will expect the behaviour to remain as it does now so I'm going to turn this one down for the present at least. Should there be actual customer complaints about the AutoRotatePages feature and the way it works then I'll reconsider this. Many thanks for your efforts anyway, it is appreciated, and we may one day use the code if someone produces a file which is sufficiently wrong to be a problem.