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