[pdftex] Creating hyperlinks in plain pdftex.

John R. Culleton john at wexfordpress.com
Thu Mar 23 21:25:44 CET 2006


On Thursday 23 March 2006 14:56, Jim Diamond wrote:
> On Thu, Mar 23, 2006 at 14:51 (-0500), John R. Culleton wrote:
> > The file example.tex describes a verbose way to create a
> > hyperlink in a pdf file to an url on the web. pdfLaTeX has a simple
> > \html
> > command.
> >
> > Is there a simple way to create the link in plain pdftex?
> > Has anyone built a macro that does this?
> > --
>
> John,
>
> I use the following, which assumes that you have color support.
> Getting color support (or removing it from this def) is left as an
> exercise to the diligent student.
>
> % URL support
> \def\URLcolor#1{\def\URLcolour{#1}}
> \URLcolor{blue}
> % Turn off the special meaning of ~ inside \URL{}.
> \def\URL{\begingroup\catcode`\~=12\catcode`\_=12\relax\URL@}
> \def\URL@ #1{%
>     \ifpdf
> %       \pdfannotlink user{   pdftex pre 0.14 ??
>         \pdfstartlink user{
>             /Subtype /Link
>             % w/o this you get an ugly box around the URL.
>             /Border [ 0 0 0 ]   % radius, radius, line thickness
>             /A <<
>                 /Type /Action
>                 /S /URI
>                 /URI (#1)
>
>         }%
>         {\color{\URLcolour}\tt #1}%
>         \pdfendlink{}%
>     \else
>         % Should we have a special case for tth?
>         {\tt #1}%
>     \fi
>     \endgroup % Reset catcode of ~ and _
> }
>
> Cheers.
>
> 				Jim

I forgot one thing. The actual link and the text in the document
may not be the same thing.  In other words you click on
foo.com but you actually get bar.com. In LaTeX this is indicated
by e.g.,
\href{http://snipurl.com/nv6p}{PRLeads}
so I would need to add a #2 to your macro.

Color support? Are you referring to the pdfcolmlmk package
mentioned in the manual?


-- 
John Culleton
Books with answers to marketing and publishing questions:
http://wexfordpress.com/tex/shortlist.pdf

Book coaches, consultants and packagers:
http://wexfordpress.com/tex/packagers.pdf



More information about the pdftex mailing list