[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: graph export to pdf
For as much as I looked I could not find a way to specify a custom page
size when converting a ps or eps to pdf with Ghostscript's pdfwrite.
Even if you instruct Stata to export to ps by specifying a custom size,
the Ghostscript device will place your graph within a default pagesize.
The default pagesize is usually US letter size, but it can be changed to
any standard ISO size such as legal a4 etc. Problem is if none of these
standard sizes match you graph size, there does not seem to be an easy
way with Ghostscript. I've looked for an option in Acrobat's Distiller
too, but haven't found it (Distiller and Ghostscript's pdfwrite share a
lot of the parameters). Like you, I too had to manually change the
bounding box dimensions in Acrobat. This is fine for one or two graphs,
but what if you need to convert 20 or 80 graphs?
Fortunately, I did come across a solution. It's not elegant, but it
works, somewhat. It involves using epstopdf.exe which you can find
Epstopdf requires Ghostcript installed and will be looking for
gswin32c.exe (I believe that Mac users should have Ghostscript and most
of its devices installed). I did have some problems trying to tell the
location of gswin32c.exe under Win (probably because of the spaces), so
I saved epstopdf.exe in the same location as gswin32c.exe.
Unfortunately, it seems that epstopdf cuts the main title. I am hoping
someone in the Stata community can provide some suggestions...
So here is some example code. I am working in Win environment, so you
would need to make the appropriate changes:
* Example *
twoway scatter mpg weight, xsize(10) ysize(5) title("Test of epstopdf")
graph set eps logo off
graph export "C:\gs\gs8.53\bin\example.eps", cmyk(on)
! cd /D C:\gs\gs8.53\bin
! epstopdf.exe --gsopt=-dPDFSETTINGS=/prepress
--gsopt=-dAutoRotatePages=/All --outfile=H:\example.pdf example.eps
capture erase C:\gs\gs8.53\bin\example.eps
Clinical Trials Unit
Tom Baker Cancer Centre
1331 - 29th Street N.W.
Calgary, AB, T2N 4N4
Tel. (403) 521-3370
This e-mail and any attachments may contain confidential and
privileged information. If you are not the intended recipient,
please notify the sender immediately by return e-mail, delete this
e-mail and destroy any copies. Any dissemination or use of this
information by a person other than the intended recipient is
unauthorized and may be illegal.
* For searches and help try: