[OS X TeX] Re: XeTeX and pdfpages: no dice?

Jonathan Kew jonathan_kew at sil.org
Tue Jul 24 06:14:35 EDT 2007


Hi Andreas,

Looking back at old email, I don't think I replied to this at the  
time.... sorry!

On 19 Apr 2007, at 6:10 pm, Andreas Matthias wrote:
> Jonathan Kew wrote:
>
>> I'd guess there are some kinds of PDF file that the clever macro
>> code  for counting pages can't quite understand.
>
> I found a bug concerning line breaks and have fixed that. Nevertheless
> there is still one problem. The macro uses the following loop:
>
>     \@whilenum\count@<256 \do{%
>       \catcode\count@=9
>       \advance\count@ by 1
>     }%
>
> And it seems that I am missing a lot of characters concerning XeTeX.
> How many character codes does XeTeX have? I have found
>
>    @d biggest_char=65535 {the largest allowed character number;
>
> but such a big number causes a TeX capacity exceeded error.
>
> What is the correct number in the above loop to ignore all
> characters?

The natural answer to this specific question would actually be  
"10FFFF, the largest possible Unicode value -- but obviously that's  
not a useful solution, if even 64K gives a "capacity exceeded" error.  
(Is it the "save stack" that overflows? I suppose making the setting  
\global might avoid that. But you *really* don't want)

The real solution, though, is to use a different approach altogether,  
and avoid attempting to parse the PDF with TeX macros at all. XeTeX  
0.997 (to be released shortly -- code is there, I just need to do  
some packaging) will include a new primitive \XeTeXpdfpagecount to  
determine the number of pages in a PDF document. This takes a  
filename (just like \XeTeXpdffile), but instead of including the  
graphic, it just returns the number of pages. So you can say things  
like:

    \count255 = \XeTeXpdfpagecount "mydoc.pdf"

(Note: be sure there's a space or \relax or similar after the  
filename, otherwise following text will be taken as part of the name  
even if it's outside the quotes. If embedding this in a macro, I'd  
suggest including an explicit \space for safety.)

For the pdfpages driver, you might like to test for the availability  
of \XeTeXpdfpagecount, and fall back to the pdf-parsing macro code if  
it isn't available; or else just give an error saying that a newer  
release of xetex is needed.

JK


------------------------- Helpful Info -------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/
List Reminders & Etiquette: http://www.esm.psu.edu/mac-tex/list/





More information about the MacOSX-TeX mailing list