groff: update vendor branch to v1.20.1
[dragonfly.git] / contrib / groff / contrib / pdfmark / pdfmark.ms
CommitLineData
465b256c 1.\" vim: ft=groff
4d3e9548
JL
2.ig
3pdfmark.ms
4
5File position: <groff-source>/contrib/pdfmark/pdfmark.ms
6
7This file is part of groff, the GNU roff type-setting system.
8
9Copyright (C) 2004, 2005, 2006, 2009 Free Software Foundation, Inc.
10written by Keith Marshall <keith.d.marshall@ntlworld.com>
11
12Permission is granted to copy, distribute and/or modify this document
13under the terms of the GNU Free Documentation License, Version 1.3 or
14any later version published by the Free Software Foundation; with no
15Front-Cover Texts, no Back-Cover Texts, and the following Invariant
16Sections:--
17
18 a) This "Legal Matters" section, extending from the start of
19 the document, to the end of the enclosing ".ig" section.
20
21 b) The two lines below starting with `.AU' and `.AI'.
22
23A copy of the Free Documentation License is included as a file called
24FDL in the main directory of the groff source package.
25..
26.
465b256c
JR
27.CS
28Portable Document Format
29Publishing with GNU Troff
30.AU Keith Marshall
31.AI <keith.d.marshall@ntlworld.com>
32.CE
33.\"
34.\" Specify the Internet address for the groff web site.
35.\" Currently, there are two available addresses; a copy is maintained at ...
36.\"
37.ds GROFF-WEBSITE http://www.gnu.org/software/groff
38.\"
39.\" ... but the official home site is at ...
40.\"
41.ds GROFF-WEBSITE http://groff.ffii.org
42.\"
43.\" Set the PDF default document view attribute, to ensure that the document
44.\" outline is visible, each time the document is opened in Acrobat Reader.
45.\"
46.pdfview /PageMode /UseOutlines
47.\"
48.\" Initialise the outline view to show only three heading levels,
49.\" with additional subordinate level headings folded.
50.\"
51.nr PDFOUTLINE.FOLDLEVEL 3
52.\"
53.\" Add document identification meta-data
54.\"
55.pdfinfo /Title Portable Document Format Publishing with GNU Troff
56.pdfinfo /Author Keith Marshall
57.pdfinfo /Subject Tips and Techniques for Exploiting PDF Features with GNU Troff
58.pdfinfo /Keywords groff troff PDF pdfmark
59.\"
60.\" Set the default cross reference format to indicate section numbers,
61.\" rather than page numbers, when we insert a reference pointer.
62.\"
63.ds PDFHREF.INFO section \\*[SN-NO-DOT] \\$*
64.\"
65.\" Define a macro, to print reference links WITHOUT the usual "see" prefix.
66.\"
67.de XR-NO-PREFIX
68.rn PDFHREF.PREFIX xx
69.ds PDFHREF.PREFIX
70.XR \\$@
71.rn xx PDFHREF.PREFIX
72..
73.\"
74.\" Define a string,
75.\" to insert a Registered Trade Mark symbol as a superscript.
76.\"
77.ds rg \*{\(rg\*}
78.\"
79.\" Establish the page layout.
80.\"
81.nr PO 2.5c
82.nr LL 17.0c
83.nr LT 17.0c
84.nr HY 0
85.nr FF 3
86.nr DI 5n
87.\"
88.\" Generate headers in larger point sizes, for NH levels < 4,
89.\" with point size increasing by 1.5p, for each lesser NH level.
90.\"
91.nr GROWPS 4
92.nr PSINCR 1.5p
93.\"
94.de EM
95.\".I "\s'+0.3'\\$1\s0" "\\$2" "\\$3"
96.I \\$@
97..
98.de CWB
99\\$5\fC\\$3\fP\f(CB\\$1\fP\fC\\$2\fP\\$4
100..
101.de CWI
102\\$5\fC\\$3\fP\f(CI\\$1\fP\fC\\$2\fP\\$4
103..
104.de CWBI
105\\$5\fC\\$3\fP\f[CBI]\\$1\fP\fC\\$2\fP\\$4
106..
107.ds = \f(CB\\$1\f(CR\\$4\f[CBI]\\$2\f(CR\\$3
108.\"
109.NH 1
110.\" When we use numbered section headings, we might like to automatically
111.\" insert a table of contents entry, using the text of the heading itself.
112.\" The "ms" macros don't provide any standard mechanism for doing this,
113.\" but "spdf.tmac" adds the "XN" macro, which will do it for us.
114.\"
115.\" Here's a simple example of how we might use it. In this case, the word
116.\" "Introduction" will appear both in the body of the document, as the text
117.\" of the heading, and it will be added to the table of contents, which is
118.\" subsequently "printed" using the "TC" macro; in both locations, it will
119.\" be prefixed by the section number.
120.\"
121.\" As an additional side effect, any use of "XN" will cause the table of
122.\" contents entry to be automatically reproduced, with the exception of its
123.\" page number reference, as a PDF document outline entry. Thus, the use
124.\" of "XN" to specify numbered section headings results in the automatic
125.\" creation of a numbered PDF document outline. This automatic creation
126.\" of the outline is completely transparent, and will occur regardless
127.\" of whether the "TC" macro is subsequently invoked, or not.
128.\"
129.XN Introduction
130.\"
131.\" If using an old s.tmac, without the SN-NO-DOT extension,
132.\" make sure we get SOMETHING in section number references.
133.\"
134.if !dSN-NO-DOT .als SN-NO-DOT SN
135.LP
136It might appear that it is a fairly simple matter to
137produce documents in Adobe\*(rg\~\(lqPortable\~Document\~Format\(rq,
138commonly known as PDF, using
139.CW groff ) GNU\~Troff\~(
140as the document formatter.
141Indeed,
142.CW groff 's
143default output format is the native Adobe\*(rg\~PostScript\*(rg format,
144which PDF producers such as Adobe\*(rg Acrobat\*(rg Distiller\*(rg,
145or GhostScript, expect as their input format.
146Thus, the PDF production process would seem to entail simply
147formatting the document source with
148.CW groff ,
149to produce a PostScript\*(rg version of the document,
150which can subsequently be processed by Acrobat\*(rg Distiller\*(rg
151or GhostScript, to generate the final PDF document.
152.LP
153For many PDF production requirements,
154the production cycle described above may be sufficient.
155However, this is a limited PDF production method,
156in which the resultant PDF document represents no more than
157an on screen image of the printed form of the document, if
158.CW groff 's
159PostScript\*(rg output were printed directly.
160.LP
161The Portable Document Format provides a number of features,
162which significantly enhance the experience of reading a document on screen,
163but which are of little or no value to a document which is merely printed.
164It
165.EM is
166possible to exploit these PDF features, which are described in the Adobe\*(rg
167.\"
168.de pdfmark-manual
169.\" This is an example of a resource reference specified by URI ...
170.\" We may need to refer often to the Adobe pdfmark Reference Manual,
171.\" so we create the internet link definition using a macro, to make
172.\" it reusable.
173.\"
174.\" Note also, that we protect the description of the reference by
175.\" preceding it with "--", to avoid "invalid character in name" type
176.\" error messages from groff (caused by the use of "\~").
177.\"
4d3e9548 178.pdfhref W -D http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/pdfmarkReference.pdf \
465b256c
JR
179 -P \(lq -A \(rq\\$1 -- pdfmark\~Reference\~Manual
180..
181.pdfmark-manual ,
182with some refinement of the simple PDF production method, provided
183appropriate \(lqfeature implementing\(rq instructions can be embedded into
184.CW groff 's
185PostScript\*(rg rendering of the document.
186This, of course, implies that the original document source, which
187.CW groff
188will process to generate the PostScript\*(rg description of the document,
189must include appropriate markup to exploit the desired PDF features.
190It is this preparation of the
191.CW groff
192document source to exploit a number of these features,
193which provides the principal focus of this document.
194.LP
195The markup techniques to be described have been utilised in the production of
196the PDF version of this document itself.
197This has been formatted using
198.CW groff 's
199.CW ms
200macro package;
201thus, usage examples may be found in the document source file,
202.CW \n(.F ,
203to which comments have been added,
204to help identify appropriate markup examples for implementing PDF features,
205such as:\(en
206.QS
207.IP \(bu
208Selecting a default document view, which defines how the document will appear
209when opened in the reader application; for example, when this document is
210opened in Acrobat\*(rg\~Reader, it should display the top of the cover sheet,
211in the document view pane, while a document outline should appear to the left,
212in the \(lqBookmarks\(rq pane.
213.IP \(bu
214Adding document identification \(lqmeta\(hydata\(rq,
215which can be accessed, in Acrobat\*(rg\~Reader,
216by inspecting the \(lqFile\^/\^Document\~Properties\^/\^Summary\(rq.
217.IP \(bu
218Creating a document outline, which will be displayed in the \(lqBookmarks\(rq
219pane of Acrobat\*(rg\~Reader, such that readers may quickly navigate to any
220section of the document, simply by clicking on the associated heading
221in the outline view.
222.IP \(bu
223Embedding active links in the body of the document, such that readers may
224quickly navigate to related material at another location within the same
225document, or in another PDF document, or even to a related Internet resource,
226specified by its URI.
227.IP \(bu
228Adding annotations, in the form of \(lqsticky notes\(rq, at strategic
229points within the PDF document.
230.QE
231.LP
232All of the techniques described have been tested on
233.EM both
234GNU/Linux, and on Microsoft\*(rg Windows\(tm2000 operating platforms, using
235.CW groff
236.CW 1.19.1 ,\c
237.pdfhref L -D footnote1 -- \**
238.FS
239.pdfhref M footnote1
240Later versions should, and some earlier versions may, be equally suitable.
241See
242.pdfhref W \*[GROFF-WEBSITE]
243for information and availability of the latest version.
244.FE
245in association with
246.CW AFPL
247.CW GhostScript
248.CW 8.14 .\c
249.pdfhref L -D footnote2 -- \**
250.FS
251.pdfhref M footnote2
252Again, other versions may be suitable.
253See
254.pdfhref W http://ghostscript.com
255for information and availability.
256.FE
257Other tools employed, which should be readily available on
258.EM any
259.SM
260UNIX\(tm
261.LG
262or GNU/Linux system, are
263.CW sed ,
264.CW awk
265and
266.CW make ,
267together with an appropriate text editor, for creating and marking up the
268.CW groff
269input files.
270These additional utilities are not provided, as standard,
271on the Microsoft\*(rg Windows\(tm platform,
272but several third party implementations are available.
273Some worth considering include the MKS\*(rg\~Toolkit,\**
274.FS
275A commercial offering; see
276.pdfhref W http://mkssoftware.com/products/tk/default.asp
277for information.
278.FE
279Cygwin,\**
280.FS
281A
282.EM free
283but comprehensive
284.SM
285POSIX
286.LG
287emulation environment and
288.SM
289UNIX\(tm
290.LG
291toolkit for 32\(hybit Microsoft\*(rg Windows\(tm platforms; see
292.pdfhref W http://cygwin.com
293for information and download.
294.FE
295or MSYS.\**
296.FS
297Another free, but minimal suite of common
298.SM
299UNIX\(tm
300.LG
301tools for 32\(hybit Microsoft\*(rg Windows\(tm, available for download from
302.pdfhref W -A ; http://www.mingw.org
303it
304.EM does
305include those tools listed above,
306and is the package which was actually used when performing the Windows\(tm2000
307platform tests referred to in the text.
308.FE
309This list is by no means exhaustive, and should in no way be construed as an
310endorsement of any of these packages, nor to imply that other similar packages,
311which may be available, are in any way inferior to them.
312.bp
313.NH 1
314.\" We may wish a section heading to represent a named destination,
315.\" so that we can create a linked reference to it, from some other
316.\" part of the PDF document, (or even from another PDF document).
317.\"
318.\" Here we use the "-N" option of the "XN" macro, to create a named
319.\" PDF link destination, at the location of the heading. Notice that
320.\" we also use the "--" marker to separate the heading text from the
321.\" preceding option specification; it is not strictly necessary in
322.\" this case, but it does help to set off the heading text from the
323.\" option specification.
324.\"
325.XN -N pdf-features -- Exploiting PDF Document Features
326.LP
327To establish a consistent framework for adding PDF features, a
328.CW groff
329macro package, named
330.CW pdfmark.tmac ,
331has been provided.
332Thus, to incorporate PDF features in a document,
333the appropriate macro calls, as described below, may be placed in the
334.CW groff
335document source, which should then be processed with a
336.CW groff
337command of the form
338.QP
339.fam C
340groff -Tps [-m
341.I name "] -m"
342.B pdfmark
343.I options \& [-
344.I "file ..." \& "...] "
345.LP
346It may be noted that the
347.CW pdfmark
348macros have no dependencies on, and no known conflicts with,
349any other
350.CW groff
351macro package; thus, users are free to use any other macro package,
352of their choice, to format their documents, while also using the
353.CW pdfmark
354macros to add PDF features.
355.NH 2
356.XN -N pdfmark-operator -- The \F[C]pdfmark\F[] Operator
357.LP
358All PDF features are implemented by embedding instances of the
359.B \F[C]pdfmark\F[]
360operator, as described in the Adobe\*(rg
361.pdfmark-manual ,
362into
363.CW groff 's
364PostScript\*(rg output stream.
365To facilitate the use of this operator, the
366.CW pdfmark
367macro package defines the primitive
368.CW pdfmark
369macro; it simply emits its argument list,
370as arguments to a
371.CW pdfmark
372operator, in the PostScript\*(rg output stream.
373.LP
374.pdfhref M -N pdfmark-example
375To illustrate the use of the
376.CW pdfmark
377macro, the following is a much simplified example of how a bookmark
378may be added to a PDF document outline
379.QP
380.CW ".pdfmark \e"
381.RS 4
382.nf
383.fam C
384/Count 2 \e
385/Title (An Example of a Bookmark with Two Children) \e
386/View [/FitH \en[PDFPAGE.Y]] \e
387/OUT
388.RE
389.LP
390In general, users should rarely need to use the
391.CW pdfmark
392macro directly.
393In particular, the above example is too simple for general use; it
394.EM will
395create a bookmark, but it does
396.EM not
397address the issues of setting the proper value for the
398.CW /Count
399key, nor of computing the
400.CW PDFPAGE.Y
401value used in the
402.CW /View
403key. The
404.CW pdfmark
405macro package includes a more robust mechanism for creating bookmarks,
406.\"
407.\" Here is an example of how a local reference may be planted,
408.\" using the automatic formatting feature of the "pdfhref" macro.
409.\"
410.\" This is a forward reference to the named destination "add-outline",
411.\" which is defined below, using the "XN" wrapper macro, from the
412.\" "spdf.tmac" macro package. The automatically formatted reference
413.\" will be enclosed in parentheses, as specified by the use of
414.\" "-P" and "-A" options.
415.\"
416.pdfhref L -P ( -A ), -D add-outline
417.\"
418which addresses these issues automatically.
419Nevertheless, the
420.CW pdfmark
421macro may be useful to users wishing to implement more advanced PDF features,
422than those currently supported directly by the
423.CW pdfmark
424macro package.
425.NH 2
426.XN -N docview -- Selecting an Initial Document View
427.LP
428By default,
429when a PDF document is opened,
430the first page will be displayed,
431at the default magnification set for the reader,
432and outline and thumbnail views will be hidden.
433When using a PDF reader,
434such as Acrobat\*(rg\~Reader,
435which supports the
436.CW /DOCVIEW
437class of the
438.CW pdfmark
439operator,
440these default initial view settings may be overridden,
441using the
442.CW pdfview
443macro.
444For example
445.QP
446.CW ".pdfview /PageMode /UseOutlines"
447.LP
448will cause Acrobat\*(rg\~Reader to open the document outline view,
449to the left of the normal page view,
450while
451.QP
452.CW ".pdfview /PageMode /UseThumbs"
453.LP
454will open the thumbnail view instead.
455.LP
456Note that the two
457.CW /PageMode
458examples, above, are mutually exclusive \(em it is not possible to have
459.EM both
460outline and thumbnail views open simultaneously.
461However, it
462.EM is
463permitted to add
464.CW /Page
465and
466.CW /View
467keys, to force the document to open at a page other than the first,
468or to change the magnification at which the document is initially displayed;
469see the
470.pdfmark-manual
471for more information.
472.LP
473It should be noted that the view controlling meta\(hydata, defined by the
474.CW pdfview
475macro, is not written immediately to the PostScript\*(rg output stream,
476but is stored in an internal meta\(hydata \(lqcache\(rq,
477(simply implemented as a
478.CW groff
479diversion).
480This \(lqcached\(lq meta\(hydata must be written out later, by invoking the
481.CW pdfsync
482macro,
483.\"
484.\" Here is another example of how we may introduce a forward reference.
485.\" This time we are using the shorter notation afforded by the "XR" macro
486.\" provided by "spdf.tmac"; this example is equivalent to the native
487.\" "pdfmark.tmac" form
488.\" .pdfhref L -D pdfsync -P ( -A ).
489.\"
490.XR pdfsync ). (
491.\"
492.NH 2
493.XN -N docinfo -- Adding Document Identification Meta-Data
494.LP
495In addition to the
496.CW /DOCVIEW
497class of meta\(hydata described above,
498.XR docview ), (
499we may also wish to include document identification meta\(hydata,
500which belongs to the PDF
501.CW /DOCINFO
502class.
503.LP
504To do this, we use the
505.CW pdfinfo
506macro.
507As an example of how it is used,
508the identification meta\(hydata attached to this document
509was specified using a macro sequence similar to:\(en
510.DS I
511.CW
512\&.pdfinfo /Title PDF Document Publishing with GNU Troff
513\&.pdfinfo /Author Keith Marshall
514\&.pdfinfo /Subject How to Exploit PDF Features with GNU Troff
515\&.pdfinfo /Keywords groff troff PDF pdfmark
516.DE
517Notice that the
518.CW pdfinfo
519macro is repeated, once for each
520.CW /DOCINFO
521record to be placed in the document.
522In each case, the first argument is the name of the applicable
523.CW /DOCINFO
524key, which
525.EM must
526be named with an initial solidus character;
527all additional arguments are collected together,
528to define the value to be associated with the specified key.
529.LP
530As is the case with the
531.CW pdfview
532macro,
533.XR docview ), (
534the
535.CW /DOCINFO
536records specified with the
537.CW pdfinfo
538macro are not immediately written to the PostScript\*(rg output stream;
539they are stored in the same meta\(hydata cache as
540.CW /DOCVIEW
541specifications, until this cache is explicitly flushed,
542by invoking the
543.CW pdfsync
544macro,
545.XR pdfsync ). (
546.NH 2
547.XN -N add-outline -- Creating a Document Outline
548.LP
549A PDF document outline comprises a table of references,
550to \(lqbookmarked\(rq locations within the document.
551When the document is viewed in an \(lqoutline\~aware\(rq PDF document reader,
552such as Adobe\*(rg Acrobat\*(rg Reader,
553this table of \(lqbookmarks\(rq may be displayed in a document outline pane,
554or \(lqBookmarks\(rq pane, to the left of the main document view.
555Individual references in the outline view may then be selected,
556by clicking with the mouse,
557to jump directly to the associated marked location in the document view.
558.LP
559The document outline may be considered as a collection of \(lqhypertext\(rq
560references to \(lqbookmarked\(rq locations within the document.
561The
562.CW pdfmark
563macro package provides a single generalised macro,
564.CW pdfhref ,
565for creating and linking to \(lqhypertext\(rq reference marks.
566This macro will be described more comprehensively in a later section,
567.XR pdfhref ); (
568the description here is restricted to its use for defining document outline entries.
569.NH 3
570.XN -N basic-outline -- A Basic Document Outline
571.LP
572In its most basic form, the document outline comprises a structured list of headings,
573each associated with a marked location, or \(lqbookmark\(rq, in the document text,
574and a specification for how that marked location should be displayed,
575when this bookmark is selected.
576.LP
577To create a PDF bookmark, the
578.CW pdfhref
579macro is used,
580at the point in the document where the bookmark is to be placed,
581in the form
582.QP
583.fam C
584.B ".pdfhref O"
585.I level > <
586.I "descriptive text ..."
587.LP
588in which the reference class
589.CWB O \& \& \(rq \(lq
590stipulates that this is an outline reference.
591.LP
592Alternatively, for those users who may prefer to think of a document outline
593simply as a collection of bookmarks, the
594.CW pdfbookmark
595macro is also provided \(em indeed,
596.CW pdfhref
597invokes it, when processing the
598.CWB O \& \& \(rq \(lq
599reference class operator.
600It may be invoked directly, in the form
601.QP
602.fam C
603.B .pdfbookmark
604.I level > <
605.I "descriptive text ..."
606.LP
607Irrespective of which of the above macro forms is employed, the
608.CWI level > <
609argument is required.
610It is a numeric argument, defining the nesting level of the \(lqbookmark\(rq
611in the outline hierarchy, with one being the topmost level.
612Its function may be considered analagous to the
613.EM "heading level"
614of the document's section headings,
615for example, as specified with the
616.CW NH
617macro, if using the
618.CW ms
619macros to format the document.
620.LP
621All further arguments, following the
622.CWI level > <
623argument, are collected together, to specify the heading text which will appear
624in the document's outline view.
625Thus, the outline entry for this section of this document,
626which has a level three heading,
627might be specified as
628.QP
629.CW
630\&.pdfhref O 3 \*(SN A Basic Document Outline
631.LP
632or, in the alternative form using the
633.CW pdfbookmark
634macro, as
635.QP
636.CW
637\&.pdfbookmark 3 \*(SN A Basic Document Outline
638.NH 3
639.XN Hierarchical Structure in a Document Outline
640.LP
641When a document outline is created, using the
642.CW pdfhref
643macro as described in
644.\"
645.\" Here is an example of how we can temporarily modify the format of
646.\" a reference link, in this case to indicate only the section number
647.\" of the link target, in the form "section #", (or, if we define
648.\" "SECREF.BEGIN" before the call, its content followed by the
649.\" section number).
650.\"
651.\" We first define a macro, which will get the reference data from
652.\" pdfhref, as arguments, and will return the formatted output, as we
653.\" require it, the string "PDFHREF.TEXT".
654.\"
655.de SECREF
656.while \\n(.$ \{\
657. ie '\\$1'section' \{\
658. if !dSECREF.BEGIN .ds SECREF.BEGIN \\$1
659. ds PDFHREF.TEXT \\*[SECREF.BEGIN]\~\\$2
660. rm SECREF.BEGIN
661. shift \\n(.$
662. \}
663. el .shift
664. \}
665..
666.\" We now tell "pdfhref" to use our formatting macro, in place of
667.\" its builtin default formatter, before we specify the reference.
668.\"
669.pdfhref F SECREF
670.pdfhref L -A , -D basic-outline
671.\"
672.\" At this point, we would normally revert the "pdfhref" formatter
673.\" to use its default, built in macro. However, in this particular
674.\" case, we want to use our custom format one more time, before we
675.\" revert it, so we will omit the reversion step this time.
676.\"
677and any entry is added at a nesting level greater than one,
678then a hierarchical structure is automatically defined for the outline.
679However, as was noted in the simplified
680.pdfhref L -D pdfmark-example -- example
681in
682.pdfhref L -A , -D pdfmark-operator
683.\"
684.\" And now, we revert to default "pdfhref" formatting behaviour,
685.\" by completing the call we delayed above.
686.\"
687.pdfhref F
688.\"
689the data required by the
690.CW pdfmark
691operator to create the outline entry may not be fully defined,
692when the outline reference is defined in the
693.CW groff
694document source.
695Specifically, when the outline entry is created, its
696.CW /Count
697key must be assigned a value equal to the number of its subordinate entries,
698at the next inner level of the outline hierarchy;
699typically however,
700these subordinate entries will be defined
701.EM later
702in the document source, and the appropriate
703.CW /Count
704value will be unknown, when defining the parent entry.
705.LP
706To resolve this paradox, the
707.CW pdfhref
708macro creates the outline entry in two distinct phases \(em
709a destination marker is placed in the PostScript\*(rg output stream immediately,
710when the outline reference is defined,
711but the actual outline entry is stored in an internal \(lqoutline cache\(rq,
712until its subordinate hierarchy has been fully defined;
713it can then be inserted in the output stream, with its
714.CW /Count
715value correctly assigned.
716Effectively, to ensure integrity of the document outline structure,
717this means that each top level outline entry, and
718.EM all
719of its subordinates, are retained in the cache, until the
720.EM next
721top level entry is defined.
722.LP
723One potential problem, which arises from the use of the \(lqoutline cache\(rq,
724is that, at the end of any document formatting run, the last top level outline entry,
725and any subordinates defined after it, will remain in the cache, and will
726.EM not
727be automatically written to the output stream.
728To avoid this problem, the user should follow the guidelines given in
729.\"
730.\" Here is a more conventional example of how to temporarily change
731.\" to the format used to display reference links. We will again use
732.\" the "SECREF" format, which we defined above, but on this occasion
733.\" we will immediately revert to the default format, after the link
734.\" has been placed.
735.\"
736.pdfhref F SECREF
737.pdfhref L -D pdfsync -A ,
738.pdfhref F
739.\"
740to synchronise the output state with the cache state,
741.XR pdfsync ), (
742at the end of the
743.CW groff
744formatting run.
745.NH 3
746.XN -N outline-view -- Associating a Document View with an Outline Reference
747.LP
748Each \(lqbookmark\(rq entry, in a PDF document outline,
749is associated with a specific document view.
750When the reader selects any outline entry,
751the document view changes to display the document context
752associated with that entry.
753.LP
754The document view specification,
755to be associated with any document outline entry,
756is established at the time when the outline entry is created.
757However, rather than requiring that each individual use of the
758.CW pdhref
759macro, to create an outline entry,
760should include its own view specification,
761the actual specification assigned to each entry is derived from
762a generalised specification defined in the string
763.CW PDFBOOKMARK.VIEW ,
764together with the setting of the numeric register
765.CW PDFHREF.VIEW.LEADING ,
766which determine the effective view specification as follows:\(en
767.QS
768.IP \*[= PDFBOOKMARK.VIEW]
769Establishes the magnification at which the document will be viewed,
770at the location of the \(lqbookmark\(rq; by default, it is defined by
771.RS
772.QP
773.CW ".ds PDFBOOKMARK.VIEW /FitH \e\en[PDFPAGE.Y] u"
774.RE
775.IP
776which displays the associated document view,
777with the \(lqbookmark\(rq location positioned at the top of the display window,
778and with the magnification set to fit the page width to the width of the window.
779.IP \*[= PDFHREF.VIEW.LEADING]
780Specifies additional spacing,
781to be placed between the top of the display window
782and the actual location of the \(lqbookmark\(rq on the displayed page view.
783By default, it is set as
784.RS
785.QP
786.CW ".nr PDFHREF.VIEW.LEADING 5.0p"
787.RE
788.IP
789Note that
790.CW PDFHREF.VIEW.LEADING
791does not represent true \(lqleading\(rq, in the typographical sense,
792since any preceding text, set in the specified display space,
793will be visible at the top of the document viewing window,
794when the reference is selected.
795.IP
796Also note that the specification of
797.CW PDFHREF.VIEW.LEADING
798is shared by
799.EM all
800reference views defined by the
801.CW pdfhref
802macro; whereas
803.CW PDFBOOKMARK.VIEW
804is applied exclusively to outline references,
805there is no independent
806.CW PDFBOOKMARK.VIEW.LEADING
807specification.
808.QE
809.LP
810If desired, the view specification may be changed, by redefining the string
811.CW PDFBOOKMARK.VIEW ,
812and possibly also the numeric register
813.CW PDFHREF.VIEW.LEADING .
814Any alternative definition for
815.CW PDFBOOKMARK.VIEW
816.EM must
817be specified in terms of valid view specification parameters,
818as described in the Adobe\*(rg
819.pdfmark-manual .
820.LP
821Note the use of the register
822.CW PDFPAGE.Y ,
823in the default definition of
824.CW PDFBOOKMARK.VIEW
825above.
826This register is computed by
827.CW pdfhref ,
828when creating an outline entry;
829it specifies the vertical position of the \(lqbookmark\(rq,
830in basic
831.CW groff
832units, relative to the
833.EM bottom
834edge of the document page on which it is defined,
835and is followed, in the
836.CW PDFBOOKMARK.VIEW
837definition, by the
838.CW grops
839.CW u \(rq \(lq
840operator, to convert it to PostScript\*(rg units on output.
841It may be used in any redefined specification for
842.CW PDFBOOKMARK.VIEW ,
843(or in the analogous definition of
844.CW PDFHREF.VIEW ,
845described in
846.XR-NO-PREFIX pdfhref-view ),
847but
848.EM not
849in any other context,
850since its value is undefined outside the scope of the
851.CW pdfhref
852macro.
853.LP
854Since
855.CW PDFPAGE.Y
856is computed relative to the
857.EM bottom
858of the PDF output page,
859it is important to ensure that the page length specified to
860.CW troff
861correctly matches the size of the logical PDF page.
862This is most effectively ensured,
863by providing
864.EM identical
865page size specifications to
866.CW groff ,
867.CW grops
868and to the PostScript\*(rg to PDF converter employed,
869and avoiding any page length changes within the document source.
870.LP
871Also note that
872.CW PDFPAGE.Y
873is the only automatically computed \(lqbookmark\(rq location parameter;
874if the user redefines
875.CW PDFBOOKMARK.VIEW ,
876and the modified view specification requires any other positional parameters,
877then the user
878.EM must
879ensure that these are computed
880.EM before
881invoking the
882.CW pdfhref
883macro.
884.NH 3
885.XN -N outline-folding -- Folding the Outline to Conceal Less Significant Headings
886.LP
887When a document incorporates many subheadings,
888at deeply nested levels,
889it may be desirable to \(lqfold\(rq the outline
890such that only the major heading levels are initially visible,
891yet making the inferior subheadings accessible,
892by allowing the reader to expand the view of any heading branch on demand.
893.LP
894The
895.CW pdfmark
896macros support this capability,
897through the setting of the
898.CW PDFOUTLINE.FOLDLEVEL
899register.
900This register should be set to the number of heading levels
901which it is desired to show in expanded form, in the
902.EM initial
903document outline display;
904all subheadings at deeper levels will still be added to the outline,
905but will not become visible until the outline branch containing them is expanded.
906'ne 5
907For example, the setting used in this document:
908.QS
909.LD
910.fam C
911\&.\e" Initialise the outline view to show only three heading levels,
912\&.\e" with additional subordinate level headings folded.
913\&.\e"
914\&.nr PDFOUTLINE.FOLDLEVEL 3
915.DE
916.QE
917.LP
918results in only the first three levels of headings being displayed
919in the document outline,
920.EM until
921the reader chooses to expand the view,
922and so reveal the lower level headings in any outline branch.
923.LP
924The initial default setting of
925.CW PDFOUTLINE.FOLDLEVEL ,
926if the document author does not choose to change it,
927is 10,000.
928This is orders of magnitude greater than the maximum heading level
929which is likely to be used in any document;
930thus the default behaviour will be to show document outlines fully expanded,
931to display all headings defined,
932at all levels within each document.
933.LP
934The setting of
935.CW PDFOUTLINE.FOLDLEVEL
936may be changed at any time;
937however, the effect of each such change may be difficult to predict,
938since it is applied not only to outline entries which are defined
939.EM after
940the setting is changed,
941but also to any entries which remain in the outline cache,
942.EM at
943this time.
944Therefore, it is recommended that
945.CW PDFOUTLINE.FOLDLEVEL
946should be set
947.EM once ,
948at the start of each document;
949if it
950.EM is
951deemed necessary to change it at any other time,
952the outline cache should be flushed,
953.XR pdfsync ), (
954.EM immediately
955before the change,
956which should immediately preceed a level one heading.
957.NH 3
958.XN -N multipart-outline -- Outlines for Multipart Documents
959.LP
960When a document outline is created, using the
961.CW pdfhref
962macro, each reference mark is automatically assigned a name,
963composed of a fixed stem followed by a serially generated numeric qualifier.
964This ensures that, for each single part document, every outline reference
965has a uniquely named destination.
966.LP
967As the overall size of the PDF document increases,
968it may become convenient to divide it into smaller,
969individually formatted PostScript\*(rg components,
970which are then assembled, in the appropriate order,
971to create a composite PDF document.
972While this strategy may simplify the overall process of creating and
973editing larger documents, it does introduce a problem in creating
974an overall document outline,
975since each individual PostScript\*(rg component will be assigned
976duplicated sequences of \(lqbookmark\(rq names,
977with each name ultimately referring to multiple locations in the composite document.
978To avoid such reference naming conflicts, the
979.CW pdfhref
980macro allows the user to specify a \(lqtag\(rq,
981which is appended to the automatically generated \(lqbookmark\(rq name;
982this may be used as a discriminating mark, to distinguish otherwise
983similarly named destinations, in different sections of the composite document.
984.LP
985To create a \(lqtagged\(rq document outline,
986the syntax for invocation of the
987.CW pdfhref
988macro is modified, by the inclusion of an optional \(lqtag\(rq specification,
989.EM before
990the nesting level argument, i.e.
991.QP
992.fam C
993.B ".pdfhref O"
994.B -T \& [
995.I tag >] <
996.I level > <
997.I "descriptive text ..."
998.LP
999The optional
1000.CWI tag > <
1001argument may be composed of any characters of the user's choice;
1002however, its initial character
1003.EM "must not"
1004be any decimal digit, and ideally it should be kept short
1005\(em one or two characters at most.
1006.LP
1007By employing a different tag in each section,
1008the user can ensure that \(lqbookmark\(rq names remain unique,
1009throughout all the sections of a composite document.
1010For example, when using the
1011.CW spdf.tmac
1012macro package, which adds
1013.CW pdfmark
1014capabilities to the standard
1015.CW ms
1016package,
1017.XR using-spdf ), (
1018the table of contents is collected into a separate PostScript\*(rg section
1019from the main body of the document.
1020In the \(lqbody\(rq section, the document outline is \(lquntagged\(rq,
1021but in the \(lqTable\~of\~Contents\(rq section, a modified version of the
1022.CW TC
1023macro adds an outline entry for the start of the \(lqTable\~of\~Contents\(rq,
1024invoking the
1025.CW pdfhref
1026macro as
1027.QP
1028.CW ".pdfhref O -T T 1 \e\e*[TOC]"
1029.LP
1030to tag the associated outline destination name with the single character suffix,
1031.CW T \(rq. \(lq
1032Alternatively, as in the case of the basic outline,
1033.XR basic-outline ), (
1034this may equally well be specified as
1035.QP
1036.CW ".pdfbookmark -T T 1 \e\e*[TOC]"
1037.NH 3
1038.XN Delegation of the Outline Definition
1039.LP
1040Since the most common use of a document outline
1041is to provide a quick method of navigating through a document,
1042using active \(lqhypertext\(rq links to chapter and section headings,
1043it may be convenient to delegate the responsibility of creating the outline
1044to a higher level macro, which is itself used to
1045define and format the section headings.
1046This approach has been adopted in the
1047.CW spdf.tmac
1048package, to be described later,
1049.XR using-spdf ). (
1050.LP
1051When such an approach is adopted,
1052the user will rarely, if ever, invoke the
1053.CW pdfhref
1054macro directly, to create a document outline.
1055For example, the structure and content of the outline for this document
1056has been exclusively defined, using a combination of the
1057.CW NH
1058macro, from the
1059.CW ms
1060package, to establish the structure, and the
1061.CW XN
1062macro from
1063.CW spdf.tmac ,
1064to define the content.
1065In this case,
1066the responsibility for invoking the
1067.CW pdfhref
1068macro, to create the document outline,
1069is delegated to the
1070.CW XN
1071macro.
1072.NH 2
1073.XN -N pdfhref -- Adding Reference Marks and Links
1074.LP
1075.pdfhref F SECREF
1076.ds SECREF.BEGIN Section
1077.pdfhref L -D add-outline
1078.pdfhref F
1079has shown how the
1080.CW pdfhref
1081macro may be used to create a PDF document outline.
1082While this is undoubtedly a powerful capability,
1083it is by no means the only trick in the repertoire of this versatile macro.
1084.LP
1085The macro name,
1086.CW pdfhref ,
1087which is a contraction of \(lqPDF HyperText Reference\(rq,
1088indicates that the general purpose of this macro is to define
1089.EM any
1090type of dynamic reference mark, within a PDF document.
1091Its generalised usage syntax takes the form
1092.QP
1093.fam C
1094.B .pdfhref
1095.BI class > <
1096.I "-options ...\&" ] [
1097[--]
1098.I "descriptive text ...\&" ] [
1099.LP
1100where
1101.CW <\f(CIclass\fP>
1102represents a required single character argument,
1103which defines the specific reference operation to be performed,
1104and may be selected from:\(en
1105.QS
1106.IP \*[= O]
1107Add an entry to the document outline.
1108This operation has been described earlier,
1109.XR add-outline ). (
1110.IP \*[= M]
1111Place a \(lqnamed destination\(rq reference mark at the current output position,
1112in the current PDF document,
1113.XR mark-dest ). (
1114.IP \*[= D]
1115Specify the content of a PDF document reference dictionary entry;
1116typically, such entries are generated automatically,
1117by transformation of the intermediate output resulting from the use of
1118.CW pdfhref
1119.CWB M \& \& \(rq, \(lq
1120with the
1121.CWB -X \& \& \(rq \(lq
1122modifier,
1123.XR create-map ); (
1124however, it is also possible to specify such entries manually,
1125.XR user-format ). (
1126.IP \*[= L]
1127Insert an active link to a named destination,
1128.XR link-named ), (
1129at the current output position in the current PDF document,
1130such that when the reader clicks on the link text,
1131the document view changes to show the location of the named destination.
1132.IP \*[= W]
1133Insert an active link to a \(lqweb\(rq resource,
1134.XR add-weblink ), (
1135at the current output position in the current PDF document.
1136This is effectively the same as using the
1137.CWB L \& \& \(rq \(lq
1138operator to establish a link to a named destination in another PDF document,
1139.XR link-extern ), (
1140except that in this case, the destination is specified by a
1141\(lquniform resource identifier\(rq, or
1142.CW URI ;
1143this may represent any Internet or local resource
1144which can be specified in this manner.
1145.IP \*[= F]
1146Specify a user defined macro, to be called by
1147.CW pdfhref ,
1148when formatting the text in the active region of a link,
1149.XR set-format ). (
1150.IP \*[= Z]
1151Define the absolute position on the physical PDF output page,
1152where the \(lqhot\(hyspot\(rq associated with an active link is to be placed.
1153Invoked in pairs, marking the starting and ending PDF page co\(hyordinates
1154for each link \(lqhot\(hyspot\(rq, this operator is rarely, if ever,
1155specified directly by the user;
1156rather, appropriate
1157.CW pdfhref
1158.CWB Z \& \& \(rq \(lq
1159specifications are inserted automatically into the document reference map
1160during the PDF document formatting process,
1161.XR create-map ). (
1162.IP \*[= I]
1163Initialise support for
1164.CW pdfhref
1165features.
1166The current
1167.CW pdfhref
1168implementation provides only one such feature which requires initialisation
1169\(em a helper macro which must be attached to a user supplied page trap handler,
1170in order to support mapping of reference \(lqhot\(hyspots\(rq
1171which extend through a page transition;
1172.XR page-trap ). (
1173.QE
1174.NH 3
1175.XN Optional Features of the \F[C]pdfhref\F[] Macro
1176.LP
1177The behaviour of a number of the
1178.CW pdfhref
1179macro operations can be modified,
1180by including
1181.EM "option specifiers" \(rq \(lq
1182after the operation specifying argument,
1183but
1184.EM before
1185any other arguments normally associated with the operation.
1186In
1187.EM all
1188cases, an option is specified by an
1189.EM "option flag" \(rq, \(lq
1190comprising an initial hyphen,
1191followed by one or two option identifying characters.
1192Additionally,
1193.EM some
1194options require
1195.EM "exactly one"
1196option argument;
1197for these options, the argument
1198.EM must
1199be specified, and it
1200.EM must
1201be separated from the preceding option flag by one or more
1202.EM spaces ,
1203(tabs
1204.EM "must not"
1205be used).
1206It may be noted that this paradigm for specifying options
1207is reminiscent of most
1208.SM
1209UNIX\(tm
1210.LG
1211shells; however, in the case of the
1212.CW pdfhref
1213macro, omission of the space separating an option flag from its argument is
1214.EM never
1215permitted.
1216.LP
1217A list of
1218.EM all
1219general purpose options supported by the
1220.CW pdfhref
1221macro is given below.
1222Note that not all options are supported for all
1223.CW pdfhref
1224operations; the operations affected by each option are noted in the list.
1225For
1226.EM most
1227operations, if an unsupported option is specified,
1228it will be silently ignored; however, this behaviour should
1229not be relied upon.
1230.LP
1231The general purpose options, supported by the
1232.CW pdfhref
1233macro, are:\(en
1234.QS
1235.IP \*[= -N\0 name > <]
1236Allows the
1237.CWI name > <
1238associated with a PDF reference destination
1239to be defined independently from the following text,
1240which describes the reference.
1241This option affects only the
1242.CWB M \& \& \(rq \(lq
1243operation of the
1244.CW pdfhref
1245macro,
1246.XR mark-dest ). (
1247.IP \*[= -E]
1248Also used exclusively with the
1249.CWB M \& \& \(rq \(lq
1250operator, the
1251.CWB -E
1252option causes any specified
1253.CWI descriptive \& \& \~\c
1254.CWI text
1255arguments,
1256.XR mark-dest ), (
1257to be copied, or
1258.EM echoed ,
1259in the body text of the document,
1260at the point where the reference mark is defined;
1261(without the
1262.CWB -E
1263option, such
1264.CWI descriptive \& \& \~\c
1265.CWI text
1266will appear
1267.EM only
1268at points where links to the reference mark are placed,
1269and where the standard reference display format,
1270.XR set-format ), (
1271is used).
1272.IP \*[= -D\0 dest > <]
1273Specifies the
1274.CW URI ,
1275or the destination name associated with a PDF active link,
1276independently of the following text,
1277which describes the link and demarcates the link \(lqhot\(hyspot\(rq.
1278This option affects the behaviour of the
1279.CW pdfhref
1280macro's
1281.CWB L \& \& \(rq \(lq
1282and
1283.CWB W \& \& \(rq \(lq
1284operations.
1285.IP
1286When used with the
1287.CWB L \& \& \(rq \(lq
1288operator, the
1289.CWI dest > <
1290argument must specify a PDF \(lqnamed destination\(rq,
1291as defined using
1292.CW pdfhref
1293with the
1294.CWB M \& \& \(rq \(lq
1295operator.
1296.IP
1297When used with the
1298.CWB W \& \& \(rq \(lq
1299operator,
1300.CWI dest > <
1301must specify a link destination in the form of a
1302\(lquniform resource identifier\(rq, or
1303.CW URI ,
1304.XR add-weblink ). (
1305.IP \*[= -F\0 file > <]
1306When used with the
1307.CWB L \& \& \(rq \(lq
1308.CW pdfhref
1309operator,
1310.CWI file > <
1311specifies an external PDF file in which the named destination
1312for the link reference is defined.
1313This option
1314.EM must
1315be specified with the
1316.CWB L \& \& \(rq \(lq
1317operator,
1318to create a link to a destination in a different PDF document;
1319when the
1320.CWB L \& \& \(rq \(lq
1321operator is used
1322.EM without
1323this option, the link destination is assumed to be defined
1324within the same document.
1325.IP \*[= -P\0 \(dqprefix\(hytext\(dq > <]
1326Specifies
1327.CWI \(dqprefix\(hytext\(dq > <
1328to be attached to the
1329.EM start
1330of the text describing an active PDF document link,
1331with no intervening space, but without itself being included in the
1332active area of the link \(lqhot\(hyspot\(rq;
1333it is effective with the
1334.CWB L \& \& \(rq \(lq
1335and
1336.CWB W \& \& \(rq \(lq
1337.CW pdfhref
1338operators.
1339.IP
1340Typically, this option would be used to insert punctuation before
1341the link \(lqhot\(hyspot\(rq.
1342Thus, there is little reason for the inclusion of spaces in
1343.CWI \(dqprefix\(hytext\(dq > < ;
1344however, if such space is required, then the enclosing double quotes
1345.EM must
1346be specified, as indicated.
1347.IP \*[= -A\0 \(dqaffixed\(hytext\(dq > <]
1348Specifies
1349.CWI \(dqaffixed\(hytext\(dq > <
1350to be attached to the
1351.EM end
1352of the text describing an active PDF document link,
1353with no intervening space, but without itself being included in the
1354active area of the link \(lqhot\(hyspot\(rq;
1355it is effective with the
1356.CWB L \& \& \(rq \(lq
1357and
1358.CWB W \& \& \(rq \(lq
1359.CW pdfhref
1360operators.
1361.IP
1362Typically, this option would be used to insert punctuation after
1363the link \(lqhot\(hyspot\(rq.
1364Thus, there is little reason for the inclusion of spaces in
1365.CWI \(dqaffixed\(hytext\(dq > < ;
1366however, if such space is required, then the enclosing double quotes
1367.EM must
1368be specified, as indicated.
1369.IP \*[= -T\0 tag > <]
1370When specified with the
1371.CWB O \& \& \(rq \(lq
1372operator,
1373.CWI tag > <
1374is appended to the \(lqbookmark\(rq name assigned to the generated outline entry.
1375This option is
1376.EM required ,
1377to distinguish between the series of \(lqbookmark\(rq names generated in
1378individual passes of the
1379.CW groff
1380formatter, when the final PDF document is to be assembled
1381from a number of separately formatted components;
1382.XR multipart-outline ). (
1383.IP \*[= -X]
1384This
1385.CW pdfhref
1386option is used with either the
1387.CWB M \& \& \(rq \(lq
1388operator, or with the
1389.CWB L \& \& \(rq \(lq
1390operator.
1391.IP
1392When used with the
1393.CWB M \& \& \(rq \(lq
1394operator,
1395.XR mark-dest ), (
1396it ensures that a cross reference record for the marked destination
1397will be included in the document reference map,
1398.XR export-map ). (
1399.IP
1400When used with the
1401.CWB L \& \& \(rq \(lq
1402operator,
1403.XR link-named ), (
1404it causes the reference to be displayed in the standard cross reference format,
1405.XR set-format ), (
1406but substituting the
1407.CWI descriptive \& \& \~\c
1408.CWI text
1409specified in the
1410.CW pdfhref \& \(lq
1411.CW L \(rq
1412argument list,
1413for the description specified in the document reference map.
1414.IP \*[= --]
1415Marks the end of the option specifiers.
1416This may be used with all
1417.CW pdfhref
1418operations which accept options, to prevent
1419.CW pdfhref
1420from interpreting any following arguments as option specifiers,
1421even if they would otherwise be interpreted as such.
1422It is also useful when the argument list to
1423.CW pdfhref
1424contains special characters \(em any special character,
4d3e9548 1425which is not valid in a
465b256c
JR
1426.CW groff
1427macro name, will cause a parsing error, if
1428.CW pdfhref
1429attempts to match it as a possible option flag;
1430using the
1431.CW -- \(rq \(lq
1432flag prevents this, so suppressing the
1433.CW groff
1434warning message, which would otherwise ensue.
1435.IP
1436Using this flag after
1437.EM all
1438sequences of macro options is recommended,
1439even when it is not strictly necessary,
1440if only for the entirely cosmetic benefit of visually separating
1441the main argument list from the sequence of preceding options.
1442.QE
1443.LP
1444In addition to the
1445.CW pdfhref
1446options listed above, a supplementary set of two character options are defined.
1447These supplementary options, listed below, are intended for use with the
1448.CWB L \& \& \(rq \(lq
1449operator, in conjunction with the
1450.CWB -F \& \& \~\c
1451.CWBI file > <
1452option, to specify alternate file names,
1453in formats compatible with the file naming conventions
1454of alternate operating systems;
1455they will be silently ignored, if used in any other context.
1456.LP
1457The supported alternate file name options,
1458which are ignored if the
1459.CWB -F \& \& \~\c
1460.CWBI file > <
1461option is not specified, are:\(en
1462.QS
1463.IP \*[= -DF\0 dos\(hyfile > <]
1464Specifies the name of the file in which a link destination is defined,
1465using the file naming semantics of the
1466.CW MS\(hyDOS \*(rg
1467operating system.
1468When the PDF document is read on a machine
1469where the operating system uses the
1470.CW MS\(hyDOS \*(rg
1471file system, then
1472.CWI dos\(hyfile > <
1473is used as the name of the file containing the reference destination,
1474overriding the
1475.CWI file > <
1476argument specified with the
1477.CWB -F
1478option.
1479.IP \*[= -MF\0 mac\(hyfile > <]
1480Specifies the name of the file in which a link destination is defined,
1481using the file naming semantics of the
1482.CW Apple \*(rg
1483.CW Macintosh \*(rg
1484operating system.
1485When the PDF document is read on a machine
1486where the operating system uses the
1487.CW Macintosh \*(rg
1488file system, then
1489.CWI mac\(hyfile > <
1490is used as the name of the file containing the reference destination,
1491overriding the
1492.CWI file > <
1493argument specified with the
1494.CWB -F
1495option.
1496.IP \*[= -UF\0 unix\(hyfile > <]
1497Specifies the name of the file in which a link destination is defined,
1498using the file naming semantics of the
1499.CW UNIX \(tm
1500operating system.
1501When the PDF document is read on a machine
1502where the operating system uses
1503.CW POSIX
1504file naming semantics, then
1505.CWI unix\(hyfile > <
1506is used as the name of the file containing the reference destination,
1507overriding the
1508.CWI file > <
1509argument specified with the
1510.CWB -F
1511option.
1512.IP \*[= -WF\0 win\(hyfile > <]
1513Specifies the name of the file in which a link destination is defined,
1514using the file naming semantics of the
1515.CW MS\(hyWindows \*(rg
151632\(hybit operating system.
1517When the PDF document is read on a machine
1518where the operating system uses any of the
1519.CW MS\(hyWindows \*(rg
1520file systems, with long file name support, then
1521.CWI win\(hyfile > <
1522is used as the name of the file containing the reference destination,
1523overriding the
1524.CWI file > <
1525argument specified with the
1526.CWB -F
1527option.
1528.QE
1529.NH 3
1530.XN -N mark-dest -- Marking a Reference Destination
1531.LP
1532The
1533.CW pdfhref
1534macro may be used to create active links to any Internet resource,
1535specified by its
1536.CW URI ,
1537or to any \(lqnamed destination\(rq,
1538either within the same document, or in another PDF document.
1539Although the PDF specification allows link destinations to be defined
1540in terms of a page number, and an associated view specification,
1541this style of reference is not currently supported by the
1542.CW pdfhref
1543macro, because it is not possible to adequately bind the specification
1544for the destination with the intended reference context.
1545.LP
1546References to Internet resources are interpreted in accordance with the
1547.CW W3C
1548standard for defining a
1549.CW URI ;
1550hence the only prerequisite, for creating a link to any Internet resource,
1551is that the
1552.CW URI
1553be properly specified, when declaring the reference;
1554.XR add-weblink ). (
1555In the case of references to \(lqnamed destinations\(rq in PDF documents,
1556however, it is necessary to provide a mechanism for creating such
1557\(lqnamed destinations\(rq.
1558This may be accomplished, by invoking the
1559.CW pdfhref
1560macro in the form
1561.QP
1562.fam C
1563.B ".pdfhref M"
1564.B -N \& [
1565.I name >] <
1566.B -X ] [
1567.B -E ] [
1568.I "descriptive text ...\&" ] [
1569.LP
1570This creates a \(lqnamed destination\(rq reference mark, with its name specified by
1571.CWI name > < ,
1572or, if the
1573.CWB -N
1574option is not specified, by the first word of
1575.CWI descriptive \& \& \~\c
1576.CWI text \& \& ;
1577(note that this imposes the restriction that,
1578if the
1579.CWB -N
1580option is omitted, then
1581.EM "at least"
1582one word of
1583.CWI descriptive \& \& \~\c
1584.CWI text
1585.EM must
1586be specified).
1587Additionally, a reference view will be automatically defined,
1588and associated with the reference mark,
1589.XR pdfhref-view ), (
1590.\" and, if any
1591.\" .CWI descriptive
1592.\" .CWI text
1593.\" is specified, or the
1594and, if the
1595.CWB -X
1596option is specified, and no document cross reference map has been imported,
1597.XR import-map ), (
1598then a cross reference mapping record,
1599.XR export-map ), (
1600will be written to the
1601.CW stdout
1602stream;
1603this may be captured, and subsequently used to generate a cross reference map
1604for the document,
1605.XR create-map ). (
1606.LP
1607When a \(lqnamed destination\(rq reference mark is created, using the
1608.CW pdfhref
1609macro's
1610.CWB M \& \& \(rq \(lq
1611operator, there is normally no visible effect in the formatted document; any
1612.CWI descriptive \& \& \~\c
1613.CWI text
1614which is specified will simply be stored in the cross reference map,
1615for use when a link to the reference mark is created.
1616This default behaviour may be changed, by specifying the
1617.CWB -E
1618option, which causes any specified
1619.CWI descriptive \& \& \~\c
1620.CWI text
1621to be \(lqechoed\(rq in the document text,
1622at the point where the reference mark is placed,
1623in addition to its inclusion in the cross reference map.
1624.NH 4
1625.XN -N export-map -- Mapping a Destination for Cross Referencing
1626.LP
1627Effective cross referencing of
1628.EM any
1629document formatted by
1630.CW groff
1631requires multiple pass formatting.
1632Details of how this multiple pass formatting may be accomplished,
1633when working with the
1634.CW pdfmark
1635macros, will be discussed later,
1636.XR do-xref ); (
1637at this stage, the discussion will be restricted to the initial preparation,
1638which is required at the time when the cross reference destinations are defined.
1639.LP
1640The first stage, in the process of cross referencing a document,
1641is the generation of a cross reference map.
1642Again, the details of
1643.EM how
1644the cross reference map is generated will be discussed in
1645.pdfhref F SECREF L -D do-xref -A ;
1646.pdfhref F
1647however, it is important to recognise that
1648.EM what
1649content is included in the cross reference map is established
1650when the reference destination is defined \(em it is derived
1651from the reference data exported on the
1652.CW stderr
1653stream by the
1654.CW pdfhref
1655macro, when it is invoked with the
1656.CWB M \& \& \(rq \(lq
1657operator, and is controlled by whatever definition of the string
1658.CW PDFHREF.INFO
1659is in effect, when the
1660.CW pdfhref
1661macro is invoked.
1662.LP
1663The initial default setting of
1664.CW PDFHREF.INFO
1665is
1666.QP
1667.CW ".ds PDFHREF.INFO page \e\en% \e\e$*"
1668.LP
1669which ensures that the cross reference map will contain
1670at least a page number reference, supplemented by any
1671.CWI descriptive \& \& \~\c
1672.CWI text
1673which is specified for the reference mark, as defined by the
1674.CW pdfhref
1675macro, with its
1676.CWB M \& \& \(rq \(lq
1677operator; this may be redefined by the user,
1678to export additional cross reference information,
1679or to modify the default format for cross reference links,
1680.XR set-format ). (
1681.NH 4
1682.XN -N pdfhref-view -- Associating a Document View with a Reference Mark
1683.LP
1684In the same manner as each document outline reference, defined by the
1685.CW pdfhref
1686macro with the
1687.CWB O \& \& \(rq \(lq
1688operator,
1689.XR add-outline ), (
1690has a specific document view associated with it,
1691each reference destination marked by
1692.CW pdfhref
1693with the
1694.CWB M \& \& \(rq \(lq
1695operator, requires an associated document view specification.
1696.LP
1697The mechanism whereby a document view is associated with a reference mark
1698is entirely analogous to that employed for outline references,
1699.XR outline-view ), (
1700except that the
1701.CW PDFHREF.VIEW
1702string specification is used, in place of the
1703.CW PDFBOOKMARK.VIEW
1704specification.
1705Thus, the reference view is defined in terms of:\(en
1706.QS
1707.IP \*[= PDFHREF.VIEW]
1708A string,
1709establishing the position of the reference mark within the viewing window,
1710and the magnification at which the document will be viewed,
1711at the location of the marked reference destination;
1712by default, it is defined by
1713.RS
1714.QP
1715.CW ".ds PDFHREF.VIEW /FitH \e\en[PDFPAGE.Y] u"
1716.RE
1717.IP
1718which displays the reference destination at the top of the viewing window,
1719with the magnification set to fit the page width to the width of the window.
1720.IP \*[= PDFHREF.VIEW.LEADING]
1721A numeric register,
1722specifying additional spacing, to be placed between the top of the display
1723window and the actual position at which the location of the reference
1724destination appears within the window.
1725This register is shared with the view specification for outline references,
1726and thus has the same default initial setting,
1727.RS
1728.QP
1729.CW ".nr PDFHREF.VIEW.LEADING 5.0p"
1730.RE
1731.IP
1732as in the case of outline reference views.
1733.IP
1734Again, notice that
1735.CW PDFHREF.VIEW.LEADING
1736does not represent true typographic \(lqleading\(rq,
1737since any preceding text, set in the specified display space,
1738will be visible at the top of the viewing window,
1739when the reference is selected.
1740.QE
1741.LP
1742Just as the view associated with outline references may be changed,
1743by redefining
1744.CW PDFBOOKMARK.VIEW ,
1745so the view associated with marked reference destinations may be changed,
1746by redefining
1747.CW PDFHREF.VIEW ,
1748and, if desired,
1749.CW PDFHREF.VIEW.LEADING ;
1750such changes will become effective for all reference destinations marked
1751.EM after
1752these definitions are changed.
1753(Notice that, since the specification of
1754.CW PDFHREF.VIEW.LEADING
1755is shared by both outline reference views and marked reference views,
1756if it is changed, then the views for
1757.EM both
1758reference types are changed accordingly).
1759.LP
1760It may again be noted, that the
1761.CW PDFPAGE.Y
1762register is used in the definition of
1763.CW PDFHREF.VIEW ,
1764just as it is in the definition of
1765.CW PDFBOOKMARK.VIEW ;
1766all comments in
1767.pdfhref F SECREF L -D outline-view
1768.pdfhref F
1769relating to its use, and indeed to page position computations in general,
1770apply equally to marked reference views and to outline reference views.
1771.NH 3
1772.XN -N link-named -- Linking to a Marked Reference Destination
1773.LP
1774Any named destination, such as those marked by the
1775.CW pdfhref
1776macro, using it's
1777.CWB M \& \& \(rq \(lq
1778operator, may be referred to from any point in
1779.EM any
1780PDF document, using an
1781.EM "active link" ;
1782such active links are created by again using the
1783.CW pdfhref
1784macro, but in this case, with the
1785.CWB L \& \& \(rq \(lq
1786operator.
1787This operator provides support for two distinct cases,
1788depending on whether the reference destination is defined in
1789the same document as the link,
1790.XR link-intern ), (
1791or is defined as a named destination in a different PDF document,
1792.XR link-extern ). (
1793.NH 4
1794.XN -N link-intern -- References within a Single PDF Document
1795.LP
1796The general syntactic form for invoking the
1797.CW pdfhref
1798macro,
1799when creating a link to a named destination within the same PDF document is
1800.QP
1801.fam C
1802.B .pdfhref
1803.B L
1804.B -D \& [
1805.BI dest-name >] <
1806.B -P \& [
1807.BI prefix-text >] <
1808.B -A \& [
1809.BI affixed-text >] <
1810\e
1811.br
1812\0\0\0
1813.B -X ] [
1814.B -- ] [
1815.I "descriptive text ...\&" ] [
1816.LP
1817where
1818.CWI dest-name > <
1819specifies the name of the link destination,
1820as specified using the
1821.CW pdfhref
1822.CWB M \& \& \(rq \(lq
1823operation; (it may be defined either earlier in the document,
1824to create a backward reference, or later, to create a forward reference).
1825.\"
1826.\" Here's a example of how to add an iconic annotation.
1827.\"
1828.\".pdfnote -T "Internal Cross References" \
1829.\" This description is rather terse, and could benefit from \
1830.\" the inclusion of an example.
1831.LP
1832If any
1833.CWI descriptive \& \& \~\c
1834.CWI text
1835arguments are specified, then they will be inserted into the
1836.CW groff
1837output stream, to define the text appearing in the \(lqhot\(hyspot\(rq
1838region of the link;
1839this will be printed in the link colour specified by the string,
1840.CW PDFHREF.TEXT.COLOUR ,
1841which is described in
1842.XR-NO-PREFIX set-colour .
1843If the
1844.CWB -X
1845option is also specified, then the
1846.CWI descriptive \& \& \~\c
1847.CWI text
1848will be augmented, by prefacing it with page and section number indicators,
1849in accordance with the reference formatting rules which are in effect,
1850.XR set-format ); (
1851such indicators will be included within the active link region,
1852and will also be printed in the link colour.
1853.LP
1854Note that
1855.EM either
1856the
1857.CWB -D \& \& \~\c
1858.CWBI dest\(hyname > <
1859option,
1860.EM or
1861the
1862.CWI descriptive \& \& \~\c
1863.CWI text
1864arguments,
1865.EM "but not both" ,
1866may be omitted.
1867If the
1868.CWB -D \& \& \~\c
1869.CWBI dest\(hyname > <
1870option is omitted, then the first word of
1871.CWI descriptive \& \& \~\c
1872.CWI text \& \& ,
1873i.e.\~all text up to but not including the first space,
1874will be interpreted as the
1875.CWBI dest\(hyname > <
1876for the link; this text will also appear in the running text of the document,
1877within the active region of the link.
1878Alternatively, if the
1879.CWB -D \& \& \~\c
1880.CWBI dest\(hyname > <
1881option
1882.EM is
1883specified, and
1884.CWI descriptive \& \& \~\c
1885.CWI text
1886is not,
1887then the running text which defines the reference,
1888and its active region,
1889will be derived from the reference description which is specified
1890when the named destination is marked,
1891.XR mark-dest ), (
1892and will be formatted according to the reference formatting rules
1893which are in effect, when the reference is placed,
1894.XR set-format ); (
1895in this case, it is not necessary to specify the
1896.CWB -X
1897option to activate automatic formatting of the reference \(em it is implied,
1898by the omission of all
1899.CWI descriptive \& \& \~\c
1900.CWI text
1901arguments.
1902.LP
1903The
1904.CWB -P \& \& \~\c
1905.CWBI prefix\(hytext > <
1906and
1907.CWB -A \& \& \~\c
1908.CWBI affixed\(hytext > <
1909options may be used to specify additional text
1910which will be placed before and after the linked text respectively,
1911with no intervening space.
1912Such prefixed and affixed text will be printed in the normal text colour,
1913and will not be included within the active region of the link.
1914This feature is mostly useful for creating parenthetical references,
1915or for placing punctuation adjacent to,
1916but not included within,
1917the text which defines the active region of the link.
1918.LP
1919The operation of the
1920.CW pdfhref
1921macro, when used with its
1922.CWB L \& \& \(rq \(lq
1923operator to place a link to a named PDF destination,
1924may best be illustrated by an example.
1925However, since the appearance of the link will be influenced by
1926factors established when the named destination is marked,
1927.XR mark-dest ), (
1928and also by the formatting rules in effect when the link is placed,
1929the presentation of a suitable exanple will be deferred,
1930until the formatting mechanism has been explained,
1931.XR set-format ). (
1932.NH 4
1933.XN -N link-extern -- References to Destinations in Other PDF Documents
1934.LP
1935The
1936.CW pdfhref
1937macro's
1938.CWB L \& \& \(rq \(lq
1939operator is not restricted to creating reference links
1940within a single PDF document.
1941When the link destination is defined in a different document,
1942then the syntactic form for invoking
1943.CW pdfhref
1944is modified, by the addition of options to specify the
1945name and location of the PDF file in which the destination is defined.
1946Thus, the extended
1947.CW pdfhref
1948syntactic form becomes
1949.QP
1950.fam C
1951.B .pdfhref
1952.B L
1953.B -F
1954.BI file > <
1955.B -D \& [
1956.BI dest-name >] <
1957\e
1958.br
1959\0\0\0
1960.B -DF \& [
1961.BI dos-file >] <
1962.B -MF \& [
1963.BI mac-file >] <
1964.B -UF \& [
1965.BI unix-file >] <
1966\e
1967.br
1968\0\0\0
1969.B -WF \& [
1970.BI win-file >] <
1971.B -P \& [
1972.BI prefix-text >] <
1973.B -A \& [
1974.BI affixed-text >] <
1975\e
1976.br
1977\0\0\0
1978.B -X ] [
1979.B -- ] [
1980.I "descriptive text ...\&" ] [
1981.LP
1982where the
1983.CWB -F \& \& \~\c
1984.CWBI file > <
1985option serves
1986.EM two
1987purposes: it both indicates to the
1988.CW pdfhref
1989macro that the specified reference destination
1990is defined in an external PDF file,
1991and it also specifies the normal path name,
1992which is to be used to locate this file,
1993when a user selects the reference.
1994.LP
1995In addition to the
1996.CWB -F \& \& \~\c
1997.CWBI file > <
1998option, which
1999.EM must
2000be specified when referring to a destination in an external PDF file,
2001the
2002.CWB -DF \& \& \~\c
2003.CWBI dos\(hyfile > < ,
2004.CWB -MF \& \& \~\c
2005.CWBI mac\(hyfile > < ,
2006.CWB -UF \& \& \~\c
2007.CWBI unix\(hyfile > <
2008and
2009.CWB -WF \& \& \~\c
2010.CWBI win\(hyfile > <
2011options may be used to specify the location of the file
2012containing the reference destination,
2013in a variety of operating system dependent formats.
2014These options assign their arguments to the
2015.CW /DosFile ,
2016.CW /MacFile ,
2017.CW /UnixFile
2018and
2019.CW /WinFile
2020keys of the generated
2021.CW pdfmark
2022respectively; thus when any of these options are specified,
2023.EM "in addition to"
2024the
2025.CWB -F \& \& \~\c
2026.CWBI file > <
2027option, and the document is read on the appropriate operating systems,
2028then the path names specified by
2029.CWBI dos\(hyfile > < ,
2030.CWBI mac\(hyfile > < ,
2031.CWBI unix\(hyfile > <
2032and
2033.CWBI win\(hyfile > <
2034will be searched,
2035.EM instead
2036of the path name specified by
2037.CWBI file > < ,
2038for each of the
2039.CW MS\(hyDOS \*(rg,
2040.CW Apple \*(rg
2041.CW Macintosh \*(rg,
2042.CW UNIX \(tm
2043and
2044.CW MS\(hyWindows \*(rg
2045operating systems, respectively; see the
2046.pdfmark-manual ,
2047for further details.
2048.LP
2049Other than the use of these additional options,
2050which specify that the reference destination is in an external PDF file,
2051the behaviour of the
2052.CW pdfhref
2053.CWB L \& \& \(rq \(lq
2054operator, with the
2055.CWB -F \& \& \~\c
2056.CWBI file > <
2057option, remains identical to its behaviour
2058.EM without
2059this option,
2060.XR link-intern ), (
2061with respect to the interpretation of other options,
2062the handling of the
2063.CWI descriptive \& \& \~\c
2064.CWI text
2065arguments, and the formatting of the displayed reference.
2066.LP
2067Once again, since the appearance of the reference is determined by
2068factors specified in the document reference map,
2069and also by the formatting rules in effect when the reference is placed,
2070the presentation of an example of the placing of
2071a reference to an external destination will be deferred,
2072until the formatting mechanism has been explained,
2073.XR set-format ). (
2074.NH 3
2075.XN -N add-weblink -- Linking to Internet Resources
2076.LP
2077In addition to supporting the creation of cross references
2078to named destinations in PDF documents, the
2079.CW pdfhref
2080macro also has the capability to create active links to Internet resources,
2081or indeed to
2082.EM any
2083resource which may be specified by a Uniform Resource Identifier,
2084(which is usually abbreviated to the acronym \(lqURI\(rq,
2085and sometimes also referred to as a Uniform Resource Locator,
2086or \(lqURL\(rq).
2087.LP
2088Since the mechanism for creating a link to a URI differs somewhat
2089from that for creating PDF references, the
2090.CW pdfhref
2091macro is invoked with the
2092.CWB W \& \& \(rq \(lq
2093(for \(lqweb\(hylink\(rq) operator, rather than the
2094.CWB L \& \& \(rq \(lq
2095operator; nevertheless, the invocation syntax is similar, having the form
2096.QP
2097.fam C
2098.B .pdfhref
2099.B W
2100.B -D \& [
2101.BI URI >] <
2102.B -P \& [
2103.BI prefix-text >] <
2104.B -A \& [
2105.BI affixed-text >] <
2106\e
2107.br
2108\0\0\0
2109.B -- ] [
2110.I "descriptive text ...\&"
2111.LP
2112where the optional
2113.CWB -D
2114.CWBI URI > <
2115modifier specifies the address for the target Internet resource,
2116in any appropriate
2117.EM "Uniform Resource Identifier"
2118format, while the
2119.CWI descriptive
2120.CWI text
2121argument specifies the text which is to appear in the \(lqhot\(hyspot\(rq
2122region, and the
2123.CWB -P
2124.CWBI prefix\(hytext > <
2125and
2126.CWB -A
2127.CWBI affixed\(hytext > <
2128options have the same effect as in the case of local document links,
2129.XR link-intern ). (
2130.LP
2131Notice that it is not mandatory to include the
2132.CWB -D
2133.CWBI URI > <
2134in the link specification; if it
2135.EM is
2136specified, then it is not necessary for the URI to appear,
2137in the running text of the document \(em the
2138.CWI descriptive
2139.CWI text
2140argument exactly defines the text
2141which will appear within the \(lqhot\(hyspot\(rq region,
2142and this need not include the URI.
2143However, if the
2144.CWB -D \& \& \~\c
2145.CWBI URI > <
2146specification is omitted, then the
2147.CWI descriptive
2148.CWI text
2149argument
2150.EM must
2151be an
2152.EM exact
2153representation of the URI, which
2154.EM will ,
2155therefore, appear as the entire content of the \(lqhot\(hyspot\(rq.
2156For example, we could introduce a reference to
2157.pdfhref W -D \*[GROFF-WEBSITE] -A , the groff web site
2158in which the actual URI is concealed, by using mark up such as:\(en
2159.DS I
2160.CW
2161For example, we could introduce a reference to
2162\&.pdfhref W -D \*[GROFF-WEBSITE] -A , the groff web site
2163in which the actual URI is concealed,
2164.DE
2165Alternatively,
2166to refer the reader to the groff web site,
2167making it obvious that the appropriate URI is
2168.pdfhref W -A , \*[GROFF-WEBSITE]
2169the requisite mark up might be:\(en
2170.DS I
2171.CW
2172to refer the reader to the groff web site,
2173making it obvious that the appropriate URI is
2174\&.pdfhref W -A , \*[GROFF-WEBSITE]
2175the requisite mark up might be:\e(en
2176.DE
2177.NH 3
2178.XN -N set-format -- Establishing a Format for References
2179.LP
2180There are two principal aspects to be addressed,
2181when defining the format to be used when displaying references.
2182Firstly, it is desirable to provide a visual cue,
2183to indicate that the text describing the reference is imbued
2184with special properties \(em it is dynamically linked to the reference
2185destination \(em and secondly, the textual content should
2186describe where the link leads, and ideally,
2187it should also describe the content of the reference destination.
2188.LP
2189The visual cue,
2190that a text region defines a dynamically linked reference,
2191is most commonly provided by printing the text within the active
2192region in a distinctive colour.
2193This technique will be employed automatically by the
2194.CW pdfhref
2195macro \(em
2196.XR set-colour
2197\(em unless the user specifically chooses to adopt, and implement,
2198some alternative strategy.
2199.NH 4
2200.XN -N set-colour -- Using Colour to Demarcate Link Regions
2201.LP
2202Typically, when a PDF document contains
2203.EM active
2204references to other locations, either within the same document,
2205or even in other documents, or on the World Wide Web,
2206it is usually desirable to make the regions
2207where these active links are placed stand out from the surrounding text.
2208.NH 4
2209.XN -N user-format -- Specifying Reference Text Explicitly
2210.NH 4
2211.XN -N auto-format -- Using Automatically Formatted Reference Text
2212.NH 4
2213.XN -N custom-format -- Customising Automatically Formatted Reference Text
2214.LP
2215It is incumbent on the user,
2216if employing automatic formatting of the displayed reference,
2217.XR set-format ), (
2218to ensure that an appropriate reference definition
2219is created for the reference destination,
2220and is included in the reference map for the document
2221in which the reference will appear;
2222thus, it may be easiest to
2223.EM always
2224use manual formatting for external references.
2225.NH 3
2226.XN Problematic Links
2227.LP
2228Irrespective of whether a
2229.CW pdfhref
2230reference is placed using the
2231.CWB L \& \& \(rq \(lq
2232operator, or the
2233.CWB W \& \& \(rq \(lq
2234operator, there may be occasions when the resulting link
2235does function as expected.
2236A number of scenarios, which are known to be troublesome,
2237are described below.
2238.NH 4
2239.XN -N page-trap -- Links with a Page Transition in the Active Region
2240.LP
2241When a link is placed near the bottom of a page,
2242it is possible that its active region, or \(lqhot\(hyspot\(rq,
2243may extend on to the next page.
2244In this situation, a page trap macro is required
2245to intercept the page transition, and to restart the mapping of
2246the \(lqhot\(hyspot\(rq boundary on the new page.
2247.LP
2248The
2249.CW pdfmark
2250macro package includes a suitable page trap macro, to satisfy this requirement.
2251However, to avoid pre\(hyempting any other requirement the user may have for
2252a page transition trap, this is
2253.EM not
2254installed as an active page trap,
2255unless explicitly requested by the user.
2256.LP
2257To enable proper handling of page transitions,
2258which occur within the active regions of reference links,
2259the user should:\(en
2260.QS
2261.nr ITEM 0 1
2262.IP \n+[ITEM].
2263Define a page transition macro, to provide whatever features may be required,
2264when a page transition occurs \(em e.g.\& printing footnotes,
2265adding page footers and headers, etc.
2266This macro should end by setting the output position at the correct
2267vertical page offset, where the printing of running text is to restart,
2268following the page transition.
2269.IP \n+[ITEM].
2270Plant a trap to invoke this macro, at the appropriate vertical position
2271marking the end of normal running text on each page.
2272.KS
2273.IP \n+[ITEM].
2274Initialise the
2275.CW pdfhref
2276hook into this page transition trap, by invoking
2277.RS
2278.IP
2279.fam C
2280.B "pdfhref I -PT"
2281.BI macro-name > <
2282.LP
2283where
2284.CWBI macro-name > <
2285is the name of the user supplied page trap macro,
2286to ensure that
2287.CW pdfhref
2288will correctly restart mapping of active link regions,
2289at the start of each new page.
2290.KE
2291.RE
2292.QE
2293.LP
2294It may be observed that this initialisation of the
2295.CW pdfhref
2296page transition hook is, typically, required only once
2297.EM before
2298document formatting begins.
2299Users of document formatting macro packages may reasonably expect that
2300this initialisation should be performed by the macro package itself.
2301Thus, writers of such macro packages which include
2302.CW pdfmark
2303bindings, should provide appropriate initialisation,
2304so relieving the end user of this responsibility.
2305The following example, abstracted from the sample
2306.CW ms
2307binding package,
2308.CW spdf.tmac ,
2309illustrates how this may be accomplished:\(en
2310.DS I
2311.CW
2312\&.\e" groff "ms" provides the "pg@bottom" macro, which has already
2313\&.\e" been installed as a page transition trap. To ensure proper
2314\&.\e" mapping of "pdfhref" links which overflow the bottom of any
2315\&.\e" page, we need to install the "pdfhref" page transition hook,
2316\&.\e" as an addendum to this macro.
2317\&.
2318\&.pdfhref I -PT pg@bottom
2319.DE
2320.NH 2
2321.XN -N add-note -- Annotating a PDF Document using Pop-Up Notes
2322.NH 2
2323.XN -N pdfsync -- Synchronising Output and \F[C]pdfmark\F[] Contexts
2324.LP
2325It has been noted previously, that the
2326.CW pdfview
2327macro,
2328.XR docview ), (
2329the
2330.CW pdfinfo
2331macro,
2332.XR docinfo ), (
2333and the
2334.CW pdfhref
2335macro, when used to create a document outline,
2336.XR add-outline ), (
2337do not immediately write their
2338.CW pdfmark
2339output to the PostScript\*(rg data stream;
2340instead, they cache their output, in a
2341.CW groff
2342diversion, in the case of the
2343.CW pdfview
2344and
2345.CW pdfinfo
2346macros, or in an ordered collection of strings and numeric registers,
2347in the case of the document outline,
2348until a more appropriate time for copying it out.
2349In the case of
2350.CW pdfview
2351and
2352.CW pdfinfo
2353\(lqmeta\(hydata\(rq,
2354this \(lqmore appropriate time\(rq is explicitly chosen by the user;
2355in the case of document outline data,
2356.EM some
2357cached data may be implicitly written out as the document outline is compiled,
2358but there will
2359.EM always
2360be some remaining data, which must be explicitly flushed out, before the
2361.CW groff
2362formatting process is allowed to complete.
2363.LP
2364To allow the user to choose when cached
2365.CW pdfmark
2366data is to be flushed to the output stream, the
2367.CW pdfmark
2368macro package provides the
2369.CW pdfsync
2370macro, (to synchronise the cache and output states).
2371In its simplest form, it is invoked without arguments, i.e.
2372.QP
2373.fam C
2374.B .pdfsync
2375.LP
2376This form of invocation ensures that
2377.EM both
2378the \(lqmeta\(hydata cache\(rq, containing
2379.CW pdfview
2380and
2381.CW pdfinfo
2382data,
2383.EM and
2384the \(lqoutline cache\(rq,
2385containing any previously uncommitted document outline data,
2386are flushed; ideally, this should be included in a
2387.CW groff
2388\(lqend macro\(rq, to ensure that
2389.EM both
2390caches are flushed, before
2391.CW groff
2392terminates.
2393.LP
2394Occasionally,
2395it may be desirable to flush either the \(lqmeta\(hydata cache\(rq,
2396without affecting the \(lqoutline cache\(rq, or vice\(hyversa,
2397at a user specified time, prior to reaching the end of the document.
2398This may be accomplished, by invoking the
2399.CW pdfsync
2400macro with an argument, i.e.
2401.QP
2402.fam C
2403.B ".pdfsync M"
2404.LP
2405to flush only the \(lqmeta\(hydata cache\(rq, or
2406.QP
2407.fam C
2408.B ".pdfsync O"
2409.LP
2410to flush only the \(lqoutline cache\(rq.
2411.LP
2412The \(lqmeta\(hydata cache\(rq can normally be safely flushed
2413in this manner, at any time
2414.EM after
2415output of the first page has started;
2416(it may cause formatting problems,
2417most notably the appearance of unwanted white space, if flushed earlier,
2418or indeed, if flushed immediately after a page transition,
2419but before the output of the content on the new page has commenced).
2420Caution is required, however, when explicitly flushing the
2421\(lqoutline cache\(rq, since if the outline is to be
2422subsequently extended, then the first outline entry after flushing
2423.EM must
2424be specified at level 1.
4d3e9548 2425Nevertheless, such explicit flushing may occasionally be necessary;
465b256c
JR
2426for example, the
2427.CW TC
2428macro in the
2429.CW spdf.tmac
2430package,
2431.XR using-spdf ), (
2432invokes
2433.CW ".pdfsync\ O" \(rq \(lq
2434to ensure that the outline for the \(lqbody\(rq section of the document
2435is terminated,
2436.EM before
2437it commences the formatting of the table of contents section.
2438.bp
2439.NH 1
2440.XN -N pdf-layout -- PDF Document Layout
2441.LP
2442The
2443.CW pdfmark
2444macros described in the preceding section,
2445.XR pdf-features ), (
2446provide no inherent document formatting capability of their own.
2447However,
2448they may be used in conjunction with any other
2449.CW groff
2450macro package of the user's choice,
2451to add such capability.
2452.LP
2453In preparing this document, the standard
2454.CW ms
2455macro package, supplied as a component of the GNU Troff distribution,
2456has been employed.
2457To facilitate the use of the
2458.CW pdfmark
2459macros with the
2460.CW ms
2461macros,
2462a binding macro package,
2463.CW spdf.tmac ,
2464has been created.
2465The use of this binding macro package is described in the following section,
2466.XR using-spdf ); (
2467it may also serve as an example to users of other standard
2468.CW groff
2469macro packages,
2470as to how the
2471.CW pdfmark
2472macros may be employed with their chosen primary macro package.
2473.NH 2
2474.XN -N using-spdf -- Using \F[C]pdfmark\F[] Macros with the \F[C]ms\F[] Macro Package
2475.LP
2476The use of the binding macro package,
2477.CW spdf.tmac ,
2478allows for the use of the
2479.CW pdfmark
2480macros in conjunction with the
2481.CW ms
2482macros,
2483simply by issuing a
2484.CW groff
2485command of the form
2486.QP
2487.fam C
2488groff -Tps
2489.B -mspdf
2490.I "-options ...\&" ] [
2491file(s) ...
2492.LP
2493When using the
2494.CW spdf.tmac
2495package, the
2496.CW groff
2497input files may be marked up using any of the standard
2498.CW ms
2499macros to specify document formatting,
2500while PDF features may be added,
2501using any of the
2502.CW pdfmark
2503macros described previously,
2504.XR pdf-features ). (
2505Additionally,
2506.CW spdf.tmac
2507defines a number of convenient extensions to the
2508.CW ms
2509macro set, to better accomodate the use of PDF features within the
2510.CW ms
2511formatting framework,
2512and to address a number of
2513.CW ms
2514document layout issues,
2515which require special handling when producing PDF documents.
2516These additional macros,
2517and the issues they are intended to address,
2518are described below.
2519.NH 3
2520.XN \F[C]ms\F[] Section Headings in PDF Documents
2521.LP
2522Traditionally,
2523.CW ms
2524provides the
2525.CW NH
2526and
2527.CW SH
2528macros, to specify section headings.
2529However,
2530there is no standard mechanism for generating a
2531table of contents entry based on the text of the section heading;
2532neither is there any recognised standard method for establishing a
2533cross reference link to the section.
2534.LP
2535To address this
2536.CW ms
2537limitation,
2538.CW spdf.tmac
2539defines the
2540.CW XN
2541macro,
2542.XR xn-macro ), (
2543to be used in conjunction with the
2544.CW NH
2545macro.
2546.NH 4
2547.XN -N xn-macro -- The \F[C]XN\F[] Macro
2548.NH 1
2549.XN The PDF Publishing Process
2550.NH 2
2551.XN -N do-xref -- Resolving Cross References
2552.NH 3
2553.XN -N create-map -- Creating a Document Reference Map
2554.NH 3
2555.XN -N import-map -- Deploying a Document Reference Map
2556.TC