I would do it another way around: (This might actually solve some other issues of you)
Place the whole thing in a savebox in the preamble. (You have to manually enable the normal font use \normalfont
for this AFAIK.) Then you can measure the dimensions of the box and set the page dimensions accordantly. This will give you a PDF or PS which already has to correct size. For larger content I recommend to use a minipage
wrapper as usual.
The \pagecolor
command still works here. I would have thought you manually need to place a colored rectangle (\rule
) with the same size behind the content.
The following works for me using pdflatex
(PDF), latex
->dvips
1 (PS), latex
->dvips
1->ps2pdf
(PDF), xelatex
and lualatex
and produces a correctly sized file.
1 without any options, no -E
required
\documentclass{article}
\usepackage[cmyk]{xcolor}
\pagecolor{cyan}
\pagestyle{empty}
\parindent=0bp
\begin{lrbox}{0}%
\normalfont
\fbox{$\displaystyle E=mc^2 $}%
\end{lrbox}
\sbox0{\raise\dp0\box0}% raise box so it is all height, no depth
%\sbox0{\rlap{\textcolor{cyan}{\rule{\wd0}{\ht0}}}\box0}% \pagecolor surprisingly works so this is not needed
\usepackage[noheadfoot,nomarginpar,margin=0pt,paperwidth=\wd0,paperheight=\ht0]{geometry}
\begin{document}
\box0
\end{document}
The error messages show, that the format generation for plain pdfTeX failed.
Try
fmtutil --byfmt pdftex
If it succeeds, then you can try pdfcrop
again. Otherwise, try updating the TeX distribution, perhaps the error is already fixed.
pdfcrop
can also be used without format:
$ pdfcrop --ini FOAGaug1612public.pdf test.pdf
The file FOAGaug1612public.pdf
contains pages without contents that cause some warnings and the xref
table is not correct for some entries. And the file was generated by LaTeX with lots of overfull \hboxes
. Apart from this you should get a cropped test.pdf
.
Best Answer
Here is my version of an improved
pdfcrop
.Default operation is to remove white margins from the pdf input, optionally leaving a user defined extra-margin (option
-m ...
).Alternative operation is to trim the page edges by user defined amounts (option
-t ...
).pdfcrop.sh
usesgs
(Ghostscript) for page-wise determination of the tightly enclosing bounding box,pdftk
for uncompressing/compressing the PDF files and getting the order of pages (which doesn't need to be linear), andperl
for replacing original page dimensions by the tight bounding boxes found.Unlike original
pdfcrop
the bash script below preserves the original interactive parts of the PDF (links, annotations etc.). The output file size is about the same as before.Update: Option
-two
added for two-sided page layoutUsage examples:
Content of
pdfcrop.sh
: