I have myfile.ps
with a vector image included.
But when I run
ps2pdf myfile.ps
it seems that the output page size is A4: the vecto
I am not allowed to comment, but I must warn everyone that all the current answers are vulnerable to malicious postscript files.
Using gs
like this is VERY dangerous. ps2pdf
internally uses the -dSAFER
option which would, for example, prevent an untrusted postscript file from encrypting your files and rendering a pdf that demands a ransom payment from you for the decryption key! ALWAYS use -dSAFER
!
While -o outputFile.pdf
is nice, it is also undocumented (via man page or gs -h
) as of version 9.23.
The below command works without worrying about the top being cut off like with the other solutions:
gs -sOutputFile=file.pdf -dNOPAUSE -dBATCH -sPAPERSIZE=a4 -sDEVICE=pdfwrite -dSAFER file.ps
-sPAPERSIZE=a4
is how the a4 paper size is specified.
to get the page size you can look for a line like the following:
%%PageBoundingBox:·12·12·583·830
and then use
gs -sOutputFile=file.pdf -dNOPAUSE -dBATCH -g583x830 -r72 -sDEVICE=pdfwrite -dSAFER file.ps
and it works perfectly.