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}
I found that the --verbose
flag will output the bounding box used at each step. Since this was a "growing" animation, the last page is the largest.
So to get them all the same size, I ran pdfcrop with --verbose and extracted this output:
%%HiResBoundingBox: 48.000022 299.872046 624.124950 420.127932
and then fed that to a second run of pdfcrop, specifying the bounding box:
pdfcrop --bbox "48.000022 299.872046 624.124950 420.127932" ~/animation.pdf
Best Answer
Yes, but you should use a two-step process:
Extract the page of interest.
This can be done using The PDF Toolkit:
You can also extract it using the following minimal TeX document
Use
pdfcrop
:If the main intent is to include only pageĀ 3 of some larger, multi-page document, then you can include it via
pdfpages
or via
graphicx
Both of the above options allow you to trim the inclusion, if needed.