[XeTeX] Anchor names

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


Hello,

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 %%%
\catcode`\{=1
\catcode`\}=2
\pdfpagewidth=100bp
\pdfpageheight=200bp
\shipout\vbox{%
  \kern-1in\relax
  \hbox{%
    \kern-1in\relax
    \vrule width0pt height200bp depth0pt\relax
    % Destination at (30bp,150bp)
    \raise150bp\hbox to 0pt{%
      \kern30bp %
      \special{pdf:dest (änchør) [@thispage /XYZ @xpos @ypos null]}%
      \kern-1bp
      \vrule width2bp height1bp depth1bp\relax
      \hss
    }%
    % Link annotation center at (70bp,50bp),
    % rectangle at [68bp 48bp 72bp 52bp]
    \raise50bp\hbox to 0pt{%
       \kern70bp %
       \kern-2bp
       \special{%
         pdf:ann width 4bp height 2bp depth 2bp<<%
           /Type/Annot%
           /Subtype/Link%
           /Border[0 0 1]%
           /C[0 0 1]% blue border
           /A<<%
             /S/GoTo%
             /D(änchør)%
           >>%
         >>%
       }%
       \vrule width4bp height2bp depth2bp\relax
       \hss
    }%
  }%
}
\end
%%% test.tex %%%

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

  4 0 obj
  <<
  /Type/Annot
  /Subtype/Link
  /Border[0 0 1]
  /C[0 0 1]
  /A<<
  /S/GoTo
  /D<feff00e4006e0063006800f80072>
  >>
  /Rect[68 48 72 52]
  >>
  endobj

and the destination:

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

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

Conclusion:
* 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:
/D<feff00e4006e0063006800f80072>

Only the other way worked:

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

Result:
* 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