[XeTeX] Shrink/expand page-height to fit

Clinton Gormley clint at traveljury.com
Wed Jan 6 19:16:04 CET 2010


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.

I've tried the 'preview', 'geometry' and 'pgfpages' packages, but
without much success.  I am considering trying something like:

 - set the page height to the absolute max
 - generate the content
 - redefine \shipout to:
   - store the content "somewhere"
   - measure the height of the content
   - render a second page of the correct size, with the stored
     content
   - discard the first page

Is this the right way to approach this issue?  As a beginner, it's a bit
overwhelming figuring out the best approach to take, and TEX is somewhat
difficult for the uninitiated to read (and I'm a Perl programmer!)

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.

Currently, I'm generating the PDF with xelatex, using pdfcrop to trim
the excess height, then creating a new PDF with the border, and using
the original PDF as an included image.  

This seems wasteful, and I'm sure can be done more efficiently in a
single pass.

Pointers gratefully accepted.

many thanks

Clint



More information about the XeTeX mailing list