5 File position: <groff-source>/contrib/pdfmark/pdfmark.ms
7 This file is part of groff, the GNU roff type-setting system.
9 Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
10 written by Keith Marshall <keith.d.marshall@ntlworld.com>
12 Permission is granted to copy, distribute and/or modify this document
13 under the terms of the GNU Free Documentation License, Version 1.1 or
14 any later version published by the Free Software Foundation; with no
15 Front-Cover Texts, no Back-Cover Texts, and the following Invariant
18 a) This "Legal Matters" section, extending from the start of
19 the document, to the end of the enclosing ".ig" section.
21 b) The two lines below starting with `.AU' and `.AI'.
23 A copy of the Free Documentation License is included as a file called
24 FDL in the main directory of the groff source package.
28 Portable Document Format
29 Publishing with GNU Troff
31 .AI <keith.d.marshall@ntlworld.com>
34 .\" Specify the Internet address for the groff web site.
35 .\" Currently, there are two available addresses; a copy is maintained at ...
37 .ds GROFF-WEBSITE http://www.gnu.org/software/groff
39 .\" ... but the official home site is at ...
41 .ds GROFF-WEBSITE http://groff.ffii.org
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.
46 .pdfview /PageMode /UseOutlines
48 .\" Initialise the outline view to show only three heading levels,
49 .\" with additional subordinate level headings folded.
51 .nr PDFOUTLINE.FOLDLEVEL 3
53 .\" Add document identification meta-data
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
60 .\" Set the default cross reference format to indicate section numbers,
61 .\" rather than page numbers, when we insert a reference pointer.
63 .ds PDFHREF.INFO section \\*[SN-NO-DOT] \\$*
65 .\" Define a macro, to print reference links WITHOUT the usual "see" prefix.
75 .\" to insert a Registered Trade Mark symbol as a superscript.
79 .\" Establish the page layout.
88 .\" Generate headers in larger point sizes, for NH levels < 4,
89 .\" with point size increasing by 1.5p, for each lesser NH level.
95 .\".I "\s'+0.3'\\$1\s0" "\\$2" "\\$3"
99 \\$5\fC\\$3\fP\f(CB\\$1\fP\fC\\$2\fP\\$4
102 \\$5\fC\\$3\fP\f(CI\\$1\fP\fC\\$2\fP\\$4
105 \\$5\fC\\$3\fP\f[CBI]\\$1\fP\fC\\$2\fP\\$4
107 .ds = \f(CB\\$1\f(CR\\$4\f[CBI]\\$2\f(CR\\$3
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.
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.
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.
131 .\" If using an old s.tmac, without the SN-NO-DOT extension,
132 .\" make sure we get SOMETHING in section number references.
134 .if !dSN-NO-DOT .als SN-NO-DOT SN
136 It might appear that it is a fairly simple matter to
137 produce documents in Adobe\*(rg\~\(lqPortable\~Document\~Format\(rq,
138 commonly known as PDF, using
139 .CW groff ) GNU\~Troff\~(
140 as the document formatter.
143 default output format is the native Adobe\*(rg\~PostScript\*(rg format,
144 which PDF producers such as Adobe\*(rg Acrobat\*(rg Distiller\*(rg,
145 or GhostScript, expect as their input format.
146 Thus, the PDF production process would seem to entail simply
147 formatting the document source with
149 to produce a PostScript\*(rg version of the document,
150 which can subsequently be processed by Acrobat\*(rg Distiller\*(rg
151 or GhostScript, to generate the final PDF document.
153 For many PDF production requirements,
154 the production cycle described above may be sufficient.
155 However, this is a limited PDF production method,
156 in which the resultant PDF document represents no more than
157 an on screen image of the printed form of the document, if
159 PostScript\*(rg output were printed directly.
161 The Portable Document Format provides a number of features,
162 which significantly enhance the experience of reading a document on screen,
163 but which are of little or no value to a document which is merely printed.
166 possible to exploit these PDF features, which are described in the Adobe\*(rg
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
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 "\~").
178 .pdfhref W -D http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/pdfmarkReference.pdf \
179 -P \(lq -A \(rq\\$1 -- pdfmark\~Reference\~Manual
182 with some refinement of the simple PDF production method, provided
183 appropriate \(lqfeature implementing\(rq instructions can be embedded into
185 PostScript\*(rg rendering of the document.
186 This, of course, implies that the original document source, which
188 will process to generate the PostScript\*(rg description of the document,
189 must include appropriate markup to exploit the desired PDF features.
190 It is this preparation of the
192 document source to exploit a number of these features,
193 which provides the principal focus of this document.
195 The markup techniques to be described have been utilised in the production of
196 the PDF version of this document itself.
197 This has been formatted using
201 thus, usage examples may be found in the document source file,
203 to which comments have been added,
204 to help identify appropriate markup examples for implementing PDF features,
208 Selecting a default document view, which defines how the document will appear
209 when opened in the reader application; for example, when this document is
210 opened in Acrobat\*(rg\~Reader, it should display the top of the cover sheet,
211 in the document view pane, while a document outline should appear to the left,
212 in the \(lqBookmarks\(rq pane.
214 Adding document identification \(lqmeta\(hydata\(rq,
215 which can be accessed, in Acrobat\*(rg\~Reader,
216 by inspecting the \(lqFile\^/\^Document\~Properties\^/\^Summary\(rq.
218 Creating a document outline, which will be displayed in the \(lqBookmarks\(rq
219 pane of Acrobat\*(rg\~Reader, such that readers may quickly navigate to any
220 section of the document, simply by clicking on the associated heading
223 Embedding active links in the body of the document, such that readers may
224 quickly navigate to related material at another location within the same
225 document, or in another PDF document, or even to a related Internet resource,
226 specified by its URI.
228 Adding annotations, in the form of \(lqsticky notes\(rq, at strategic
229 points within the PDF document.
232 All of the techniques described have been tested on
234 GNU/Linux, and on Microsoft\*(rg Windows\(tm2000 operating platforms, using
237 .pdfhref L -D footnote1 -- \**
240 Later versions should, and some earlier versions may, be equally suitable.
242 .pdfhref W \*[GROFF-WEBSITE]
243 for information and availability of the latest version.
249 .pdfhref L -D footnote2 -- \**
252 Again, other versions may be suitable.
254 .pdfhref W http://ghostscript.com
255 for information and availability.
257 Other tools employed, which should be readily available on
262 or GNU/Linux system, are
267 together with an appropriate text editor, for creating and marking up the
270 These additional utilities are not provided, as standard,
271 on the Microsoft\*(rg Windows\(tm platform,
272 but several third party implementations are available.
273 Some worth considering include the MKS\*(rg\~Toolkit,\**
275 A commercial offering; see
276 .pdfhref W http://mkssoftware.com/products/tk/default.asp
287 emulation environment and
291 toolkit for 32\(hybit Microsoft\*(rg Windows\(tm platforms; see
292 .pdfhref W http://cygwin.com
293 for information and download.
297 Another free, but minimal suite of common
301 tools for 32\(hybit Microsoft\*(rg Windows\(tm, available for download from
302 .pdfhref W -A ; http://www.mingw.org
305 include those tools listed above,
306 and is the package which was actually used when performing the Windows\(tm2000
307 platform tests referred to in the text.
309 This list is by no means exhaustive, and should in no way be construed as an
310 endorsement of any of these packages, nor to imply that other similar packages,
311 which may be available, are in any way inferior to them.
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).
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.
325 .XN -N pdf-features -- Exploiting PDF Document Features
327 To establish a consistent framework for adding PDF features, a
332 Thus, to incorporate PDF features in a document,
333 the appropriate macro calls, as described below, may be placed in the
335 document source, which should then be processed with a
344 .I "file ..." \& "...] "
346 It may be noted that the
348 macros have no dependencies on, and no known conflicts with,
351 macro package; thus, users are free to use any other macro package,
352 of their choice, to format their documents, while also using the
354 macros to add PDF features.
356 .XN -N pdfmark-operator -- The \F[C]pdfmark\F[] Operator
358 All PDF features are implemented by embedding instances of the
360 operator, as described in the Adobe\*(rg
364 PostScript\*(rg output stream.
365 To facilitate the use of this operator, the
367 macro package defines the primitive
369 macro; it simply emits its argument list,
372 operator, in the PostScript\*(rg output stream.
374 .pdfhref M -N pdfmark-example
375 To illustrate the use of the
377 macro, the following is a much simplified example of how a bookmark
378 may be added to a PDF document outline
385 /Title (An Example of a Bookmark with Two Children) \e
386 /View [/FitH \en[PDFPAGE.Y]] \e
390 In general, users should rarely need to use the
393 In particular, the above example is too simple for general use; it
395 create a bookmark, but it does
397 address the issues of setting the proper value for the
399 key, nor of computing the
405 macro package includes a more robust mechanism for creating bookmarks,
407 .\" Here is an example of how a local reference may be planted,
408 .\" using the automatic formatting feature of the "pdfhref" macro.
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.
416 .pdfhref L -P ( -A ), -D add-outline
418 which addresses these issues automatically.
421 macro may be useful to users wishing to implement more advanced PDF features,
422 than those currently supported directly by the
426 .XN -N docview -- Selecting an Initial Document View
429 when a PDF document is opened,
430 the first page will be displayed,
431 at the default magnification set for the reader,
432 and outline and thumbnail views will be hidden.
433 When using a PDF reader,
434 such as Acrobat\*(rg\~Reader,
440 these default initial view settings may be overridden,
446 .CW ".pdfview /PageMode /UseOutlines"
448 will cause Acrobat\*(rg\~Reader to open the document outline view,
449 to the left of the normal page view,
452 .CW ".pdfview /PageMode /UseThumbs"
454 will open the thumbnail view instead.
458 examples, above, are mutually exclusive \(em it is not possible to have
460 outline and thumbnail views open simultaneously.
467 keys, to force the document to open at a page other than the first,
468 or to change the magnification at which the document is initially displayed;
471 for more information.
473 It should be noted that the view controlling meta\(hydata, defined by the
475 macro, is not written immediately to the PostScript\*(rg output stream,
476 but is stored in an internal meta\(hydata \(lqcache\(rq,
477 (simply implemented as a
480 This \(lqcached\(lq meta\(hydata must be written out later, by invoking the
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 ).
493 .XN -N docinfo -- Adding Document Identification Meta-Data
497 class of meta\(hydata described above,
499 we may also wish to include document identification meta\(hydata,
500 which belongs to the PDF
504 To do this, we use the
507 As an example of how it is used,
508 the identification meta\(hydata attached to this document
509 was specified using a macro sequence similar to:\(en
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
519 macro is repeated, once for each
521 record to be placed in the document.
522 In each case, the first argument is the name of the applicable
526 be named with an initial solidus character;
527 all additional arguments are collected together,
528 to define the value to be associated with the specified key.
530 As is the case with the
536 records specified with the
538 macro are not immediately written to the PostScript\*(rg output stream;
539 they are stored in the same meta\(hydata cache as
541 specifications, until this cache is explicitly flushed,
547 .XN -N add-outline -- Creating a Document Outline
549 A PDF document outline comprises a table of references,
550 to \(lqbookmarked\(rq locations within the document.
551 When the document is viewed in an \(lqoutline\~aware\(rq PDF document reader,
552 such as Adobe\*(rg Acrobat\*(rg Reader,
553 this table of \(lqbookmarks\(rq may be displayed in a document outline pane,
554 or \(lqBookmarks\(rq pane, to the left of the main document view.
555 Individual references in the outline view may then be selected,
556 by clicking with the mouse,
557 to jump directly to the associated marked location in the document view.
559 The document outline may be considered as a collection of \(lqhypertext\(rq
560 references to \(lqbookmarked\(rq locations within the document.
563 macro package provides a single generalised macro,
565 for creating and linking to \(lqhypertext\(rq reference marks.
566 This macro will be described more comprehensively in a later section,
568 the description here is restricted to its use for defining document outline entries.
570 .XN -N basic-outline -- A Basic Document Outline
572 In its most basic form, the document outline comprises a structured list of headings,
573 each associated with a marked location, or \(lqbookmark\(rq, in the document text,
574 and a specification for how that marked location should be displayed,
575 when this bookmark is selected.
577 To create a PDF bookmark, the
580 at the point in the document where the bookmark is to be placed,
586 .I "descriptive text ..."
588 in which the reference class
589 .CWB O \& \& \(rq \(lq
590 stipulates that this is an outline reference.
592 Alternatively, for those users who may prefer to think of a document outline
593 simply as a collection of bookmarks, the
595 macro is also provided \(em indeed,
597 invokes it, when processing the
598 .CWB O \& \& \(rq \(lq
599 reference class operator.
600 It may be invoked directly, in the form
605 .I "descriptive text ..."
607 Irrespective of which of the above macro forms is employed, the
609 argument is required.
610 It is a numeric argument, defining the nesting level of the \(lqbookmark\(rq
611 in the outline hierarchy, with one being the topmost level.
612 Its function may be considered analagous to the
614 of the document's section headings,
615 for example, as specified with the
619 macros to format the document.
621 All further arguments, following the
623 argument, are collected together, to specify the heading text which will appear
624 in the document's outline view.
625 Thus, the outline entry for this section of this document,
626 which has a level three heading,
627 might be specified as
630 \&.pdfhref O 3 \*(SN A Basic Document Outline
632 or, in the alternative form using the
637 \&.pdfbookmark 3 \*(SN A Basic Document Outline
639 .XN Hierarchical Structure in a Document Outline
641 When a document outline is created, using the
643 macro as described in
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
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".
657 . ie '\\$1'section' \{\
658 . if !dSECREF.BEGIN .ds SECREF.BEGIN \\$1
659 . ds PDFHREF.TEXT \\*[SECREF.BEGIN]\~\\$2
666 .\" We now tell "pdfhref" to use our formatting macro, in place of
667 .\" its builtin default formatter, before we specify the reference.
670 .pdfhref L -A , -D basic-outline
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.
677 and any entry is added at a nesting level greater than one,
678 then a hierarchical structure is automatically defined for the outline.
679 However, as was noted in the simplified
680 .pdfhref L -D pdfmark-example -- example
682 .pdfhref L -A , -D pdfmark-operator
684 .\" And now, we revert to default "pdfhref" formatting behaviour,
685 .\" by completing the call we delayed above.
689 the data required by the
691 operator to create the outline entry may not be fully defined,
692 when the outline reference is defined in the
695 Specifically, when the outline entry is created, its
697 key must be assigned a value equal to the number of its subordinate entries,
698 at the next inner level of the outline hierarchy;
700 these subordinate entries will be defined
702 in the document source, and the appropriate
704 value will be unknown, when defining the parent entry.
706 To resolve this paradox, the
708 macro creates the outline entry in two distinct phases \(em
709 a destination marker is placed in the PostScript\*(rg output stream immediately,
710 when the outline reference is defined,
711 but the actual outline entry is stored in an internal \(lqoutline cache\(rq,
712 until its subordinate hierarchy has been fully defined;
713 it can then be inserted in the output stream, with its
715 value correctly assigned.
716 Effectively, to ensure integrity of the document outline structure,
717 this means that each top level outline entry, and
719 of its subordinates, are retained in the cache, until the
721 top level entry is defined.
723 One potential problem, which arises from the use of the \(lqoutline cache\(rq,
724 is that, at the end of any document formatting run, the last top level outline entry,
725 and any subordinates defined after it, will remain in the cache, and will
727 be automatically written to the output stream.
728 To avoid this problem, the user should follow the guidelines given in
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
737 .pdfhref L -D pdfsync -A ,
740 to synchronise the output state with the cache state,
746 .XN -N outline-view -- Associating a Document View with an Outline Reference
748 Each \(lqbookmark\(rq entry, in a PDF document outline,
749 is associated with a specific document view.
750 When the reader selects any outline entry,
751 the document view changes to display the document context
752 associated with that entry.
754 The document view specification,
755 to be associated with any document outline entry,
756 is established at the time when the outline entry is created.
757 However, rather than requiring that each individual use of the
759 macro, to create an outline entry,
760 should include its own view specification,
761 the actual specification assigned to each entry is derived from
762 a generalised specification defined in the string
763 .CW PDFBOOKMARK.VIEW ,
764 together with the setting of the numeric register
765 .CW PDFHREF.VIEW.LEADING ,
766 which determine the effective view specification as follows:\(en
768 .IP \*[= PDFBOOKMARK.VIEW]
769 Establishes the magnification at which the document will be viewed,
770 at the location of the \(lqbookmark\(rq; by default, it is defined by
773 .CW ".ds PDFBOOKMARK.VIEW /FitH \e\en[PDFPAGE.Y] u"
776 which displays the associated document view,
777 with the \(lqbookmark\(rq location positioned at the top of the display window,
778 and with the magnification set to fit the page width to the width of the window.
779 .IP \*[= PDFHREF.VIEW.LEADING]
780 Specifies additional spacing,
781 to be placed between the top of the display window
782 and the actual location of the \(lqbookmark\(rq on the displayed page view.
783 By default, it is set as
786 .CW ".nr PDFHREF.VIEW.LEADING 5.0p"
790 .CW PDFHREF.VIEW.LEADING
791 does not represent true \(lqleading\(rq, in the typographical sense,
792 since any preceding text, set in the specified display space,
793 will be visible at the top of the document viewing window,
794 when the reference is selected.
796 Also note that the specification of
797 .CW PDFHREF.VIEW.LEADING
800 reference views defined by the
804 is applied exclusively to outline references,
805 there is no independent
806 .CW PDFBOOKMARK.VIEW.LEADING
810 If desired, the view specification may be changed, by redefining the string
811 .CW PDFBOOKMARK.VIEW ,
812 and possibly also the numeric register
813 .CW PDFHREF.VIEW.LEADING .
814 Any alternative definition for
817 be specified in terms of valid view specification parameters,
818 as described in the Adobe\*(rg
821 Note the use of the register
823 in the default definition of
826 This register is computed by
828 when creating an outline entry;
829 it specifies the vertical position of the \(lqbookmark\(rq,
832 units, relative to the
834 edge of the document page on which it is defined,
835 and is followed, in the
840 operator, to convert it to PostScript\*(rg units on output.
841 It may be used in any redefined specification for
842 .CW PDFBOOKMARK.VIEW ,
843 (or in the analogous definition of
846 .XR-NO-PREFIX pdfhref-view ),
849 in any other context,
850 since its value is undefined outside the scope of the
856 is computed relative to the
858 of the PDF output page,
859 it is important to ensure that the page length specified to
861 correctly matches the size of the logical PDF page.
862 This is most effectively ensured,
865 page size specifications to
868 and to the PostScript\*(rg to PDF converter employed,
869 and avoiding any page length changes within the document source.
873 is the only automatically computed \(lqbookmark\(rq location parameter;
874 if the user redefines
875 .CW PDFBOOKMARK.VIEW ,
876 and the modified view specification requires any other positional parameters,
879 ensure that these are computed
885 .XN -N outline-folding -- Folding the Outline to Conceal Less Significant Headings
887 When a document incorporates many subheadings,
888 at deeply nested levels,
889 it may be desirable to \(lqfold\(rq the outline
890 such that only the major heading levels are initially visible,
891 yet making the inferior subheadings accessible,
892 by allowing the reader to expand the view of any heading branch on demand.
896 macros support this capability,
897 through the setting of the
898 .CW PDFOUTLINE.FOLDLEVEL
900 This register should be set to the number of heading levels
901 which it is desired to show in expanded form, in the
903 document outline display;
904 all subheadings at deeper levels will still be added to the outline,
905 but will not become visible until the outline branch containing them is expanded.
907 For example, the setting used in this document:
911 \&.\e" Initialise the outline view to show only three heading levels,
912 \&.\e" with additional subordinate level headings folded.
914 \&.nr PDFOUTLINE.FOLDLEVEL 3
918 results in only the first three levels of headings being displayed
919 in the document outline,
921 the reader chooses to expand the view,
922 and so reveal the lower level headings in any outline branch.
924 The initial default setting of
925 .CW PDFOUTLINE.FOLDLEVEL ,
926 if the document author does not choose to change it,
928 This is orders of magnitude greater than the maximum heading level
929 which is likely to be used in any document;
930 thus the default behaviour will be to show document outlines fully expanded,
931 to display all headings defined,
932 at all levels within each document.
935 .CW PDFOUTLINE.FOLDLEVEL
936 may be changed at any time;
937 however, the effect of each such change may be difficult to predict,
938 since it is applied not only to outline entries which are defined
940 the setting is changed,
941 but also to any entries which remain in the outline cache,
944 Therefore, it is recommended that
945 .CW PDFOUTLINE.FOLDLEVEL
948 at the start of each document;
951 deemed necessary to change it at any other time,
952 the outline cache should be flushed,
956 which should immediately preceed a level one heading.
958 .XN -N multipart-outline -- Outlines for Multipart Documents
960 When a document outline is created, using the
962 macro, each reference mark is automatically assigned a name,
963 composed of a fixed stem followed by a serially generated numeric qualifier.
964 This ensures that, for each single part document, every outline reference
965 has a uniquely named destination.
967 As the overall size of the PDF document increases,
968 it may become convenient to divide it into smaller,
969 individually formatted PostScript\*(rg components,
970 which are then assembled, in the appropriate order,
971 to create a composite PDF document.
972 While this strategy may simplify the overall process of creating and
973 editing larger documents, it does introduce a problem in creating
974 an overall document outline,
975 since each individual PostScript\*(rg component will be assigned
976 duplicated sequences of \(lqbookmark\(rq names,
977 with each name ultimately referring to multiple locations in the composite document.
978 To avoid such reference naming conflicts, the
980 macro allows the user to specify a \(lqtag\(rq,
981 which is appended to the automatically generated \(lqbookmark\(rq name;
982 this may be used as a discriminating mark, to distinguish otherwise
983 similarly named destinations, in different sections of the composite document.
985 To create a \(lqtagged\(rq document outline,
986 the syntax for invocation of the
988 macro is modified, by the inclusion of an optional \(lqtag\(rq specification,
990 the nesting level argument, i.e.
997 .I "descriptive text ..."
1001 argument may be composed of any characters of the user's choice;
1002 however, its initial character
1004 be any decimal digit, and ideally it should be kept short
1005 \(em one or two characters at most.
1007 By employing a different tag in each section,
1008 the user can ensure that \(lqbookmark\(rq names remain unique,
1009 throughout all the sections of a composite document.
1010 For example, when using the
1012 macro package, which adds
1014 capabilities to the standard
1018 the table of contents is collected into a separate PostScript\*(rg section
1019 from the main body of the document.
1020 In the \(lqbody\(rq section, the document outline is \(lquntagged\(rq,
1021 but in the \(lqTable\~of\~Contents\(rq section, a modified version of the
1023 macro adds an outline entry for the start of the \(lqTable\~of\~Contents\(rq,
1028 .CW ".pdfhref O -T T 1 \e\e*[TOC]"
1030 to tag the associated outline destination name with the single character suffix,
1032 Alternatively, as in the case of the basic outline,
1033 .XR basic-outline ), (
1034 this may equally well be specified as
1036 .CW ".pdfbookmark -T T 1 \e\e*[TOC]"
1038 .XN Delegation of the Outline Definition
1040 Since the most common use of a document outline
1041 is to provide a quick method of navigating through a document,
1042 using active \(lqhypertext\(rq links to chapter and section headings,
1043 it may be convenient to delegate the responsibility of creating the outline
1044 to a higher level macro, which is itself used to
1045 define and format the section headings.
1046 This approach has been adopted in the
1048 package, to be described later,
1051 When such an approach is adopted,
1052 the user will rarely, if ever, invoke the
1054 macro directly, to create a document outline.
1055 For example, the structure and content of the outline for this document
1056 has been exclusively defined, using a combination of the
1060 package, to establish the structure, and the
1064 to define the content.
1066 the responsibility for invoking the
1068 macro, to create the document outline,
1073 .XN -N pdfhref -- Adding Reference Marks and Links
1076 .ds SECREF.BEGIN Section
1077 .pdfhref L -D add-outline
1081 macro may be used to create a PDF document outline.
1082 While this is undoubtedly a powerful capability,
1083 it is by no means the only trick in the repertoire of this versatile macro.
1087 which is a contraction of \(lqPDF HyperText Reference\(rq,
1088 indicates that the general purpose of this macro is to define
1090 type of dynamic reference mark, within a PDF document.
1091 Its generalised usage syntax takes the form
1096 .I "-options ...\&" ] [
1098 .I "descriptive text ...\&" ] [
1102 represents a required single character argument,
1103 which defines the specific reference operation to be performed,
1104 and may be selected from:\(en
1107 Add an entry to the document outline.
1108 This operation has been described earlier,
1109 .XR add-outline ). (
1111 Place a \(lqnamed destination\(rq reference mark at the current output position,
1112 in the current PDF document,
1115 Specify the content of a PDF document reference dictionary entry;
1116 typically, such entries are generated automatically,
1117 by transformation of the intermediate output resulting from the use of
1119 .CWB M \& \& \(rq, \(lq
1121 .CWB -X \& \& \(rq \(lq
1124 however, it is also possible to specify such entries manually,
1125 .XR user-format ). (
1127 Insert an active link to a named destination,
1129 at the current output position in the current PDF document,
1130 such that when the reader clicks on the link text,
1131 the document view changes to show the location of the named destination.
1133 Insert an active link to a \(lqweb\(rq resource,
1134 .XR add-weblink ), (
1135 at the current output position in the current PDF document.
1136 This is effectively the same as using the
1137 .CWB L \& \& \(rq \(lq
1138 operator to establish a link to a named destination in another PDF document,
1139 .XR link-extern ), (
1140 except that in this case, the destination is specified by a
1141 \(lquniform resource identifier\(rq, or
1143 this may represent any Internet or local resource
1144 which can be specified in this manner.
1146 Specify a user defined macro, to be called by
1148 when formatting the text in the active region of a link,
1151 Define the absolute position on the physical PDF output page,
1152 where the \(lqhot\(hyspot\(rq associated with an active link is to be placed.
1153 Invoked in pairs, marking the starting and ending PDF page co\(hyordinates
1154 for each link \(lqhot\(hyspot\(rq, this operator is rarely, if ever,
1155 specified directly by the user;
1158 .CWB Z \& \& \(rq \(lq
1159 specifications are inserted automatically into the document reference map
1160 during the PDF document formatting process,
1163 Initialise support for
1168 implementation provides only one such feature which requires initialisation
1169 \(em a helper macro which must be attached to a user supplied page trap handler,
1170 in order to support mapping of reference \(lqhot\(hyspots\(rq
1171 which extend through a page transition;
1175 .XN Optional Features of the \F[C]pdfhref\F[] Macro
1177 The behaviour of a number of the
1179 macro operations can be modified,
1181 .EM "option specifiers" \(rq \(lq
1182 after the operation specifying argument,
1185 any other arguments normally associated with the operation.
1188 cases, an option is specified by an
1189 .EM "option flag" \(rq, \(lq
1190 comprising an initial hyphen,
1191 followed by one or two option identifying characters.
1197 for these options, the argument
1199 be specified, and it
1201 be separated from the preceding option flag by one or more
1206 It may be noted that this paradigm for specifying options
1207 is reminiscent of most
1211 shells; however, in the case of the
1213 macro, omission of the space separating an option flag from its argument is
1219 general purpose options supported by the
1221 macro is given below.
1222 Note that not all options are supported for all
1224 operations; the operations affected by each option are noted in the list.
1227 operations, if an unsupported option is specified,
1228 it will be silently ignored; however, this behaviour should
1231 The general purpose options, supported by the
1235 .IP \*[= -N\0 name > <]
1238 associated with a PDF reference destination
1239 to be defined independently from the following text,
1240 which describes the reference.
1241 This option affects only the
1242 .CWB M \& \& \(rq \(lq
1248 Also used exclusively with the
1249 .CWB M \& \& \(rq \(lq
1252 option causes any specified
1253 .CWI descriptive \& \& \~\c
1259 in the body text of the document,
1260 at the point where the reference mark is defined;
1264 .CWI descriptive \& \& \~\c
1268 at points where links to the reference mark are placed,
1269 and where the standard reference display format,
1272 .IP \*[= -D\0 dest > <]
1275 or the destination name associated with a PDF active link,
1276 independently of the following text,
1277 which describes the link and demarcates the link \(lqhot\(hyspot\(rq.
1278 This option affects the behaviour of the
1281 .CWB L \& \& \(rq \(lq
1283 .CWB W \& \& \(rq \(lq
1287 .CWB L \& \& \(rq \(lq
1290 argument must specify a PDF \(lqnamed destination\(rq,
1294 .CWB M \& \& \(rq \(lq
1298 .CWB W \& \& \(rq \(lq
1301 must specify a link destination in the form of a
1302 \(lquniform resource identifier\(rq, or
1304 .XR add-weblink ). (
1305 .IP \*[= -F\0 file > <]
1307 .CWB L \& \& \(rq \(lq
1311 specifies an external PDF file in which the named destination
1312 for the link reference is defined.
1315 be specified with the
1316 .CWB L \& \& \(rq \(lq
1318 to create a link to a destination in a different PDF document;
1320 .CWB L \& \& \(rq \(lq
1323 this option, the link destination is assumed to be defined
1324 within the same document.
1325 .IP \*[= -P\0 \(dqprefix\(hytext\(dq > <]
1327 .CWI \(dqprefix\(hytext\(dq > <
1328 to be attached to the
1330 of the text describing an active PDF document link,
1331 with no intervening space, but without itself being included in the
1332 active area of the link \(lqhot\(hyspot\(rq;
1333 it is effective with the
1334 .CWB L \& \& \(rq \(lq
1336 .CWB W \& \& \(rq \(lq
1340 Typically, this option would be used to insert punctuation before
1341 the link \(lqhot\(hyspot\(rq.
1342 Thus, there is little reason for the inclusion of spaces in
1343 .CWI \(dqprefix\(hytext\(dq > < ;
1344 however, if such space is required, then the enclosing double quotes
1346 be specified, as indicated.
1347 .IP \*[= -A\0 \(dqaffixed\(hytext\(dq > <]
1349 .CWI \(dqaffixed\(hytext\(dq > <
1350 to be attached to the
1352 of the text describing an active PDF document link,
1353 with no intervening space, but without itself being included in the
1354 active area of the link \(lqhot\(hyspot\(rq;
1355 it is effective with the
1356 .CWB L \& \& \(rq \(lq
1358 .CWB W \& \& \(rq \(lq
1362 Typically, this option would be used to insert punctuation after
1363 the link \(lqhot\(hyspot\(rq.
1364 Thus, there is little reason for the inclusion of spaces in
1365 .CWI \(dqaffixed\(hytext\(dq > < ;
1366 however, if such space is required, then the enclosing double quotes
1368 be specified, as indicated.
1369 .IP \*[= -T\0 tag > <]
1370 When specified with the
1371 .CWB O \& \& \(rq \(lq
1374 is appended to the \(lqbookmark\(rq name assigned to the generated outline entry.
1377 to distinguish between the series of \(lqbookmark\(rq names generated in
1378 individual passes of the
1380 formatter, when the final PDF document is to be assembled
1381 from a number of separately formatted components;
1382 .XR multipart-outline ). (
1386 option is used with either the
1387 .CWB M \& \& \(rq \(lq
1388 operator, or with the
1389 .CWB L \& \& \(rq \(lq
1393 .CWB M \& \& \(rq \(lq
1396 it ensures that a cross reference record for the marked destination
1397 will be included in the document reference map,
1401 .CWB L \& \& \(rq \(lq
1404 it causes the reference to be displayed in the standard cross reference format,
1406 but substituting the
1407 .CWI descriptive \& \& \~\c
1413 for the description specified in the document reference map.
1415 Marks the end of the option specifiers.
1416 This may be used with all
1418 operations which accept options, to prevent
1420 from interpreting any following arguments as option specifiers,
1421 even if they would otherwise be interpreted as such.
1422 It is also useful when the argument list to
1424 contains special characters \(em any special character,
1425 which is not valid in a
1427 macro name, will cause a parsing error, if
1429 attempts to match it as a possible option flag;
1432 flag prevents this, so suppressing the
1434 warning message, which would otherwise ensue.
1436 Using this flag after
1438 sequences of macro options is recommended,
1439 even when it is not strictly necessary,
1440 if only for the entirely cosmetic benefit of visually separating
1441 the main argument list from the sequence of preceding options.
1446 options listed above, a supplementary set of two character options are defined.
1447 These supplementary options, listed below, are intended for use with the
1448 .CWB L \& \& \(rq \(lq
1449 operator, in conjunction with the
1452 option, to specify alternate file names,
1453 in formats compatible with the file naming conventions
1454 of alternate operating systems;
1455 they will be silently ignored, if used in any other context.
1457 The supported alternate file name options,
1458 which are ignored if the
1461 option is not specified, are:\(en
1463 .IP \*[= -DF\0 dos\(hyfile > <]
1464 Specifies the name of the file in which a link destination is defined,
1465 using the file naming semantics of the
1468 When the PDF document is read on a machine
1469 where the operating system uses the
1472 .CWI dos\(hyfile > <
1473 is used as the name of the file containing the reference destination,
1476 argument specified with the
1479 .IP \*[= -MF\0 mac\(hyfile > <]
1480 Specifies the name of the file in which a link destination is defined,
1481 using the file naming semantics of the
1485 When the PDF document is read on a machine
1486 where the operating system uses the
1489 .CWI mac\(hyfile > <
1490 is used as the name of the file containing the reference destination,
1493 argument specified with the
1496 .IP \*[= -UF\0 unix\(hyfile > <]
1497 Specifies the name of the file in which a link destination is defined,
1498 using the file naming semantics of the
1501 When the PDF document is read on a machine
1502 where the operating system uses
1504 file naming semantics, then
1505 .CWI unix\(hyfile > <
1506 is used as the name of the file containing the reference destination,
1509 argument specified with the
1512 .IP \*[= -WF\0 win\(hyfile > <]
1513 Specifies the name of the file in which a link destination is defined,
1514 using the file naming semantics of the
1515 .CW MS\(hyWindows \*(rg
1516 32\(hybit operating system.
1517 When the PDF document is read on a machine
1518 where the operating system uses any of the
1519 .CW MS\(hyWindows \*(rg
1520 file systems, with long file name support, then
1521 .CWI win\(hyfile > <
1522 is used as the name of the file containing the reference destination,
1525 argument specified with the
1530 .XN -N mark-dest -- Marking a Reference Destination
1534 macro may be used to create active links to any Internet resource,
1537 or to any \(lqnamed destination\(rq,
1538 either within the same document, or in another PDF document.
1539 Although the PDF specification allows link destinations to be defined
1540 in terms of a page number, and an associated view specification,
1541 this style of reference is not currently supported by the
1543 macro, because it is not possible to adequately bind the specification
1544 for the destination with the intended reference context.
1546 References to Internet resources are interpreted in accordance with the
1548 standard for defining a
1550 hence the only prerequisite, for creating a link to any Internet resource,
1553 be properly specified, when declaring the reference;
1554 .XR add-weblink ). (
1555 In the case of references to \(lqnamed destinations\(rq in PDF documents,
1556 however, it is necessary to provide a mechanism for creating such
1557 \(lqnamed destinations\(rq.
1558 This may be accomplished, by invoking the
1568 .I "descriptive text ...\&" ] [
1570 This creates a \(lqnamed destination\(rq reference mark, with its name specified by
1574 option is not specified, by the first word of
1575 .CWI descriptive \& \& \~\c
1577 (note that this imposes the restriction that,
1580 option is omitted, then
1583 .CWI descriptive \& \& \~\c
1587 Additionally, a reference view will be automatically defined,
1588 and associated with the reference mark,
1589 .XR pdfhref-view ), (
1591 .\" .CWI descriptive
1593 .\" is specified, or the
1596 option is specified, and no document cross reference map has been imported,
1598 then a cross reference mapping record,
1600 will be written to the
1603 this may be captured, and subsequently used to generate a cross reference map
1607 When a \(lqnamed destination\(rq reference mark is created, using the
1610 .CWB M \& \& \(rq \(lq
1611 operator, there is normally no visible effect in the formatted document; any
1612 .CWI descriptive \& \& \~\c
1614 which is specified will simply be stored in the cross reference map,
1615 for use when a link to the reference mark is created.
1616 This default behaviour may be changed, by specifying the
1618 option, which causes any specified
1619 .CWI descriptive \& \& \~\c
1621 to be \(lqechoed\(rq in the document text,
1622 at the point where the reference mark is placed,
1623 in addition to its inclusion in the cross reference map.
1625 .XN -N export-map -- Mapping a Destination for Cross Referencing
1627 Effective cross referencing of
1629 document formatted by
1631 requires multiple pass formatting.
1632 Details of how this multiple pass formatting may be accomplished,
1633 when working with the
1635 macros, will be discussed later,
1637 at this stage, the discussion will be restricted to the initial preparation,
1638 which is required at the time when the cross reference destinations are defined.
1640 The first stage, in the process of cross referencing a document,
1641 is the generation of a cross reference map.
1642 Again, the details of
1644 the cross reference map is generated will be discussed in
1645 .pdfhref F SECREF L -D do-xref -A ;
1647 however, it is important to recognise that
1649 content is included in the cross reference map is established
1650 when the reference destination is defined \(em it is derived
1651 from the reference data exported on the
1655 macro, when it is invoked with the
1656 .CWB M \& \& \(rq \(lq
1657 operator, and is controlled by whatever definition of the string
1659 is in effect, when the
1663 The initial default setting of
1667 .CW ".ds PDFHREF.INFO page \e\en% \e\e$*"
1669 which ensures that the cross reference map will contain
1670 at least a page number reference, supplemented by any
1671 .CWI descriptive \& \& \~\c
1673 which is specified for the reference mark, as defined by the
1676 .CWB M \& \& \(rq \(lq
1677 operator; this may be redefined by the user,
1678 to export additional cross reference information,
1679 or to modify the default format for cross reference links,
1682 .XN -N pdfhref-view -- Associating a Document View with a Reference Mark
1684 In the same manner as each document outline reference, defined by the
1687 .CWB O \& \& \(rq \(lq
1689 .XR add-outline ), (
1690 has a specific document view associated with it,
1691 each reference destination marked by
1694 .CWB M \& \& \(rq \(lq
1695 operator, requires an associated document view specification.
1697 The mechanism whereby a document view is associated with a reference mark
1698 is entirely analogous to that employed for outline references,
1699 .XR outline-view ), (
1702 string specification is used, in place of the
1703 .CW PDFBOOKMARK.VIEW
1705 Thus, the reference view is defined in terms of:\(en
1707 .IP \*[= PDFHREF.VIEW]
1709 establishing the position of the reference mark within the viewing window,
1710 and the magnification at which the document will be viewed,
1711 at the location of the marked reference destination;
1712 by default, it is defined by
1715 .CW ".ds PDFHREF.VIEW /FitH \e\en[PDFPAGE.Y] u"
1718 which displays the reference destination at the top of the viewing window,
1719 with the magnification set to fit the page width to the width of the window.
1720 .IP \*[= PDFHREF.VIEW.LEADING]
1722 specifying additional spacing, to be placed between the top of the display
1723 window and the actual position at which the location of the reference
1724 destination appears within the window.
1725 This register is shared with the view specification for outline references,
1726 and thus has the same default initial setting,
1729 .CW ".nr PDFHREF.VIEW.LEADING 5.0p"
1732 as in the case of outline reference views.
1735 .CW PDFHREF.VIEW.LEADING
1736 does not represent true typographic \(lqleading\(rq,
1737 since any preceding text, set in the specified display space,
1738 will be visible at the top of the viewing window,
1739 when the reference is selected.
1742 Just as the view associated with outline references may be changed,
1744 .CW PDFBOOKMARK.VIEW ,
1745 so the view associated with marked reference destinations may be changed,
1749 .CW PDFHREF.VIEW.LEADING ;
1750 such changes will become effective for all reference destinations marked
1752 these definitions are changed.
1753 (Notice that, since the specification of
1754 .CW PDFHREF.VIEW.LEADING
1755 is shared by both outline reference views and marked reference views,
1756 if it is changed, then the views for
1758 reference types are changed accordingly).
1760 It may again be noted, that the
1762 register is used in the definition of
1764 just as it is in the definition of
1765 .CW PDFBOOKMARK.VIEW ;
1767 .pdfhref F SECREF L -D outline-view
1769 relating to its use, and indeed to page position computations in general,
1770 apply equally to marked reference views and to outline reference views.
1772 .XN -N link-named -- Linking to a Marked Reference Destination
1774 Any named destination, such as those marked by the
1777 .CWB M \& \& \(rq \(lq
1778 operator, may be referred to from any point in
1780 PDF document, using an
1782 such active links are created by again using the
1784 macro, but in this case, with the
1785 .CWB L \& \& \(rq \(lq
1787 This operator provides support for two distinct cases,
1788 depending on whether the reference destination is defined in
1789 the same document as the link,
1790 .XR link-intern ), (
1791 or is defined as a named destination in a different PDF document,
1792 .XR link-extern ). (
1794 .XN -N link-intern -- References within a Single PDF Document
1796 The general syntactic form for invoking the
1799 when creating a link to a named destination within the same PDF document is
1807 .BI prefix-text >] <
1809 .BI affixed-text >] <
1815 .I "descriptive text ...\&" ] [
1819 specifies the name of the link destination,
1820 as specified using the
1822 .CWB M \& \& \(rq \(lq
1823 operation; (it may be defined either earlier in the document,
1824 to create a backward reference, or later, to create a forward reference).
1826 .\" Here's a example of how to add an iconic annotation.
1828 .\".pdfnote -T "Internal Cross References" \
1829 .\" This description is rather terse, and could benefit from \
1830 .\" the inclusion of an example.
1833 .CWI descriptive \& \& \~\c
1835 arguments are specified, then they will be inserted into the
1837 output stream, to define the text appearing in the \(lqhot\(hyspot\(rq
1839 this will be printed in the link colour specified by the string,
1840 .CW PDFHREF.TEXT.COLOUR ,
1841 which is described in
1842 .XR-NO-PREFIX set-colour .
1845 option is also specified, then the
1846 .CWI descriptive \& \& \~\c
1848 will be augmented, by prefacing it with page and section number indicators,
1849 in accordance with the reference formatting rules which are in effect,
1851 such indicators will be included within the active link region,
1852 and will also be printed in the link colour.
1858 .CWBI dest\(hyname > <
1862 .CWI descriptive \& \& \~\c
1865 .EM "but not both" ,
1869 .CWBI dest\(hyname > <
1870 option is omitted, then the first word of
1871 .CWI descriptive \& \& \~\c
1873 i.e.\~all text up to but not including the first space,
1874 will be interpreted as the
1875 .CWBI dest\(hyname > <
1876 for the link; this text will also appear in the running text of the document,
1877 within the active region of the link.
1878 Alternatively, if the
1880 .CWBI dest\(hyname > <
1884 .CWI descriptive \& \& \~\c
1887 then the running text which defines the reference,
1888 and its active region,
1889 will be derived from the reference description which is specified
1890 when the named destination is marked,
1892 and will be formatted according to the reference formatting rules
1893 which are in effect, when the reference is placed,
1895 in this case, it is not necessary to specify the
1897 option to activate automatic formatting of the reference \(em it is implied,
1898 by the omission of all
1899 .CWI descriptive \& \& \~\c
1905 .CWBI prefix\(hytext > <
1908 .CWBI affixed\(hytext > <
1909 options may be used to specify additional text
1910 which will be placed before and after the linked text respectively,
1911 with no intervening space.
1912 Such prefixed and affixed text will be printed in the normal text colour,
1913 and will not be included within the active region of the link.
1914 This feature is mostly useful for creating parenthetical references,
1915 or for placing punctuation adjacent to,
1916 but not included within,
1917 the text which defines the active region of the link.
1919 The operation of the
1921 macro, when used with its
1922 .CWB L \& \& \(rq \(lq
1923 operator to place a link to a named PDF destination,
1924 may best be illustrated by an example.
1925 However, since the appearance of the link will be influenced by
1926 factors established when the named destination is marked,
1928 and also by the formatting rules in effect when the link is placed,
1929 the presentation of a suitable exanple will be deferred,
1930 until the formatting mechanism has been explained,
1933 .XN -N link-extern -- References to Destinations in Other PDF Documents
1938 .CWB L \& \& \(rq \(lq
1939 operator is not restricted to creating reference links
1940 within a single PDF document.
1941 When the link destination is defined in a different document,
1942 then the syntactic form for invoking
1944 is modified, by the addition of options to specify the
1945 name and location of the PDF file in which the destination is defined.
1948 syntactic form becomes
1972 .BI prefix-text >] <
1974 .BI affixed-text >] <
1980 .I "descriptive text ...\&" ] [
1987 purposes: it both indicates to the
1989 macro that the specified reference destination
1990 is defined in an external PDF file,
1991 and it also specifies the normal path name,
1992 which is to be used to locate this file,
1993 when a user selects the reference.
2000 be specified when referring to a destination in an external PDF file,
2003 .CWBI dos\(hyfile > < ,
2005 .CWBI mac\(hyfile > < ,
2007 .CWBI unix\(hyfile > <
2010 .CWBI win\(hyfile > <
2011 options may be used to specify the location of the file
2012 containing the reference destination,
2013 in a variety of operating system dependent formats.
2014 These options assign their arguments to the
2020 keys of the generated
2022 respectively; thus when any of these options are specified,
2023 .EM "in addition to"
2027 option, and the document is read on the appropriate operating systems,
2028 then the path names specified by
2029 .CWBI dos\(hyfile > < ,
2030 .CWBI mac\(hyfile > < ,
2031 .CWBI unix\(hyfile > <
2033 .CWBI win\(hyfile > <
2036 of the path name specified by
2039 .CW MS\(hyDOS \*(rg,
2041 .CW Macintosh \*(rg,
2044 .CW MS\(hyWindows \*(rg
2045 operating systems, respectively; see the
2047 for further details.
2049 Other than the use of these additional options,
2050 which specify that the reference destination is in an external PDF file,
2051 the behaviour of the
2053 .CWB L \& \& \(rq \(lq
2057 option, remains identical to its behaviour
2060 .XR link-intern ), (
2061 with respect to the interpretation of other options,
2063 .CWI descriptive \& \& \~\c
2065 arguments, and the formatting of the displayed reference.
2067 Once again, since the appearance of the reference is determined by
2068 factors specified in the document reference map,
2069 and also by the formatting rules in effect when the reference is placed,
2070 the presentation of an example of the placing of
2071 a reference to an external destination will be deferred,
2072 until the formatting mechanism has been explained,
2075 .XN -N add-weblink -- Linking to Internet Resources
2077 In addition to supporting the creation of cross references
2078 to named destinations in PDF documents, the
2080 macro also has the capability to create active links to Internet resources,
2083 resource which may be specified by a Uniform Resource Identifier,
2084 (which is usually abbreviated to the acronym \(lqURI\(rq,
2085 and sometimes also referred to as a Uniform Resource Locator,
2088 Since the mechanism for creating a link to a URI differs somewhat
2089 from that for creating PDF references, the
2091 macro is invoked with the
2092 .CWB W \& \& \(rq \(lq
2093 (for \(lqweb\(hylink\(rq) operator, rather than the
2094 .CWB L \& \& \(rq \(lq
2095 operator; nevertheless, the invocation syntax is similar, having the form
2103 .BI prefix-text >] <
2105 .BI affixed-text >] <
2110 .I "descriptive text ...\&"
2115 modifier specifies the address for the target Internet resource,
2117 .EM "Uniform Resource Identifier"
2121 argument specifies the text which is to appear in the \(lqhot\(hyspot\(rq
2124 .CWBI prefix\(hytext > <
2127 .CWBI affixed\(hytext > <
2128 options have the same effect as in the case of local document links,
2129 .XR link-intern ). (
2131 Notice that it is not mandatory to include the
2134 in the link specification; if it
2136 specified, then it is not necessary for the URI to appear,
2137 in the running text of the document \(em the
2140 argument exactly defines the text
2141 which will appear within the \(lqhot\(hyspot\(rq region,
2142 and this need not include the URI.
2146 specification is omitted, then the
2153 representation of the URI, which
2155 therefore, appear as the entire content of the \(lqhot\(hyspot\(rq.
2156 For example, we could introduce a reference to
2157 .pdfhref W -D \*[GROFF-WEBSITE] -A , the groff web site
2158 in which the actual URI is concealed, by using mark up such as:\(en
2161 For example, we could introduce a reference to
2162 \&.pdfhref W -D \*[GROFF-WEBSITE] -A , the groff web site
2163 in which the actual URI is concealed,
2166 to refer the reader to the groff web site,
2167 making it obvious that the appropriate URI is
2168 .pdfhref W -A , \*[GROFF-WEBSITE]
2169 the requisite mark up might be:\(en
2172 to refer the reader to the groff web site,
2173 making it obvious that the appropriate URI is
2174 \&.pdfhref W -A , \*[GROFF-WEBSITE]
2175 the requisite mark up might be:\e(en
2178 .XN -N set-format -- Establishing a Format for References
2180 There are two principal aspects to be addressed,
2181 when defining the format to be used when displaying references.
2182 Firstly, it is desirable to provide a visual cue,
2183 to indicate that the text describing the reference is imbued
2184 with special properties \(em it is dynamically linked to the reference
2185 destination \(em and secondly, the textual content should
2186 describe where the link leads, and ideally,
2187 it should also describe the content of the reference destination.
2190 that a text region defines a dynamically linked reference,
2191 is most commonly provided by printing the text within the active
2192 region in a distinctive colour.
2193 This technique will be employed automatically by the
2197 \(em unless the user specifically chooses to adopt, and implement,
2198 some alternative strategy.
2200 .XN -N set-colour -- Using Colour to Demarcate Link Regions
2202 Typically, when a PDF document contains
2204 references to other locations, either within the same document,
2205 or even in other documents, or on the World Wide Web,
2206 it is usually desirable to make the regions
2207 where these active links are placed stand out from the surrounding text.
2209 .XN -N user-format -- Specifying Reference Text Explicitly
2211 .XN -N auto-format -- Using Automatically Formatted Reference Text
2213 .XN -N custom-format -- Customising Automatically Formatted Reference Text
2215 It is incumbent on the user,
2216 if employing automatic formatting of the displayed reference,
2218 to ensure that an appropriate reference definition
2219 is created for the reference destination,
2220 and is included in the reference map for the document
2221 in which the reference will appear;
2222 thus, it may be easiest to
2224 use manual formatting for external references.
2226 .XN Problematic Links
2228 Irrespective of whether a
2230 reference is placed using the
2231 .CWB L \& \& \(rq \(lq
2233 .CWB W \& \& \(rq \(lq
2234 operator, there may be occasions when the resulting link
2235 does function as expected.
2236 A number of scenarios, which are known to be troublesome,
2237 are described below.
2239 .XN -N page-trap -- Links with a Page Transition in the Active Region
2241 When a link is placed near the bottom of a page,
2242 it is possible that its active region, or \(lqhot\(hyspot\(rq,
2243 may extend on to the next page.
2244 In this situation, a page trap macro is required
2245 to intercept the page transition, and to restart the mapping of
2246 the \(lqhot\(hyspot\(rq boundary on the new page.
2250 macro package includes a suitable page trap macro, to satisfy this requirement.
2251 However, to avoid pre\(hyempting any other requirement the user may have for
2252 a page transition trap, this is
2254 installed as an active page trap,
2255 unless explicitly requested by the user.
2257 To enable proper handling of page transitions,
2258 which occur within the active regions of reference links,
2259 the user should:\(en
2263 Define a page transition macro, to provide whatever features may be required,
2264 when a page transition occurs \(em e.g.\& printing footnotes,
2265 adding page footers and headers, etc.
2266 This macro should end by setting the output position at the correct
2267 vertical page offset, where the printing of running text is to restart,
2268 following the page transition.
2270 Plant a trap to invoke this macro, at the appropriate vertical position
2271 marking the end of normal running text on each page.
2276 hook into this page transition trap, by invoking
2284 .CWBI macro-name > <
2285 is the name of the user supplied page trap macro,
2288 will correctly restart mapping of active link regions,
2289 at the start of each new page.
2294 It may be observed that this initialisation of the
2296 page transition hook is, typically, required only once
2298 document formatting begins.
2299 Users of document formatting macro packages may reasonably expect that
2300 this initialisation should be performed by the macro package itself.
2301 Thus, writers of such macro packages which include
2303 bindings, should provide appropriate initialisation,
2304 so relieving the end user of this responsibility.
2305 The following example, abstracted from the sample
2309 illustrates how this may be accomplished:\(en
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.
2318 \&.pdfhref I -PT pg@bottom
2321 .XN -N add-note -- Annotating a PDF Document using Pop-Up Notes
2323 .XN -N pdfsync -- Synchronising Output and \F[C]pdfmark\F[] Contexts
2325 It has been noted previously, that the
2335 macro, when used to create a document outline,
2336 .XR add-outline ), (
2337 do not immediately write their
2339 output to the PostScript\*(rg data stream;
2340 instead, they cache their output, in a
2342 diversion, in the case of the
2346 macros, or in an ordered collection of strings and numeric registers,
2347 in the case of the document outline,
2348 until a more appropriate time for copying it out.
2353 \(lqmeta\(hydata\(rq,
2354 this \(lqmore appropriate time\(rq is explicitly chosen by the user;
2355 in the case of document outline data,
2357 cached data may be implicitly written out as the document outline is compiled,
2360 be some remaining data, which must be explicitly flushed out, before the
2362 formatting process is allowed to complete.
2364 To allow the user to choose when cached
2366 data is to be flushed to the output stream, the
2368 macro package provides the
2370 macro, (to synchronise the cache and output states).
2371 In its simplest form, it is invoked without arguments, i.e.
2376 This form of invocation ensures that
2378 the \(lqmeta\(hydata cache\(rq, containing
2384 the \(lqoutline cache\(rq,
2385 containing any previously uncommitted document outline data,
2386 are flushed; ideally, this should be included in a
2388 \(lqend macro\(rq, to ensure that
2390 caches are flushed, before
2395 it may be desirable to flush either the \(lqmeta\(hydata cache\(rq,
2396 without affecting the \(lqoutline cache\(rq, or vice\(hyversa,
2397 at a user specified time, prior to reaching the end of the document.
2398 This may be accomplished, by invoking the
2400 macro with an argument, i.e.
2405 to flush only the \(lqmeta\(hydata cache\(rq, or
2410 to flush only the \(lqoutline cache\(rq.
2412 The \(lqmeta\(hydata cache\(rq can normally be safely flushed
2413 in this manner, at any time
2415 output of the first page has started;
2416 (it may cause formatting problems,
2417 most notably the appearance of unwanted white space, if flushed earlier,
2418 or indeed, if flushed immediately after a page transition,
2419 but before the output of the content on the new page has commenced).
2420 Caution is required, however, when explicitly flushing the
2421 \(lqoutline cache\(rq, since if the outline is to be
2422 subsequently extended, then the first outline entry after flushing
2424 be specified at level 1.
2425 Nevertheless, such explicit flushing may occasionally be necessary;
2433 .CW ".pdfsync\ O" \(rq \(lq
2434 to ensure that the outline for the \(lqbody\(rq section of the document
2437 it commences the formatting of the table of contents section.
2440 .XN -N pdf-layout -- PDF Document Layout
2444 macros described in the preceding section,
2445 .XR pdf-features ), (
2446 provide no inherent document formatting capability of their own.
2448 they may be used in conjunction with any other
2450 macro package of the user's choice,
2451 to add such capability.
2453 In preparing this document, the standard
2455 macro package, supplied as a component of the GNU Troff distribution,
2457 To facilitate the use of the
2462 a binding macro package,
2465 The use of this binding macro package is described in the following section,
2467 it may also serve as an example to users of other standard
2472 macros may be employed with their chosen primary macro package.
2474 .XN -N using-spdf -- Using \F[C]pdfmark\F[] Macros with the \F[C]ms\F[] Macro Package
2476 The use of the binding macro package,
2478 allows for the use of the
2480 macros in conjunction with the
2490 .I "-options ...\&" ] [
2497 input files may be marked up using any of the standard
2499 macros to specify document formatting,
2500 while PDF features may be added,
2503 macros described previously,
2504 .XR pdf-features ). (
2507 defines a number of convenient extensions to the
2509 macro set, to better accomodate the use of PDF features within the
2511 formatting framework,
2512 and to address a number of
2514 document layout issues,
2515 which require special handling when producing PDF documents.
2516 These additional macros,
2517 and the issues they are intended to address,
2518 are described below.
2520 .XN \F[C]ms\F[] Section Headings in PDF Documents
2528 macros, to specify section headings.
2530 there is no standard mechanism for generating a
2531 table of contents entry based on the text of the section heading;
2532 neither is there any recognised standard method for establishing a
2533 cross reference link to the section.
2543 to be used in conjunction with the
2547 .XN -N xn-macro -- The \F[C]XN\F[] Macro
2549 .XN The PDF Publishing Process
2551 .XN -N do-xref -- Resolving Cross References
2553 .XN -N create-map -- Creating a Document Reference Map
2555 .XN -N import-map -- Deploying a Document Reference Map