# \pdfpageheight does not work in XeTeX?

The XeTeX reference manual says that this engine understands \pdfpageheight and \pdfpagewidth. However, is seems to ignore the requests to change paper size in the middle of the document. Consider this example (from https://www.tug.org/members/TUGboat/tb32-3/tb102veytsman-ebooks.pdf)

\documentclass{article}
\usepackage{everyshi,lipsum}
\pagestyle{empty}
\textheight500cm
\pdfpageheight500cm
\EveryShipout{\pdfpageheight=\pagetotal
\begin{document}

\lipsum[3-5]
\pagebreak

This line has a footnote\footnote{\lipsum[6-8]}.
\lipsum[1]

And this line too\footnote{\lipsum[12]}.
\pagebreak

\end{document}

1. pdflatex produces two pages with different page heights as intended.

2. lualatex also works fine

3. xelatex (XeTeX, Version 3.1415926-2.3-0.9997.5 (TeX Live 2011), xdvipdfmx-0.7.8) produces two pages of the same height (letter), which is not what I wanted.

My questions:

1. Is this a bug in xetex or, possibly, in xdvipdfmx, or maybe I do something wrong?

2. Are there any workarounds - for example, using PostScript \specials instead of \pdfpageheight?

-

What a complicated example ;-).

As default the both lengths have the value 0pt in xetex. If you change only one xetex will ignore it and fall back to the default. So you should also set \pdfpagewidth then it will work:

\documentclass{article}
\showthe\pdfpagewidth
\showthe\pdfpageheight
\begin{document}
\pdfpageheight10cm
\pdfpagewidth5cm
abc
\newpage
\pdfpageheight5cm
\pdfpagewidth15cm
cde
\end{document}

-
Thanks! I would consider this a bug: XeTeX manual says about compatibility with pdftex, and this behavior is not compatible. Still, your solution works great. By the way, the example was not contrived: people asked for this feature for e-book formatting - please see our paper. –  Boris Jan 13 '12 at 16:21