In a Linux system, we have a set of free tools that can help us produce an appropriate bounding box and convert PDF format to EPS format.
- pdftk from PDF Labs
- GNU gv
- pdfcrop by Heiko Oberdiek
- pdftops by the Poppler developers
- pdf2ps in Ghostscript
- ps2eps by Roland Bless
sudo apt-get install \ pdftk gv texlive-extra-utils \ poppler-utils ghostscript ps2eps
Assume that PDF file foo.pdf contains an interesting figure in page 2 and we want to extract the figure for inserting it in a LaTex document. We would follow the steps below,
Extract the page from the PDF file that contains the figure we would like to extract
pdftk foo.pdf cat 2 output page2.pdf
where foo.pdf is the input PDF file, page2.pdf is the output PDF file, and 2 is the page number in the input PDF file.
Measure roughtly the position and the dimension of a box that contains the figure using
We read the coordinates of the bottom left corner and the top right corner of the box from
gv. Assume the readings are
(321, 161), respectivley.
Crop the PDF file based on the box obtained in the above.
pdfcrop --bbox "61 82 321 161" page2.pdf
The output of this step is
Crop the resulting PDF file from previous step to reduce white space around the figure.
The result is
Convert the PDF file to an EPS file.
pdftops -eps page2-crop-crop.pdf page2.eps
We could complete the last step using
pdf2psin Ghostscript instead of
pdftopsby the Poppler developers as the following two steps approach.
pdf2ps page2-crop-crop.pdf ps2eps page2-crop-crop.ps page2.eps
However, we do not recommend
pdf2ps, convinced by the argument made by Stefaan Lippens.
As indicated by Stefaan Lippens,
pdf2psconverts fonts in PDF files to bitmap fonts in resulting PS files. Some may consider this an advantage because the fonts used in the figure will always be "present" in the PDF files generated form the corresponding LaTeX files. However, as we discussed previously, it is not difficult to embedd all fonts in a PDF file.