If you have been logged in at mapleprimes in the last week you will know that I'm currently going through an obsession with plots. Indeed, some deadline is looming and it is all very stressful. For reference, and hopefully it may be of use to someone somewhere someday, I produce 2D plots with Standard GUI in the postscript format using plotsetup(ps). I'm on Windows for this. (3D plots aren't so hot with Standard GUI)

I use LaTeX for my documents. I used to insert postscript files directly using latex->dvips->ps2pdf, but now I prefer to use pdflatex (I think this is a trend for many users). So I convert my ps images into pdf. And here 2 problems typically arise, 1) there's lots of white space around the actual plot, 2) wide plots may be exported in landscape mode and need to be rotated. Both of these tasks can be handled within latex, by using clip and rotate options on includegraphics, but I prefer to proceed differently. I crop and rotate the images before insertion into latex, this way I don't have to worry about specifying dimensions for clipping.

To convert from ps to pdf, I use ps2pdf in a MiKTeX (2.9) installation.

To crop, I use ghostcript together with calibre2, both freeware (same thing can be done with linux, as far as I know).

To rotate, I use pdftk, also freeware.

Google will take you to the relevant download links.

I have created batch files to automate this on windows. A batch file is a text file with the extension ".bat". When you "execute" a batch file it's like running a command-line instruction. Here are my batch files. To use them, you need to adapt the paths:

 

To create pdf from ps

setlocal
cd /d %~dp0
for %%I in (*.ps) do ps2pdf %%I

 

To crop:

for %%I in (*.pdf) do (
"C:\Program Files (x86)\Ghostscript\gs9.00\bin\gswin32c.exe" -dSAFER -dNOPAUSE -dBATCH -sDEVICE#bbox "%%I" 2> bounding
"C:\Program Files (x86)\Calibre2\pdfmanipulate.exe" crop -o "%%~nICropped.pdf" -b bounding "%%I"
)

 

To rotate 90 degrees:

for %%I in (*.pdf) do "pdftk.exe" "%%I" cat 1-endE output "%%~nIRotated90.pdf"

 

To rotate 180 degrees:


for %%I in (*.pdf) do "pdftk.exe" "%%I" cat 1-endS output "%%~nIRotated180.pdf"

 

EDIT: added the batch file for ps2pdf, which I had forgotten to insert.


Please Wait...