[XeTeX] Shrink/expand page-height to fit

Ulrike Fischer news3 at nililand.de
Thu Jan 7 10:58:33 CET 2010


Am Wed, 06 Jan 2010 19:16:04 +0100 schrieb Clinton Gormley:

> Hi all
> 
> I'm a beginner in *TEX, and I'm trying to do something which I hope is
> possible, but am not sure :)
> 
> I need to generate PDFs, where each PDF contains a short advert which
> will appear in a newspaper.
> 
> The column width is known beforehand, but the height isn't (other than
> an absolute maximum for the physical page height).
> 
> So I'd like to be able to crop the page height to fit the contents,
> after the contents have been rendered.

> Additionally, I'd like to draw a border around the content, with rounded
> edges - obviously I need to know the content height before drawing this
> box.

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{backgrounds}
\usepackage[%
 paperwidth=8cm,
 vmargin=10pt
 ]{geometry}
 
\begin{document}
\newbox\mycontent
\savebox\mycontent{%
    \begin{tikzpicture}
     [background rectangle/.style=
        {double,ultra thick,draw=red,top color=blue,
         rounded corners},
      show background rectangle]
\node[use as bounding box]{\parbox{\linewidth}{\lipsum[1]abc}};
\end{tikzpicture}}

\pdfpageheight=\dimexpr\dp\mycontent+\ht\mycontent+20pt

\noindent\makebox[\linewidth]{\usebox\mycontent}
\end{document}

-- 
Ulrike Fischer 



More information about the XeTeX mailing list