[XeTeX] Anchor names

Heiko Oberdiek heiko.oberdiek at googlemail.com
Thu Nov 3 15:58:27 CET 2011


to get more to the point, I start a new thread.
As we have learned, the PDF specification uses byte strings
for anchor names. And there is a wish to use "normal" characters
in anchor names. Let's make an example:

xetex --ini --output-driver='xdvipdfmx -V4' test

%%% test.tex %%%
    \vrule width0pt height200bp depth0pt\relax
    % Destination at (30bp,150bp)
    \raise150bp\hbox to 0pt{%
      \kern30bp %
      \special{pdf:dest (änchør) [@thispage /XYZ @xpos @ypos null]}%
      \vrule width2bp height1bp depth1bp\relax
    % Link annotation center at (70bp,50bp),
    % rectangle at [68bp 48bp 72bp 52bp]
    \raise50bp\hbox to 0pt{%
       \kern70bp %
         pdf:ann width 4bp height 2bp depth 2bp<<%
           /Border[0 0 1]%
           /C[0 0 1]% blue border
       \vrule width4bp height2bp depth2bp\relax
%%% test.tex %%%

The link is not working. Looking into the PDF file we can find
the link annotation:

  4 0 obj
  /Border[0 0 1]
  /C[0 0 1]
  /Rect[68 48 72 52]

and the destination:

7 0 obj
[3 0 R/XYZ 30 150 null]
8 0 obj
/Names[<c3a46e6368c3b872>7 0 R]

The positions of both the link annotation and the destination are perfect.
The name for "änchør" is given both times as hexadecimal string.
That's ok, too. But the names are different:

Destination: <c3a46e6368c3b872> ==> UTF-8
Link annot.: <feff00e4006e0063006800f80072> ==> UTF-16BE with BOM

* The encoding mess with 8-bit characters remain even with XeTeX.

Then I tried to be clever and a workaround by using
/D<c3a46e6368c3b872> for the link name in the source.
But it got converted and the PDF file still contains:

Only the other way worked:

  \special{pdf:dest <feff00e4006e0063006800f80072> ...}
  \special{pdf:ann ... /D(änchør) ...}

* Even for nice short names the size is doubled and increased
  by two bytes.
* Assymetrical behaviour of \special commands.
* No documentation.
* Unfair, arbitrary byte strings can't be written.

Yours sincerely
  Heiko Oberdiek

More information about the XeTeX mailing list