On Saturday, 23 November 2019 14:02:26 GMT Ralph Corderoy wrote:
> The mom macros have a method of moving the table of contents with -Tpdf
> that depends on gropdf(1)'s .pdfpagename and .pdfswitchtopage.  (Deri,
> I don't think they're documented?)  mom uses them with the page name
> MOM:TOC.  Perhaps mm, or an mm user, could also benefit from them for
> .TC.  Hard to say without more investigation.

The example I sent with my previous email had all the initial full stops of 
the switch.trf file removed by some process in the mail delivery, so I attach 
it again, this time as base64.

Cheers 

Deri
\#
\# PDFLINK
\# --------
\# *Arguments:
\#    $1 = named link
\#    [PREFIX text] : text to prefix link
\#    [SUFFIX text] : text after link
\#    text
\#
\# *Notes
\#    Text is output as a hotspot link to named destination.
\#    If text has final '*' it is replaced with the text associated with the 
link
\#
.de PDFLINK END
.    ds PDF_NM \\$1
.    shift
.    ie '\\$1'PREFIX' \{\
.       ds PDF_PRE -P "\&\\$2"
.       shift 2
.    \}
.    el .ds PDF_PRE
.    ie '\\$1'SUFFIX' \{\
.       ds PDF_POST -A "\\$2"
.       shift 2
.    \}
.    el .ds PDF_POST
.    ds PDF_AST_Q
.    ds PDF_TXT \&\\$1
.    ds PDF_AST \\*[PDF_TXT]
.    substring PDF_AST -1 -1
.    if '\\*[PDF_AST]'+' \{\
.       ds PDF_AST *
.       ds PDF_AST_Q ""
.    \}
.    if '\\*[PDF_AST]'*' \{\
.        chop PDF_TXT
.        ie '\\*[.T]'pdf' \{\
.           ie d pdf:look(\\*[PDF_NM]) \
.               as PDF_TXT 
\&\\*[PDF_AST_Q]\\*[pdf:look(\\*[PDF_NM])]\\*[PDF_AST_Q]
.           el \{\
.               as PDF_TXT Unknown
.               if !rPDF_UNKNOWN .tm \
\\n[.F]:\\n[.c]: forward reference detected (please run using 'pdfmom')
.               nr PDF_UNKNOWN 1
.           \}
.        \}
.        el \{\
.            ie d pdf:href(\\*[PDF_NM]).info \
.               as PDF_TXT 
\&\\*[PDF_AST_Q]\\*[pdf:href(\\*[PDF_NM]).info]\\*[PDF_AST_Q]
.            el .as PDF_TXT Unknown
.       \}
.    \}
.    pdfhref L \\*[PDF_PRE] \\*[PDF_POST] -D \\*[PDF_NM] -- \\*[PDF_TXT]
.    rm PDF_NM
.    rm PDF_PRE
.    rm PDF_POST
.    rm PDF_TXT
.    rm PDF_AST
.    rm PDF_AST_Q
.END
\#
.de PDFTARGET END
.    ds ARG_1 \\$1
.    shift
.    fl
.    ie '\\$*'' .pdfhref M -N \\*[ARG_1] -- \\$*
.    el .pdfhref M -N \\*[ARG_1] -E -- \\$*
.    if '\\*[.T]'ps' .if !dpdf:href.map .tm gropdf-info:href \\*[ARG_1] \\$*
.END
\#
.de BP END
.    bp \\$*
.    sp |1i
.END
.
.sp 1i
Title
.pdfpagename TITLE
.BP 1
.PDFTARGET One One \n%
.BP
.PDFTARGET Two Two \n%
.BP
.PDFTARGET Three Three \n%
.pdfswitchtopage after TITLE
.BP
TOC
.nf
.PDFLINK One *
.PDFLINK Two *
.PDFLINK Three *

Reply via email to