arnima@u.washington.edu
2003-Oct-08 05:00 UTC
[Rd] Unpredictable EPS->PDF rotation (PR#4460)
Dear r-bugs, When I create EPS files, they sometimes appear rotated in my LaTeX PDF document and sometimes they don't. Two examples: ## x1.eps is not rotated in LaTeX x <- seq(-1, 1, length=100) postscript("c:/x1.eps", height=3, width=4, horizontal=FALSE, onefile=FALSE, paper="special") plot(x, dnorm(x), type="l") dev.off() ## x2.eps is not rotated in LaTeX x <- seq(-2, 2, length=100) postscript("c:/x2.eps", height=3, width=4, horizontal=FALSE, onefile=FALSE, paper="special") plot(x, dnorm(x), type="l") dev.off() By LaTeX PDF, I am referring to the dvips->ghostscript pathway, but x2.eps also rotates when distilled into PDF outside LaTeX. I have tried ghostscript and acrobat, placed on a page or cropped, so the problem does not seem to be confounded with particular PDF distillation software. I'm aware of the pdf() device in R, but EPS files are a widely used format to share scientific graphics, often winding up embedded in a PDF document at a later point in the hands of an editor. If at all possible, a more predictable postscript generator would be appreciated, where EPS figures would not rotate when embedded in PDF documents. Regards, Arni OS: Windows XP R: 1.7.1
arnima@u.washington.edu writes:> Dear r-bugs, > > When I create EPS files, they sometimes appear rotated in my LaTeX PDF > document and sometimes they don't. Two examples: > > ## x1.eps is not rotated in LaTeX > x <- seq(-1, 1, length=100) > postscript("c:/x1.eps", height=3, width=4, > horizontal=FALSE, onefile=FALSE, paper="special") > plot(x, dnorm(x), type="l") > dev.off() > > ## x2.eps is not rotated in LaTeX > x <- seq(-2, 2, length=100) > postscript("c:/x2.eps", height=3, width=4, > horizontal=FALSE, onefile=FALSE, paper="special") > plot(x, dnorm(x), type="l") > dev.off() > > By LaTeX PDF, I am referring to the dvips->ghostscript pathway, but x2.eps > also rotates when distilled into PDF outside LaTeX. I have tried > ghostscript and acrobat, placed on a page or cropped, so the problem does > not seem to be confounded with particular PDF distillation software. > > I'm aware of the pdf() device in R, but EPS files are a widely used format > to share scientific graphics, often winding up embedded in a PDF document > at a later point in the hands of an editor. > > If at all possible, a more predictable postscript generator would be > appreciated, where EPS figures would not rotate when embedded in PDF > documents.I can reproduce the effect on RedHat 8, but I'm at a loss as to explain it. The headers and bounding boxes of the two .eps files are identical and to the best of my eyesight they are also using the same coordinate system. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk) FAX: (+45) 35327907
maechler@stat.math.ethz.ch
2003-Oct-08 12:08 UTC
[Rd] Unpredictable EPS->PDF rotation (PR#4460)
>>>>> "PD" == Peter Dalgaard BSA <p.dalgaard@biostat.ku.dk> >>>>> on 08 Oct 2003 11:36:52 +0200 writes:PD> arnima@u.washington.edu writes: >> Dear r-bugs, >> >> When I create EPS files, they sometimes appear rotated in my LaTeX PDF >> document and sometimes they don't. Two examples: >> >> ## x1.eps is not rotated in LaTeX >> x <- seq(-1, 1, length=100) >> postscript("c:/x1.eps", height=3, width=4, >> horizontal=FALSE, onefile=FALSE, paper="special") >> plot(x, dnorm(x), type="l") >> dev.off() >> >> ## x2.eps is not rotated in LaTeX >> x <- seq(-2, 2, length=100) >> postscript("c:/x2.eps", height=3, width=4, >> horizontal=FALSE, onefile=FALSE, paper="special") >> plot(x, dnorm(x), type="l") >> dev.off() >> >> By LaTeX PDF, I am referring to the dvips->ghostscript pathway, but x2.eps >> also rotates when distilled into PDF outside LaTeX. I have tried >> ghostscript and acrobat, placed on a page or cropped, so the problem does >> not seem to be confounded with particular PDF distillation software. >> >> I'm aware of the pdf() device in R, but EPS files are a widely used format >> to share scientific graphics, often winding up embedded in a PDF document >> at a later point in the hands of an editor. >> >> If at all possible, a more predictable postscript generator would be >> appreciated, where EPS figures would not rotate when embedded in PDF >> documents. PD> I can reproduce the effect on RedHat 8, but I'm at a loss as to PD> explain it. The headers and bounding boxes of the two .eps files are PD> identical and to the best of my eyesight they are also using the same PD> coordinate system. It's definitely unrelated to R. The "bug" is in newer versions of gs (ghostscript) which does rotate plots under some circumstances by default. Of course, the authors of gs consider this a feature (called "AutoRotatePages"), but IMO it's been a very bad design-decision. Here, we have implemented a workaround by patching the "epstopdf" (shell script) (we use the version from teTeX), by the following: --- epstopdf.~1~ 2002-04-20 00:00:00.000000000 +0200 +++ epstopdf 2003-03-13 16:43:53.000000000 +0100 @@ -182,6 +182,8 @@ ### open output file if ($::opt_gs) { my $pipe = "$GS -q -sDEVICE=pdfwrite $GSOPTS " . + "-dAutoRotatePages=/None " . ## MMä: <<<< This is the fix I found via google +## http://lists.debian.org/debian-tetex-maint/2002/debian-tetex-maint-200202/msg00013.html "-sOutputFile=$OutputFilename - -c quit"; debug "Ghostscript pipe:", $pipe; open(OUT,"|$pipe") or error "Cannot open Ghostscript for piped input"; ------------------- I'm interested to hear about more current workarounds / "official" ways to deal with this ``cool gs feature'' .. Martin Maechler <maechler@stat.math.ethz.ch> http://stat.ethz.ch/~maechler/ Seminar fuer Statistik, ETH-Zentrum LEO C16 Leonhardstr. 27 ETH (Federal Inst. Technology) 8092 Zurich SWITZERLAND phone: x-41-1-632-3408 fax: ...-1228 <><
ripley@stats.ox.ac.uk
2003-Oct-08 12:30 UTC
[Rd] Unpredictable EPS->PDF rotation (PR#4460)
On 8 Oct 2003, Peter Dalgaard BSA wrote:> arnima@u.washington.edu writes: > > > Dear r-bugs, > > > > When I create EPS files, they sometimes appear rotated in my LaTeX PDF > > document and sometimes they don't. Two examples: > > > > ## x1.eps is not rotated in LaTeX > > x <- seq(-1, 1, length=100) > > postscript("c:/x1.eps", height=3, width=4, > > horizontal=FALSE, onefile=FALSE, paper="special") > > plot(x, dnorm(x), type="l") > > dev.off() > > > > ## x2.eps is not rotated in LaTeX > > x <- seq(-2, 2, length=100) > > postscript("c:/x2.eps", height=3, width=4, > > horizontal=FALSE, onefile=FALSE, paper="special") > > plot(x, dnorm(x), type="l") > > dev.off() > > > > By LaTeX PDF, I am referring to the dvips->ghostscript pathway, but x2.eps > > also rotates when distilled into PDF outside LaTeX. I have tried > > ghostscript and acrobat, placed on a page or cropped, so the problem does > > not seem to be confounded with particular PDF distillation software. > > > > I'm aware of the pdf() device in R, but EPS files are a widely used format > > to share scientific graphics, often winding up embedded in a PDF document > > at a later point in the hands of an editor. > > > > If at all possible, a more predictable postscript generator would be > > appreciated, where EPS figures would not rotate when embedded in PDF > > documents.I think this is nothing to do with R, which generates predictable postscript for me.> I can reproduce the effect on RedHat 8, but I'm at a loss as toPerhaps you could tells us what the effect is (the original message says neither is rotated!) and how exactly to reproduce it? I found that x1.eps is not rotated by Distiller, but x2.eps is. That's not a bug but intentional: Distiller (on its default settings) does auto-rotate individual pages of eps files. My guess is that gs is doing something similar on your setup -- it rotates for me under gs8.00 unless I set AutoRotate to /None (I used Convert in GSView to do so).> explain it. The headers and bounding boxes of the two .eps files are > identical and to the best of my eyesight they are also using the same > coordinate system. >-- Brian D. Ripley, ripley@stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595
On 08-Oct-03 arnima@u.washington.edu wrote:> When I create EPS files, they sometimes appear rotated in my LaTeX PDF > document and sometimes they don't. Two examples: > >## x1.eps is not rotated in LaTeX > x <- seq(-1, 1, length=100) > postscript("c:/x1.eps", height=3, width=4, > horizontal=FALSE, onefile=FALSE, paper="special") > plot(x, dnorm(x), type="l") > dev.off() > >## x2.eps is not rotated in LaTeX > x <- seq(-2, 2, length=100) > postscript("c:/x2.eps", height=3, width=4, > horizontal=FALSE, onefile=FALSE, paper="special") > plot(x, dnorm(x), type="l") > dev.off() > > By LaTeX PDF, I am referring to the dvips->ghostscript pathway, but > x2.eps > also rotates when distilled into PDF outside LaTeX. I have tried > ghostscript and acrobat, placed on a page or cropped, so the problem > does not seem to be confounded with particular PDF distillation > software.I've done an experiment or two (and I've read Peter Dalgaard's reply). Using Red Hat 9, I imported the two files x1.eps and x2.eps as output by R-1.7.1 into a groff document, both on one page and one above the other, outputting the result as a PS file, temp.ps. Using ghostview, the result displayed fine: right way up. Then distilled this to PDF, using (a) ps2pdf from ghostscript 7.05, then (b) epstopdf from TeX (though this too calls ghostscript). In both cases, the entire page displayed in Acrobat Reader rotated right through 90 degrees, i.e. the wrong way round. Then I transferred the temp.ps file to two other machines. [A] On one, SuSE Linux 5.2, I have an elderly copy of PStill (See Frank Siegert's site http://www.pstill.com ) which actually is a better distiller than ghostscript provides. The resulting PDF displayed right way up using acroread 3.0. I then converted to PDF using ps2pdf (ghostscript 5.10) and again it was the right way up. [B] On the other, SuSE Linux 7.2, I converted using ps2pdf (ghostscript 5.50) and again it was the right way up when viewed with acroread 4.0. Then I transferred both PDF files, from [A] and from [B], back to the original Red Hat 9 machine and viewed each using aroread 5.0, and they were still the right way up. It would seem from this that the problem arises with the distillation using ghostscript 7.05 (I don't have access to Acrobat Distiller). BY THE WAY: I had a look at the PostScript code in the EPS files from R, and noticed that the begin-page and end-page definitions use double invocations of gsave and grestore: /bp { gs gs } def % begin .ps.prolog /gs { gsave } def /gr { grestore } def /ep { showpage gr gr } def This doesn't strike me as necessary, so (in case it might have something to do with it) I removed one of them in each case: /bp { gs } def % begin .ps.prolog /gs { gsave } def /gr { grestore } def /ep { showpage gr } def to see if it made any difference (it didn't). I hope this helps to advance the investigation! Best wishes, Ted.