| 1 |
\input ptb-utils |
| 2 |
\_checkloaded{hyperlinks} |
| 3 |
|
| 4 |
\def\linkborder#1{% |
| 5 |
\ifx^#1^% |
| 6 |
/C [\default@border] /Border [0 0 \default@border@wd]% |
| 7 |
\else\ifcsname #1@border\endcsname% |
| 8 |
\_xp\ifx\csname #1@border\endcsname\empty% |
| 9 |
/Border [0 0 0]% |
| 10 |
\else% |
| 11 |
/C [\csname #1@border\endcsname] /Border [0 0 \csname #1@border@wd\endcsname]% |
| 12 |
\fi% |
| 13 |
\fi\fi% |
| 14 |
} |
| 15 |
|
| 16 |
\def\createbordertype#1#2#3{% |
| 17 |
\_xp\def\csname #1@border\endcsname{#2}% |
| 18 |
\_xp\def\csname #1@border@wd\endcsname{#3}% |
| 19 |
} |
| 20 |
|
| 21 |
\def\anchorheight{1.5em} % Raise anchor since it should be at top of line |
| 22 |
\def\_anchor[#1]#2{\vbox to\z@{\kern-\anchorheight\pdfdest name{#1:#2} xyz\relax\vss}} |
| 23 |
\def\anchor{\_ifnextchar[ {\_anchor}{\_anchor[]}} |
| 24 |
|
| 25 |
\def\@anchorbuf{0pt} |
| 26 |
\def\@anchorwbuf{1pt} |
| 27 |
\def\_gotoanchor[#1]#2#3{{% |
| 28 |
\setbox0=\hbox{#3}% |
| 29 |
\quitvmode% |
| 30 |
\pdfstartlink height \dimexpr\ht0 + \@anchorbuf\relax depth \dimexpr\dp0 + \@anchorbuf\relax |
| 31 |
attr {\linkborder{#1}} goto name{#1:#2}\relax{\kern\@anchorwbuf\relax#3\kern\@anchorwbuf\relax}\pdfendlink% |
| 32 |
}} |
| 33 |
|
| 34 |
\def\gotoanchor{\_ifnextchar[ {\_gotoanchor}{\_gotoanchor[]}} |
| 35 |
|
| 36 |
\def\_url#1#2{% |
| 37 |
\pdfstartlink user{ |
| 38 |
/Subtype /Link |
| 39 |
\linkborder{url} |
| 40 |
/A << |
| 41 |
/Type /Action |
| 42 |
/S /URI |
| 43 |
/URI (#1) |
| 44 |
>> |
| 45 |
}% |
| 46 |
#2% |
| 47 |
\pdfendlink{}% |
| 48 |
\egroup% |
| 49 |
} |
| 50 |
|
| 51 |
\def\url{% |
| 52 |
\bgroup% |
| 53 |
\catcode`~=12 \catcode`_=12 \catcode`\%=12 % |
| 54 |
\_url% |
| 55 |
} |
| 56 |
|
| 57 |
\createbordertype{default}{1 0 0}{0.6} |
| 58 |
\createbordertype{url}{1 0 0}{0.6} |
| 59 |
|