[XeTeX] [tex-live] hyperref 6.79n breaks xetex's (xdvipdfmx) ability to set proper page dimensions (and overrides page dimensions on pdftex)

Jin-Hwan Cho jinhwan.cho at gmail.com
Mon Dec 14 11:52:06 CET 2009


On Dec 14, 2009, at 7:02 PM, Heiko Oberdiek wrote:

> On Mon, Dec 14, 2009 at 04:28:33AM +0300, Vladimir Volovich wrote:
> 
>> [first is the xetex-related part of bug report, then follows the
>> pdftex-related part]
>> 
>> when using hyperref with unicode option, I'm not able to set the proper
>> page dimensions.
>> 
>> Here is a minimal working example which demonstrates the problem:
>> 
>> \documentclass{article}
>> \usepackage[unicode,pdftitle={test}]{hyperref}
>> \pdfpagewidth=300bp
>> \pdfpageheight=300bp
>> \begin{document}
> 
> \paperwidth and \paperheight are in size *letter* (default of
> class article); hyperref looks at these registers using \AtBeginDocument.

This comment gives the KEY answer to this problem.

Suppose we have a TeX file "test.tex" containing Volovich's sample.
Run "xelatex --no-pdf test" to get "test.xdv", and then dviasm shows me the
first five DVI commands of "test.xdv" as follows:

[page 1 0 0 0 0 0 0 0 0 0]
xxx: 'pdf:pagesize width 301.125pt height 301.125pt'
push:
  xxx: 'pdf:docinfo<</Title(\\376\\377\\000t\\000e\\000s\\000t)/Subject()/Creator(LaTeX with hyperref package)/Author()/Producer(XeTeX 0.9995)/Keywords()>>'
  xxx: 'papersize=614.295pt,794.96999pt'
pop:

As I know, XeTeX emulates pdfTeX's \pdfpagewidth and \pdfpageheight registers
so that the first special command "pdf:pagesize ..." was given by XeTeX itself.

As Heiko explained, hyperref inserts the third special command "papersize=...", and
it overlaps the first special command.

Then how to avoid this problem? The simplest solution is to give one more option
to hyperref package as follows:

\usepackage[unicode,pdftitle={test},setpagesize=false]{hyperref}

Best regards, ChoF.

> \documenclass{article}
> \usepackage[...]{hyperref}
> \setlength{\paperwidth}{300bp}
> \setlength{\paperheight}{300bp}
> \begin{document}
> ...
> \end{document}
> 
> The setting of the paper/media size is independent from option `unicode'.
> 
>> when running "xelatex test.tex", i see the following few last lines on
>> terminal:
>> 
>> [1] (./test.aux)
>> ** WARNING ** Failed to convert input string to UTF16...
> 
>> (the WARNING is actually produced by xdvipdfmx, rather than by xetex itself;
> 
> hyperref uses the same specials as for dvipdfm. The only exception is
> the current version of today. It will use pdfTeX's \pdfpagewidth
> and \pdfpageheight for setting the paper/media size.
> 
> Unhappily there isn't any documentation/specification, what is
> different to dvipdfm. At least hyperref should now generate
> correct PDF strings in UTF-16, for outlines, info entries,
> page labels.
> 
>> the \pdfpagewidth and \pdfpageheight primitives are working in xetex,
>> and i used them rather than the geometry package to make an example
>> simpler to debug.)
>> 
>> when i then run "pdfinfo test.pdf", i get:
>> 
>> $ pdfinfo test.pdf 
>> Page size:      612 x 792 pts (letter)
> 
>> Notice that the page size is wrong.
> 
> No, LaTeX thinks different: \showthe\paperwidth and
> \showthe\paperheight give:
>  614.295pt and 794.96999pt
> that is
>  612bp and 792bp (letter format)
> 
>> If i comment out the line which calls the hyperref package, i get no
>> warning, and the pdfinfo shows the expected page size:
>> 
>> $ pdfinfo test.pdf 
>> Page size:      300 x 300 pts
> 
> But LaTeX allows you to fill a complete letter page.
> 
> Correct is setting the paper size in LaTeX *and*
> setting it for the output media or let a package do the last or
> both parts (geometry, hyperref, ...).
> 
> It's a deficiency of LaTeX that the second part is necessary.
> 
>> is this a bug in hyperref (e.g. it produces some malformed UTF16 string
>> which xdvipdfmx can't handle) or in xdvipdfmx?
> 
> * Media size: the bug is in the incomplete user input (forgetting
>  about \paperwidth, \paperheight.
> 
> * UTF16-warning: AFAIK the hyperref code is correct in producing
>  correct PDF strings in UTF16. I do not have information about
>  xdvipdfmx, whether it uses different specials, expects the data
>  in different form, ...
> 
>> Now, the pdftex-related part of the bug report.
>> 
>> If I uncomment the "\showthe\pdfpagewidth" line, i see that the
>> \pdfpagewidth gets reset after the \begin{document}:
>> 
>> pdflatex shows:
>>> 614.295pt.
>> 
>> if i comment out hyperref usage, i get the expected result:
>>> 301.125pt.
> 
> Already explained, see above.
> 
>> in xetex, I'm always getting the 301.125pt result, regardless of
>> presence of hyperref; but nevertheless because of the WARNING by
>> xdvipdfmx, the page dimensions appear wrong when using hyperref.
> 
> No, I think, the warning is unrelated to the page size.
> It is rather caused by other strings, like entries in the
> information dictionary, ...
> 
> Yours sincerely
>  Heiko <oberdiek at uni-freiburg.de>



More information about the XeTeX mailing list