[pdftex] Link annotations in included pdf documents

Lander lander at we.lc.ehu.es
Wed Feb 28 03:27:08 CET 2007

Dear List,

I'm afraid I didn't explain myself clear enough in my
previous message.  What I was trying to do is to make a
toc so that you can navigate to individual pages.

Thanh has kindly provided me with a couple of macros he had
used in the past to do what I wanted to.  Here you are (note
the use of <+place-holders+>):

====================================================================
%%% In this approach we start at the upper left corner of the "text
%%% area".  We need to move down to the desire coordinates and place
%%% the annotation there.  (The calc package may help simplify the
%%% calculational notation; not used here though.)

\newdimen\dimenA
\def\nullrule{\hrule height 0pt\relax}

\vbox to 0pt{
\nullrule
\dimenA=\paperheight

% Compensate vertical margin: one inch + \voffset + \topmargin

% y coordinate of the lower left corner of the link box; you can
% get this one from gv or gsview.

\vskip\dimenA
\nullrule
\hbox to 0pt{%
% x coordinate of the lower left corner of the link box; you
% can get this one from gv or gsview.
\hskip#1bp

% Compensate horizontal margin: one inch + \hoffset
% \oddsidemargin (or \evensidemargin + \marginparwidth
% \marginparsep)
\hskip -<+hmargin+>

% The annotation itself, with <rule spec> (dimensions of the
% box where the link is active)
\pdfannot width #3 height #4 depth 0pt {%
/Subtype /Link /C [1 0 0] /Dest (#5)}%
\hss}%
\vss
}
\nullrule
}

% More \putlink lines, if you wish
}

%% Contents page
\includepdf[%
page=<+contents_page+>, <+more_options+>,
]{<+book+>}
====================================================================

I don't feel very confortable with TeX primitives, and I
don't want to keep track of the vertical and horizontal
margin compensations.  I was working on a similar solution
to Thanh's, and thanks to him I've come up with another one,
which makes use of the eso-pic package

====================================================================
%%% In this approach, we start at the lower left corner of the
%%% "page".  We just need to give the coordinates of the point where
%%% we want to place the link box.  No extra calculations needed.

\bgroup
\setlength{\unitlength}{1bp}
\put(#1,#2){%
\pdfannot width #3 height #4 depth 0pt
{/Subtype /Link /C [1 0 0] /Dest (#5)}%
}%
\egroup
}

% More \putlink lines, if you wish
}
====================================================================

You can see a working example at