4 Copyright
(c
) 2014 Steffen
(Daode
) Nurpmeso
<sdaoden@users.sf.net
>.
6 Copyright
(C
) 2004 - 2006 Free Software Foundation
, Inc.
7 written
by Keith Marshall
<keith.d.marshall@ntlworld.com
>
9 Permission is granted
to copy
, distribute
and/or modify this document
10 under the terms
of the GNU Free Documentation License
, Version
1.1 or
11 any later version published
by the Free Software Foundation
; with no
12 Front
-Cover Texts
, no Back
-Cover Texts
, and the following Invariant
15 a
) This
"Legal Matters" section
, extending from the start
of
16 the document
, to the end
of the enclosing
".ig" section.
18 b
) The two lines below starting
with `.AU'
and `.AI'.
20 You should have received a copy
of the Free Documentation License
21 as part
of the file COPYING
; also located
in the main directory
of the
22 source package
of this program.
26 Portable Document Format
27 Publishing
with @T_ROFF@
29 .AI
<keith.d.marshall@ntlworld.com
>
32 .
\" Specify the Internet address
for our web site.
33 .
\" Currently
, there are two available addresses
; a copy is maintained
at ...
35 .ds ROFF
-WEBSITE @ROFF_WEBURL@
37 .
\" Set the PDF
default document view attribute
, to ensure that the document
38 .
\" outline is visible
, each
time the document is opened
in Acrobat Reader.
40 .pdfview
/PageMode
/UseOutlines
42 .
\" Initialise the outline view
to show only three heading levels
,
43 .
\" with additional subordinate
level headings folded.
45 .nr PDFOUTLINE.FOLDLEVEL
3
47 .
\" Add document identification meta
-data
49 .pdfinfo
/Title Portable Document Format Publishing
with @T_ROFF@
50 .pdfinfo
/Author Keith Marshall
51 .pdfinfo
/Subject Tips
and Techniques
for Exploiting PDF Features
with @T_ROFF@
52 .pdfinfo
/Keywords @T_ROFF@ @T_TROFF@ troff PDF pdfmark
54 .
\" Set the
default cross reference format
to indicate section numbers
,
55 .
\" rather than page numbers
, when we insert a reference pointer.
57 .ds PDFHREF.INFO section
\\*[SN
-NO
-DOT
] \\$
*
59 .
\" Define a macro
, to print reference links WITHOUT the usual
"see" prefix.
69 .
\" to insert a Registered Trade Mark symbol
as a superscript.
73 .
\" Establish the page layout.
82 .
\" Generate headers
in larger point sizes
, for NH levels
< 4,
83 .
\" with point size increasing
by 1.5p
, for each lesser NH
level.
89 .
\".I
"\s'+0.3'\\$1\s0" "\\$2" "\\$3"
93 \\$
5\fC
\\$
3\fP
\f(CB
\\$
1\fP
\fC
\\$
2\fP
\\$
4
96 \\$
5\fC
\\$
3\fP
\f(CI
\\$
1\fP
\fC
\\$
2\fP
\\$
4
99 \\$
5\fC
\\$
3\fP
\f[CBI
]\\$
1\fP
\fC
\\$
2\fP
\\$
4
101 .ds
= \f(CB
\\$
1\f(CR
\\$
4\f[CBI
]\\$
2\f(CR
\\$
3
104 .
\" When we use numbered section headings
, we might like
to automatically
105 .
\" insert a table
of contents entry
, using the text
of the heading itself.
106 .
\" The
"ms" macros don't provide any standard mechanism
for doing this
,
107 .
\" but
"spdf.tmac" adds the
"XN" macro
, which will
do it
for us.
109 .
\" Here's a simple example
of how we might use it. In this
case, the word
110 .
\" "Introduction" will appear both
in the body
of the document
, as the text
111 .
\" of the heading
, and it will be added
to the table
of contents
, which is
112 .
\" subsequently
"printed" using the
"TC" macro
; in both locations
, it will
113 .
\" be prefixed
by the section number.
115 .
\" As an additional side effect
, any use
of "XN" will cause the table
of
116 .
\" contents entry
to be automatically reproduced
, with the exception
of its
117 .
\" page number reference
, as a PDF document outline entry. Thus
, the use
118 .
\" of "XN" to specify numbered section headings results
in the automatic
119 .
\" creation
of a numbered PDF document outline. This automatic creation
120 .
\" of the outline is completely transparent
, and will occur regardless
121 .
\" of whether the
"TC" macro is subsequently invoked
, or not.
125 .
\" If using an old s.tmac
, without the SN
-NO
-DOT extension
,
126 .
\" make sure we get SOMETHING
in section number references.
128 .
if !dSN
-NO
-DOT .als SN
-NO
-DOT SN
130 It might appear that it is a fairly simple matter
to
131 produce documents
in Adobe\
*(rg\~\
(lqPortable\~Document\~Format\
(rq
,
132 commonly known
as PDF
, using
134 as the document formatter.
137 default output format is the native Adobe\
*(rg\~PostScript\
*(rg format
,
138 which PDF producers such
as Adobe\
*(rg Acrobat\
*(rg Distiller\
*(rg
,
139 or GhostScript
, expect
as their input format.
140 Thus
, the PDF production process would seem
to entail simply
141 formatting the document source
with
143 to produce a PostScript\
*(rg version
of the document
,
144 which can subsequently be processed
by Acrobat\
*(rg Distiller\
*(rg
145 or GhostScript
, to generate the final PDF document.
147 For many PDF production requirements
,
148 the production cycle described above may be sufficient.
149 However
, this is a limited PDF production method
,
150 in which the resultant PDF document represents no more than
151 an
on screen image
of the printed form
of the document
, if
153 PostScript\
*(rg output were printed directly.
155 The Portable Document Format provides a number
of features
,
156 which significantly enhance the experience
of reading a document
on screen
,
157 but which are
of little
or no value
to a document which is merely printed.
160 possible
to exploit these PDF features
, which are described
in the Adobe\
*(rg
163 .
\" This is an example
of a resource reference specified
by URI ...
164 .
\" We may need
to refer often
to the Adobe pdfmark Reference Manual
,
165 .
\" so we create the internet link definition using a macro
, to make
168 .
\" Note also
, that we protect the description
of the reference
by
169 .
\" preceding it
with "--", to avoid
"invalid character in name" type
170 .
\" error messages from groff
(caused
by the use
of "\~").
172 .pdfhref W
-D http
://partners.adobe.com
/public
/developer
/en
/acrobat
/sdk
/pdf
/pdf_creation_apis_and_specs
/pdfmarkReference.pdf \
173 -P \
(lq
-A \
(rq
\\$
1 -- pdfmark\~Reference\~Manual
176 with some refinement
of the simple PDF production method
, provided
177 appropriate \
(lqfeature implementing\
(rq instructions can be embedded into
179 PostScript\
*(rg rendering
of the document.
180 This
, of course
, implies that the original document source
, which
182 will process
to generate the PostScript\
*(rg description
of the document
,
183 must include appropriate markup
to exploit the desired PDF features.
184 It is this preparation
of the
186 document source
to exploit a number
of these features
,
187 which provides the principal focus
of this document.
189 The markup techniques
to be described have been utilised
in the production
of
190 the PDF version
of this document itself.
191 This has been formatted using
195 thus
, usage examples may be found
in the document source file
,
197 to which comments have been added
,
198 to help identify appropriate markup examples
for implementing PDF features
,
202 Selecting a
default document view
, which defines how the document will appear
203 when opened
in the reader application
; for example
, when this document is
204 opened
in Acrobat\
*(rg\~Reader
, it should display the top
of the cover sheet
,
205 in the document view pane
, while a document outline should appear
to the left
,
206 in the \
(lqBookmarks\
(rq pane.
208 Adding document identification \
(lqmeta\
(hydata\
(rq
,
209 which can be accessed
, in Acrobat\
*(rg\~Reader
,
210 by inspecting the \
(lqFile\^
/\^Document\~Properties\^
/\^Summary\
(rq.
212 Creating a document outline
, which will be displayed
in the \
(lqBookmarks\
(rq
213 pane
of Acrobat\
*(rg\~Reader
, such that readers may quickly navigate
to any
214 section
of the document
, simply
by clicking
on the associated heading
217 Embedding active links
in the body
of the document
, such that readers may
218 quickly navigate
to related material
at another location within the same
219 document
, or in another PDF document
, or even
to a related Internet resource
,
220 specified
by its URI.
222 Adding annotations
, in the form
of \
(lqsticky notes\
(rq
, at strategic
223 points within the PDF document.
226 All
of the techniques described have been tested
on
228 GNU
/Linux
, and on Microsoft\
*(rg Windows\
(tm2000 operating platforms
, using
231 .pdfhref L
-D footnote1
-- \**
234 Later versions should
, and some earlier versions may
, be equally suitable.
236 .pdfhref W \
*[ROFF
-WEBSITE
]
237 for information
and availability
of the latest version.
243 .pdfhref L
-D footnote2
-- \**
246 Again
, other versions may be suitable.
248 .pdfhref W http
://ghostscript.com
249 for information
and availability.
251 Other tools employed
, which should be readily available
on
256 or GNU
/Linux system
, are
261 together
with an appropriate text editor
, for creating
and marking up the
264 These additional utilities are
not provided
, as standard
,
265 on the Microsoft\
*(rg Windows\
(tm platform
,
266 but several third party implementations are available.
267 Some worth considering include the MKS\
*(rg\~Toolkit
,\
**
269 A commercial offering
; see
270 .pdfhref W http
://mkssoftware.com
/products
/tk
/default.asp
281 emulation environment
and
285 toolkit
for 32\
(hybit Microsoft\
*(rg Windows\
(tm platforms
; see
286 .pdfhref W http
://cygwin.com
287 for information
and download.
291 Another free
, but minimal suite
of common
295 tools
for 32\
(hybit Microsoft\
*(rg Windows\
(tm
, available
for download from
296 .pdfhref W
-A
; http
://www.mingw.org
299 include those tools listed above
,
300 and is the package which was actually used when performing the Windows\
(tm2000
301 platform tests referred
to in the text.
303 This list is
by no means exhaustive
, and should
in no way be construed
as an
304 endorsement
of any
of these packages
, nor
to imply that other similar packages
,
305 which may be available
, are
in any way inferior
to them.
308 .
\" We may wish a section heading
to represent a named destination
,
309 .
\" so that we can create a linked reference
to it
, from some other
310 .
\" part
of the PDF document
, (or even from another PDF document
).
312 .
\" Here we use the
"-N" option
of the
"XN" macro
, to create a named
313 .
\" PDF link destination
, at the location
of the heading. Notice that
314 .
\" we also use the
"--" marker
to separate the heading text from the
315 .
\" preceding option specification
; it is
not strictly necessary
in
316 .
\" this
case, but it does help
to set off the heading text from the
317 .
\" option specification.
319 .XN
-N pdf
-features
-- Exploiting PDF Document Features
321 To establish a consistent framework
for adding PDF features
, a
326 Thus
, to incorporate PDF features
in a document
,
327 the appropriate macro calls
, as described below
, may be placed
in the
329 document source
, which should
then be processed
with a
338 .I
"file ..." \
& "...] "
340 It may be noted that the
342 macros have no dependencies
on, and no known conflicts
with,
345 macro package
; thus
, users are free
to use any other macro package
,
346 of their choice
, to format their documents
, while also using the
348 macros
to add PDF features.
350 .XN
-N pdfmark
-operator
-- The \F[C]pdfmark\F[] Operator
352 All PDF features are implemented
by embedding instances
of the
354 operator
, as described
in the Adobe\
*(rg
358 PostScript\
*(rg output stream.
359 To facilitate the use
of this operator
, the
361 macro package defines the primitive
363 macro
; it simply emits its argument list
,
366 operator
, in the PostScript\
*(rg output stream.
368 .pdfhref M
-N pdfmark
-example
369 To illustrate the use
of the
371 macro
, the following is a much simplified example
of how a bookmark
372 may be added
to a PDF document outline
379 /Title
(An Example
of a Bookmark
with Two Children
) \e
380 /View
[/FitH \en
[PDFPAGE.Y
]] \e
384 In general
, users should rarely need
to use the
387 In particular
, the above example is too simple
for general use
; it
389 create a bookmark
, but it does
391 address the issues
of setting the proper value
for the
393 key
, nor
of computing the
399 macro package includes a more robust mechanism
for creating bookmarks
,
401 .
\" Here is an example
of how a
local reference may be planted
,
402 .
\" using the automatic formatting feature
of the
"pdfhref" macro.
404 .
\" This is a forward reference
to the named destination
"add-outline",
405 .
\" which is defined below
, using the
"XN" wrapper macro
, from the
406 .
\" "spdf.tmac" macro package. The automatically formatted reference
407 .
\" will be enclosed
in parentheses
, as specified
by the use
of
408 .
\" "-P" and "-A" options.
410 .pdfhref L
-P
( -A
), -D add
-outline
412 which addresses these issues automatically.
415 macro may be useful
to users wishing
to implement more advanced PDF features
,
416 than those currently supported directly
by the
420 .XN
-N docview
-- Selecting an Initial Document View
423 when a PDF document is opened
,
424 the first page will be displayed
,
425 at the
default magnification
set for the reader
,
426 and outline
and thumbnail views will be hidden.
427 When using a PDF reader
,
428 such
as Acrobat\
*(rg\~Reader
,
434 these
default initial view settings may be overridden
,
440 .CW
".pdfview /PageMode /UseOutlines"
442 will cause Acrobat\
*(rg\~Reader
to open the document outline view
,
443 to the left
of the normal page view
,
446 .CW
".pdfview /PageMode /UseThumbs"
448 will open the thumbnail view instead.
452 examples
, above
, are mutually exclusive \
(em it is
not possible
to have
454 outline
and thumbnail views open simultaneously.
461 keys
, to force the document
to open
at a page other than the first
,
462 or to change the magnification
at which the document is initially displayed
;
465 for more information.
467 It should be noted that the view controlling meta\
(hydata
, defined
by the
469 macro
, is
not written immediately
to the PostScript\
*(rg output stream
,
470 but is stored
in an internal meta\
(hydata \
(lqcache\
(rq
,
471 (simply implemented
as a
474 This \
(lqcached\
(lq meta\
(hydata must be written out later
, by invoking the
478 .
\" Here is another example
of how we may introduce a forward reference.
479 .
\" This
time we are using the shorter notation afforded
by the
"XR" macro
480 .
\" provided
by "spdf.tmac"; this example is equivalent
to the native
481 .
\" "pdfmark.tmac" form
482 .
\" .pdfhref L
-D pdfsync
-P
( -A
).
487 .XN
-N docinfo
-- Adding Document Identification Meta-Data
491 class
of meta\
(hydata described above
,
493 we may also wish
to include document identification meta\
(hydata
,
494 which belongs
to the PDF
498 To
do this
, we use the
501 As an example
of how it is used
,
502 the identification meta\
(hydata attached
to this document
503 was specified using a macro sequence similar
to:\
(en
506 \
&.pdfinfo
/Title PDF Document Publishing
with GNU Troff
507 \
&.pdfinfo
/Author Keith Marshall
508 \
&.pdfinfo
/Subject How
to Exploit PDF Features
with GNU Troff
509 \
&.pdfinfo
/Keywords @T_ROFF@ @T_TROFF@ PDF pdfmark
513 macro is repeated
, once
for each
515 record
to be placed
in the document.
516 In each
case, the first argument is the name
of the applicable
520 be named
with an initial solidus character
;
521 all additional arguments are collected together
,
522 to define the value
to be associated
with the specified key.
524 As is the
case with the
530 records specified
with the
532 macro are
not immediately written
to the PostScript\
*(rg output stream
;
533 they are stored
in the same meta\
(hydata cache
as
535 specifications
, until this cache is explicitly flushed
,
541 .XN
-N add
-outline
-- Creating a Document Outline
543 A PDF document outline comprises a table
of references
,
544 to \
(lqbookmarked\
(rq locations within the document.
545 When the document is viewed
in an \
(lqoutline\~aware\
(rq PDF document reader
,
546 such
as Adobe\
*(rg Acrobat\
*(rg Reader
,
547 this table
of \
(lqbookmarks\
(rq may be displayed
in a document outline pane
,
548 or \
(lqBookmarks\
(rq pane
, to the left
of the main document view.
549 Individual references
in the outline view may
then be selected
,
550 by clicking
with the mouse
,
551 to jump directly
to the associated marked location
in the document view.
553 The document outline may be considered
as a collection
of \
(lqhypertext\
(rq
554 references
to \
(lqbookmarked\
(rq locations within the document.
557 macro package provides a single generalised macro
,
559 for creating
and linking
to \
(lqhypertext\
(rq reference marks.
560 This macro will be described more comprehensively
in a later section
,
562 the description here is restricted
to its use
for defining document outline entries.
564 .XN
-N basic
-outline
-- A Basic Document Outline
566 In its most basic form
, the document outline comprises a structured list
of headings
,
567 each associated
with a marked location
, or \
(lqbookmark\
(rq
, in the document text
,
568 and a specification
for how that marked location should be displayed
,
569 when this bookmark is selected.
571 To create a PDF bookmark
, the
574 at the point
in the document
where the bookmark is
to be placed
,
580 .I
"descriptive text ..."
582 in which the reference class
583 .CWB O \
& \
& \
(rq \
(lq
584 stipulates that this is an outline reference.
586 Alternatively
, for those users who may prefer
to think
of a document outline
587 simply
as a collection
of bookmarks
, the
589 macro is also provided \
(em indeed
,
591 invokes it
, when processing the
592 .CWB O \
& \
& \
(rq \
(lq
593 reference class operator.
594 It may be invoked directly
, in the form
599 .I
"descriptive text ..."
601 Irrespective
of which
of the above macro forms is employed
, the
603 argument is required.
604 It is a numeric argument
, defining the nesting
level of the \
(lqbookmark\
(rq
605 in the outline hierarchy
, with one being the topmost
level.
606 Its
function may be considered analagous
to the
608 of the document's section headings
,
609 for example
, as specified
with the
613 macros
to format the document.
615 All further arguments
, following the
617 argument
, are collected together
, to specify the heading text which will appear
618 in the document's outline view.
619 Thus
, the outline entry
for this section
of this document
,
620 which has a
level three heading
,
621 might be specified
as
624 \
&.pdfhref O
3 \
*(SN A Basic Document Outline
626 or, in the alternative form using the
631 \
&.pdfbookmark
3 \
*(SN A Basic Document Outline
633 .XN Hierarchical Structure
in a Document Outline
635 When a document outline is created
, using the
637 macro
as described
in
639 .
\" Here is an example
of how we can temporarily modify the format
of
640 .
\" a reference link
, in this
case to indicate only the section number
641 .
\" of the link target
, in the form
"section #", (or, if we define
642 .
\" "SECREF.BEGIN" before the call
, its content followed
by the
645 .
\" We first define a macro
, which will get the reference data from
646 .
\" pdfhref
, as arguments
, and will
return the formatted output
, as we
647 .
\" require it
, the string
"PDFHREF.TEXT".
651 . ie '
\\$
1'section' \
{\
652 .
if !dSECREF.BEGIN .ds SECREF.BEGIN
\\$
1
653 . ds PDFHREF.TEXT
\\*[SECREF.BEGIN
]\~
\\$
2
660 .
\" We now tell
"pdfhref" to use our formatting macro
, in place
of
661 .
\" its builtin
default formatter
, before we specify the reference.
664 .pdfhref L
-A
, -D basic
-outline
666 .
\" At this point
, we would normally revert the
"pdfhref" formatter
667 .
\" to use its
default, built
in macro. However
, in this particular
668 .
\" case, we want
to use our custom format one more
time, before we
669 .
\" revert it
, so we will omit the reversion step this
time.
671 and any entry is added
at a nesting
level greater than one
,
672 then a hierarchical structure is automatically defined
for the outline.
673 However
, as was noted
in the simplified
674 .pdfhref L
-D pdfmark
-example
-- example
676 .pdfhref L
-A
, -D pdfmark
-operator
678 .
\" And now
, we revert
to default "pdfhref" formatting behaviour
,
679 .
\" by completing the call we delayed above.
683 the data required
by the
685 operator
to create the outline entry may
not be fully defined
,
686 when the outline reference is defined
in the
689 Specifically
, when the outline entry is created
, its
691 key must be assigned a value equal
to the number
of its subordinate entries
,
692 at the next inner
level of the outline hierarchy
;
694 these subordinate entries will be defined
696 in the document source
, and the appropriate
698 value will be unknown
, when defining the
parent entry.
700 To resolve this paradox
, the
702 macro creates the outline entry
in two distinct phases \
(em
703 a destination marker is placed
in the PostScript\
*(rg output stream immediately
,
704 when the outline reference is defined
,
705 but the actual outline entry is stored
in an internal \
(lqoutline cache\
(rq
,
706 until its subordinate hierarchy has been fully defined
;
707 it can
then be inserted
in the output stream
, with its
709 value correctly assigned.
710 Effectively
, to ensure integrity
of the document outline structure
,
711 this means that each top
level outline entry
, and
713 of its subordinates
, are retained
in the cache
, until the
715 top
level entry is defined.
717 One potential problem
, which arises from the use
of the \
(lqoutline cache\
(rq
,
718 is that
, at the end
of any document formatting run
, the last top
level outline entry
,
719 and any subordinates defined after it
, will remain
in the cache
, and will
721 be automatically written
to the output stream.
722 To avoid this problem
, the user should follow the guidelines given
in
724 .
\" Here is a more conventional example
of how
to temporarily change
725 .
\" to the format used
to display reference links. We will again use
726 .
\" the
"SECREF" format
, which we defined above
, but
on this occasion
727 .
\" we will immediately revert
to the
default format
, after the link
731 .pdfhref L
-D pdfsync
-A
,
734 to synchronise the output state
with the cache state
,
740 .XN
-N outline
-view
-- Associating a Document View with an Outline Reference
742 Each \
(lqbookmark\
(rq entry
, in a PDF document outline
,
743 is associated
with a specific document view.
744 When the reader selects any outline entry
,
745 the document view changes
to display the document context
746 associated
with that entry.
748 The document view specification
,
749 to be associated
with any document outline entry
,
750 is established
at the
time when the outline entry is created.
751 However
, rather than requiring that each individual use
of the
753 macro
, to create an outline entry
,
754 should include its own view specification
,
755 the actual specification assigned
to each entry is derived from
756 a generalised specification defined
in the string
757 .CW PDFBOOKMARK.VIEW
,
758 together
with the setting
of the numeric register
759 .CW PDFHREF.VIEW.LEADING
,
760 which determine the effective view specification
as follows
:\
(en
762 .IP \
*[= PDFBOOKMARK.VIEW
]
763 Establishes the magnification
at which the document will be viewed
,
764 at the location
of the \
(lqbookmark\
(rq
; by default, it is defined
by
767 .CW
".ds PDFBOOKMARK.VIEW /FitH \e\en[PDFPAGE.Y] u"
770 which displays the associated document view
,
771 with the \
(lqbookmark\
(rq location positioned
at the top
of the display window
,
772 and with the magnification
set to fit the page width
to the width
of the window.
773 .IP \
*[= PDFHREF.VIEW.LEADING
]
774 Specifies additional spacing
,
775 to be placed between the top
of the display window
776 and the actual location
of the \
(lqbookmark\
(rq
on the displayed page view.
777 By
default, it is
set as
780 .CW
".nr PDFHREF.VIEW.LEADING 5.0p"
784 .CW PDFHREF.VIEW.LEADING
785 does
not represent
true \
(lqleading\
(rq
, in the typographical sense
,
786 since any preceding text
, set in the specified display space
,
787 will be visible
at the top
of the document viewing window
,
788 when the reference is selected.
790 Also note that the specification
of
791 .CW PDFHREF.VIEW.LEADING
794 reference views defined
by the
798 is applied exclusively
to outline references
,
799 there is no independent
800 .CW PDFBOOKMARK.VIEW.LEADING
804 If desired
, the view specification may be changed
, by redefining the string
805 .CW PDFBOOKMARK.VIEW
,
806 and possibly also the numeric register
807 .CW PDFHREF.VIEW.LEADING .
808 Any alternative definition
for
811 be specified
in terms
of valid view specification
parameters,
812 as described
in the Adobe\
*(rg
815 Note the use
of the register
817 in the
default definition
of
820 This register is computed
by
822 when creating an outline entry
;
823 it specifies the vertical position
of the \
(lqbookmark\
(rq
,
826 units
, relative
to the
828 edge
of the document page
on which it is defined
,
829 and is followed
, in the
834 operator
, to convert it
to PostScript\
*(rg units
on output.
835 It may be used
in any redefined specification
for
836 .CW PDFBOOKMARK.VIEW
,
837 (or in the analogous definition
of
840 .XR
-NO
-PREFIX pdfhref
-view
),
843 in any other context
,
844 since its value is
undefined outside the scope
of the
850 is computed relative
to the
852 of the PDF output page
,
853 it is important
to ensure that the page length specified
to
855 correctly matches the size
of the logical PDF page.
856 This is most effectively ensured
,
859 page size specifications
to
862 and to the PostScript\
*(rg
to PDF converter employed
,
863 and avoiding any page length changes within the document source.
867 is the only automatically computed \
(lqbookmark\
(rq location parameter
;
868 if the user redefines
869 .CW PDFBOOKMARK.VIEW
,
870 and the modified view specification requires any other positional
parameters,
873 ensure that these are computed
879 .XN
-N outline
-folding
-- Folding the Outline to Conceal Less Significant Headings
881 When a document incorporates many subheadings
,
882 at deeply nested levels
,
883 it may be desirable
to \
(lqfold\
(rq the outline
884 such that only the major heading levels are initially visible
,
885 yet making the inferior subheadings accessible
,
886 by allowing the reader
to expand the view
of any heading branch
on demand.
890 macros support this capability
,
891 through the setting
of the
892 .CW PDFOUTLINE.FOLDLEVEL
894 This register should be
set to the number
of heading levels
895 which it is desired
to show
in expanded form
, in the
897 document outline display
;
898 all subheadings
at deeper levels will still be added
to the outline
,
899 but will
not become visible until the outline branch containing them is expanded.
901 For example
, the setting used
in this document
:
905 \
&.\e
" Initialise the outline view to show only three heading levels,
906 \&.\e" with additional subordinate
level headings folded.
908 \&.nr PDFOUTLINE.FOLDLEVEL 3
912 results in only the first three levels of headings being displayed
913 in the document outline,
915 the reader chooses to expand the view,
916 and so reveal the lower level headings in any outline branch.
918 The initial default setting of
919 .CW PDFOUTLINE.FOLDLEVEL ,
920 if the document author does not choose to change it,
922 This is orders of magnitude greater than the maximum heading level
923 which is likely to be used in any document;
924 thus the default behaviour will be to show document outlines fully expanded,
925 to display all headings defined,
926 at all levels within each document.
929 .CW PDFOUTLINE.FOLDLEVEL
930 may be changed at any time;
931 however, the effect of each such change may be difficult to predict,
932 since it is applied not only to outline entries which are defined
934 the setting is changed,
935 but also to any entries which remain in the outline cache,
938 Therefore, it is recommended that
939 .CW PDFOUTLINE.FOLDLEVEL
942 at the start of each document;
945 deemed necessary to change it at any other time,
946 the outline cache should be flushed,
950 which should immediately preceed a level one heading.
952 .XN -N multipart-outline -- Outlines for Multipart Documents
954 When a document outline is created, using the
956 macro, each reference mark is automatically assigned a name,
957 composed of a fixed stem followed by a serially generated numeric qualifier.
958 This ensures that, for each single part document, every outline reference
959 has a uniquely named destination.
961 As the overall size of the PDF document increases,
962 it may become convenient to divide it into smaller,
963 individually formatted PostScript\*(rg components,
964 which are then assembled, in the appropriate order,
965 to create a composite PDF document.
966 While this strategy may simplify the overall process of creating and
967 editing larger documents, it does introduce a problem in creating
968 an overall document outline,
969 since each individual PostScript\*(rg component will be assigned
970 duplicated sequences of \(lqbookmark\(rq names,
971 with each name ultimately referring to multiple locations in the composite document.
972 To avoid such reference naming conflicts, the
974 macro allows the user to specify a \(lqtag\(rq,
975 which is appended to the automatically generated \(lqbookmark\(rq name;
976 this may be used as a discriminating mark, to distinguish otherwise
977 similarly named destinations, in different sections of the composite document.
979 To create a \(lqtagged\(rq document outline,
980 the syntax for invocation of the
982 macro is modified, by the inclusion of an optional \(lqtag\(rq specification,
984 the nesting level argument, i.e.
991 .I "descriptive text ...
"
995 argument may be composed of any characters of the user's choice;
996 however, its initial character
998 be any decimal digit, and ideally it should be kept short
999 \(em one or two characters at most.
1001 By employing a different tag in each section,
1002 the user can ensure that \(lqbookmark\(rq names remain unique,
1003 throughout all the sections of a composite document.
1004 For example, when using the
1006 macro package, which adds
1008 capabilities to the standard
1012 the table of contents is collected into a separate PostScript\*(rg section
1013 from the main body of the document.
1014 In the \(lqbody\(rq section, the document outline is \(lquntagged\(rq,
1015 but in the \(lqTable\~of\~Contents\(rq section, a modified version of the
1017 macro adds an outline entry for the start of the \(lqTable\~of\~Contents\(rq,
1022 .CW ".pdfhref O
-T T
1 \e\e
*[TOC
]"
1024 to tag the associated outline destination name with the single character suffix,
1026 Alternatively, as in the case of the basic outline,
1027 .XR basic-outline ), (
1028 this may equally well be specified as
1030 .CW ".pdfbookmark
-T T
1 \e\e
*[TOC
]"
1032 .XN Delegation of the Outline Definition
1034 Since the most common use of a document outline
1035 is to provide a quick method of navigating through a document,
1036 using active \(lqhypertext\(rq links to chapter and section headings,
1037 it may be convenient to delegate the responsibility of creating the outline
1038 to a higher level macro, which is itself used to
1039 define and format the section headings.
1040 This approach has been adopted in the
1042 package, to be described later,
1045 When such an approach is adopted,
1046 the user will rarely, if ever, invoke the
1048 macro directly, to create a document outline.
1049 For example, the structure and content of the outline for this document
1050 has been exclusively defined, using a combination of the
1054 package, to establish the structure, and the
1058 to define the content.
1060 the responsibility for invoking the
1062 macro, to create the document outline,
1067 .XN -N pdfhref -- Adding Reference Marks and Links
1070 .ds SECREF.BEGIN Section
1071 .pdfhref L -D add-outline
1075 macro may be used to create a PDF document outline.
1076 While this is undoubtedly a powerful capability,
1077 it is by no means the only trick in the repertoire of this versatile macro.
1081 which is a contraction of \(lqPDF HyperText Reference\(rq,
1082 indicates that the general purpose of this macro is to define
1084 type of dynamic reference mark, within a PDF document.
1085 Its generalised usage syntax takes the form
1090 .I "-options ...\
&" ] [
1092 .I "descriptive text ...\
&" ] [
1096 represents a required single character argument,
1097 which defines the specific reference operation to be performed,
1098 and may be selected from:\(en
1101 Add an entry to the document outline.
1102 This operation has been described earlier,
1103 .XR add-outline ). (
1105 Place a \(lqnamed destination\(rq reference mark at the current output position,
1106 in the current PDF document,
1109 Specify the content of a PDF document reference dictionary entry;
1110 typically, such entries are generated automatically,
1111 by transformation of the intermediate output resulting from the use of
1113 .CWB M \& \& \(rq, \(lq
1115 .CWB -X \& \& \(rq \(lq
1118 however, it is also possible to specify such entries manually,
1119 .XR user-format ). (
1121 Insert an active link to a named destination,
1123 at the current output position in the current PDF document,
1124 such that when the reader clicks on the link text,
1125 the document view changes to show the location of the named destination.
1127 Insert an active link to a \(lqweb\(rq resource,
1128 .XR add-weblink ), (
1129 at the current output position in the current PDF document.
1130 This is effectively the same as using the
1131 .CWB L \& \& \(rq \(lq
1132 operator to establish a link to a named destination in another PDF document,
1133 .XR link-extern ), (
1134 except that in this case, the destination is specified by a
1135 \(lquniform resource identifier\(rq, or
1137 this may represent any Internet or local resource
1138 which can be specified in this manner.
1140 Specify a user defined macro, to be called by
1142 when formatting the text in the active region of a link,
1145 Define the absolute position on the physical PDF output page,
1146 where the \(lqhot\(hyspot\(rq associated with an active link is to be placed.
1147 Invoked in pairs, marking the starting and ending PDF page co\(hyordinates
1148 for each link \(lqhot\(hyspot\(rq, this operator is rarely, if ever,
1149 specified directly by the user;
1152 .CWB Z \& \& \(rq \(lq
1153 specifications are inserted automatically into the document reference map
1154 during the PDF document formatting process,
1157 Initialise support for
1162 implementation provides only one such feature which requires initialisation
1163 \(em a helper macro which must be attached to a user supplied page trap handler,
1164 in order to support mapping of reference \(lqhot\(hyspots\(rq
1165 which extend through a page transition;
1169 .XN Optional Features of the \F[C]pdfhref\F[] Macro
1171 The behaviour of a number of the
1173 macro operations can be modified,
1175 .EM "option specifiers
" \(rq \(lq
1176 after the operation specifying argument,
1179 any other arguments normally associated with the operation.
1182 cases, an option is specified by an
1183 .EM "option flag
" \(rq, \(lq
1184 comprising an initial hyphen,
1185 followed by one or two option identifying characters.
1191 for these options, the argument
1193 be specified, and it
1195 be separated from the preceding option flag by one or more
1200 It may be noted that this paradigm for specifying options
1201 is reminiscent of most
1205 shells; however, in the case of the
1207 macro, omission of the space separating an option flag from its argument is
1213 general purpose options supported by the
1215 macro is given below.
1216 Note that not all options are supported for all
1218 operations; the operations affected by each option are noted in the list.
1221 operations, if an unsupported option is specified,
1222 it will be silently ignored; however, this behaviour should
1225 The general purpose options, supported by the
1229 .IP \*[= -N\0 name > <]
1232 associated with a PDF reference destination
1233 to be defined independently from the following text,
1234 which describes the reference.
1235 This option affects only the
1236 .CWB M \& \& \(rq \(lq
1242 Also used exclusively with the
1243 .CWB M \& \& \(rq \(lq
1246 option causes any specified
1247 .CWI descriptive \& \& \~\c
1253 in the body text of the document,
1254 at the point where the reference mark is defined;
1258 .CWI descriptive \& \& \~\c
1262 at points where links to the reference mark are placed,
1263 and where the standard reference display format,
1266 .IP \*[= -D\0 dest > <]
1269 or the destination name associated with a PDF active link,
1270 independently of the following text,
1271 which describes the link and demarcates the link \(lqhot\(hyspot\(rq.
1272 This option affects the behaviour of the
1275 .CWB L \& \& \(rq \(lq
1277 .CWB W \& \& \(rq \(lq
1281 .CWB L \& \& \(rq \(lq
1284 argument must specify a PDF \(lqnamed destination\(rq,
1288 .CWB M \& \& \(rq \(lq
1292 .CWB W \& \& \(rq \(lq
1295 must specify a link destination in the form of a
1296 \(lquniform resource identifier\(rq, or
1298 .XR add-weblink ). (
1299 .IP \*[= -F\0 file > <]
1301 .CWB L \& \& \(rq \(lq
1305 specifies an external PDF file in which the named destination
1306 for the link reference is defined.
1309 be specified with the
1310 .CWB L \& \& \(rq \(lq
1312 to create a link to a destination in a different PDF document;
1314 .CWB L \& \& \(rq \(lq
1317 this option, the link destination is assumed to be defined
1318 within the same document.
1319 .IP \*[= -P\0 \(dqprefix\(hytext\(dq > <]
1321 .CWI \(dqprefix\(hytext\(dq > <
1322 to be attached to the
1324 of the text describing an active PDF document link,
1325 with no intervening space, but without itself being included in the
1326 active area of the link \(lqhot\(hyspot\(rq;
1327 it is effective with the
1328 .CWB L \& \& \(rq \(lq
1330 .CWB W \& \& \(rq \(lq
1334 Typically, this option would be used to insert punctuation before
1335 the link \(lqhot\(hyspot\(rq.
1336 Thus, there is little reason for the inclusion of spaces in
1337 .CWI \(dqprefix\(hytext\(dq > < ;
1338 however, if such space is required, then the enclosing double quotes
1340 be specified, as indicated.
1341 .IP \*[= -A\0 \(dqaffixed\(hytext\(dq > <]
1343 .CWI \(dqaffixed\(hytext\(dq > <
1344 to be attached to the
1346 of the text describing an active PDF document link,
1347 with no intervening space, but without itself being included in the
1348 active area of the link \(lqhot\(hyspot\(rq;
1349 it is effective with the
1350 .CWB L \& \& \(rq \(lq
1352 .CWB W \& \& \(rq \(lq
1356 Typically, this option would be used to insert punctuation after
1357 the link \(lqhot\(hyspot\(rq.
1358 Thus, there is little reason for the inclusion of spaces in
1359 .CWI \(dqaffixed\(hytext\(dq > < ;
1360 however, if such space is required, then the enclosing double quotes
1362 be specified, as indicated.
1363 .IP \*[= -T\0 tag > <]
1364 When specified with the
1365 .CWB O \& \& \(rq \(lq
1368 is appended to the \(lqbookmark\(rq name assigned to the generated outline entry.
1371 to distinguish between the series of \(lqbookmark\(rq names generated in
1372 individual passes of the
1374 formatter, when the final PDF document is to be assembled
1375 from a number of separately formatted components;
1376 .XR multipart-outline ). (
1380 option is used with either the
1381 .CWB M \& \& \(rq \(lq
1382 operator, or with the
1383 .CWB L \& \& \(rq \(lq
1387 .CWB M \& \& \(rq \(lq
1390 it ensures that a cross reference record for the marked destination
1391 will be included in the document reference map,
1395 .CWB L \& \& \(rq \(lq
1398 it causes the reference to be displayed in the standard cross reference format,
1400 but substituting the
1401 .CWI descriptive \& \& \~\c
1407 for the description specified in the document reference map.
1409 Marks the end of the option specifiers.
1410 This may be used with all
1412 operations which accept options, to prevent
1414 from interpreting any following arguments as option specifiers,
1415 even if they would otherwise be interpreted as such.
1416 It is also useful when the argument list to
1418 contains special characters \(em any special character,
1419 which is not valid in a
1421 macro name, will cause a parsing error, if
1423 attempts to match it as a possible option flag;
1426 flag prevents this, so suppressing the
1428 warning message, which would otherwise ensue.
1430 Using this flag after
1432 sequences of macro options is recommended,
1433 even when it is not strictly necessary,
1434 if only for the entirely cosmetic benefit of visually separating
1435 the main argument list from the sequence of preceding options.
1440 options listed above, a supplementary set of two character options are defined.
1441 These supplementary options, listed below, are intended for use with the
1442 .CWB L \& \& \(rq \(lq
1443 operator, in conjunction with the
1446 option, to specify alternate file names,
1447 in formats compatible with the file naming conventions
1448 of alternate operating systems;
1449 they will be silently ignored, if used in any other context.
1451 The supported alternate file name options,
1452 which are ignored if the
1455 option is not specified, are:\(en
1457 .IP \*[= -DF\0 dos\(hyfile > <]
1458 Specifies the name of the file in which a link destination is defined,
1459 using the file naming semantics of the
1462 When the PDF document is read on a machine
1463 where the operating system uses the
1466 .CWI dos\(hyfile > <
1467 is used as the name of the file containing the reference destination,
1470 argument specified with the
1473 .IP \*[= -MF\0 mac\(hyfile > <]
1474 Specifies the name of the file in which a link destination is defined,
1475 using the file naming semantics of the
1479 When the PDF document is read on a machine
1480 where the operating system uses the
1483 .CWI mac\(hyfile > <
1484 is used as the name of the file containing the reference destination,
1487 argument specified with the
1490 .IP \*[= -UF\0 unix\(hyfile > <]
1491 Specifies the name of the file in which a link destination is defined,
1492 using the file naming semantics of the
1495 When the PDF document is read on a machine
1496 where the operating system uses
1498 file naming semantics, then
1499 .CWI unix\(hyfile > <
1500 is used as the name of the file containing the reference destination,
1503 argument specified with the
1506 .IP \*[= -WF\0 win\(hyfile > <]
1507 Specifies the name of the file in which a link destination is defined,
1508 using the file naming semantics of the
1509 .CW MS\(hyWindows \*(rg
1510 32\(hybit operating system.
1511 When the PDF document is read on a machine
1512 where the operating system uses any of the
1513 .CW MS\(hyWindows \*(rg
1514 file systems, with long file name support, then
1515 .CWI win\(hyfile > <
1516 is used as the name of the file containing the reference destination,
1519 argument specified with the
1524 .XN -N mark-dest -- Marking a Reference Destination
1528 macro may be used to create active links to any Internet resource,
1531 or to any \(lqnamed destination\(rq,
1532 either within the same document, or in another PDF document.
1533 Although the PDF specification allows link destinations to be defined
1534 in terms of a page number, and an associated view specification,
1535 this style of reference is not currently supported by the
1537 macro, because it is not possible to adequately bind the specification
1538 for the destination with the intended reference context.
1540 References to Internet resources are interpreted in accordance with the
1542 standard for defining a
1544 hence the only prerequisite, for creating a link to any Internet resource,
1547 be properly specified, when declaring the reference;
1548 .XR add-weblink ). (
1549 In the case of references to \(lqnamed destinations\(rq in PDF documents,
1550 however, it is necessary to provide a mechanism for creating such
1551 \(lqnamed destinations\(rq.
1552 This may be accomplished, by invoking the
1562 .I "descriptive text ...\
&" ] [
1564 This creates a \(lqnamed destination\(rq reference mark, with its name specified by
1568 option is not specified, by the first word of
1569 .CWI descriptive \& \& \~\c
1571 (note that this imposes the restriction that,
1574 option is omitted, then
1577 .CWI descriptive \& \& \~\c
1581 Additionally, a reference view will be automatically defined,
1582 and associated with the reference mark,
1583 .XR pdfhref-view ), (
1585 .\" .CWI descriptive
1587 .\" is specified, or the
1590 option is specified, and no document cross reference map has been imported,
1592 then a cross reference mapping record,
1594 will be written to the
1597 this may be captured, and subsequently used to generate a cross reference map
1601 When a \(lqnamed destination\(rq reference mark is created, using the
1604 .CWB M \& \& \(rq \(lq
1605 operator, there is normally no visible effect in the formatted document; any
1606 .CWI descriptive \& \& \~\c
1608 which is specified will simply be stored in the cross reference map,
1609 for use when a link to the reference mark is created.
1610 This default behaviour may be changed, by specifying the
1612 option, which causes any specified
1613 .CWI descriptive \& \& \~\c
1615 to be \(lqechoed\(rq in the document text,
1616 at the point where the reference mark is placed,
1617 in addition to its inclusion in the cross reference map.
1619 .XN -N export-map -- Mapping a Destination for Cross Referencing
1621 Effective cross referencing of
1623 document formatted by
1625 requires multiple pass formatting.
1626 Details of how this multiple pass formatting may be accomplished,
1627 when working with the
1629 macros, will be discussed later,
1631 at this stage, the discussion will be restricted to the initial preparation,
1632 which is required at the time when the cross reference destinations are defined.
1634 The first stage, in the process of cross referencing a document,
1635 is the generation of a cross reference map.
1636 Again, the details of
1638 the cross reference map is generated will be discussed in
1639 .pdfhref F SECREF L -D do-xref -A ;
1641 however, it is important to recognise that
1643 content is included in the cross reference map is established
1644 when the reference destination is defined \(em it is derived
1645 from the reference data exported on the
1649 macro, when it is invoked with the
1650 .CWB M \& \& \(rq \(lq
1651 operator, and is controlled by whatever definition of the string
1653 is in effect, when the
1657 The initial default setting of
1661 .CW ".ds PDFHREF.INFO page \e\en
% \e\e$
*"
1663 which ensures that the cross reference map will contain
1664 at least a page number reference, supplemented by any
1665 .CWI descriptive \& \& \~\c
1667 which is specified for the reference mark, as defined by the
1670 .CWB M \& \& \(rq \(lq
1671 operator; this may be redefined by the user,
1672 to export additional cross reference information,
1673 or to modify the default format for cross reference links,
1676 .XN -N pdfhref-view -- Associating a Document View with a Reference Mark
1678 In the same manner as each document outline reference, defined by the
1681 .CWB O \& \& \(rq \(lq
1683 .XR add-outline ), (
1684 has a specific document view associated with it,
1685 each reference destination marked by
1688 .CWB M \& \& \(rq \(lq
1689 operator, requires an associated document view specification.
1691 The mechanism whereby a document view is associated with a reference mark
1692 is entirely analogous to that employed for outline references,
1693 .XR outline-view ), (
1696 string specification is used, in place of the
1697 .CW PDFBOOKMARK.VIEW
1699 Thus, the reference view is defined in terms of:\(en
1701 .IP \*[= PDFHREF.VIEW]
1703 establishing the position of the reference mark within the viewing window,
1704 and the magnification at which the document will be viewed,
1705 at the location of the marked reference destination;
1706 by default, it is defined by
1709 .CW ".ds PDFHREF.VIEW
/FitH \e\en
[PDFPAGE.Y
] u
"
1712 which displays the reference destination at the top of the viewing window,
1713 with the magnification set to fit the page width to the width of the window.
1714 .IP \*[= PDFHREF.VIEW.LEADING]
1716 specifying additional spacing, to be placed between the top of the display
1717 window and the actual position at which the location of the reference
1718 destination appears within the window.
1719 This register is shared with the view specification for outline references,
1720 and thus has the same default initial setting,
1723 .CW ".nr PDFHREF.VIEW.LEADING
5.0p
"
1726 as in the case of outline reference views.
1729 .CW PDFHREF.VIEW.LEADING
1730 does not represent true typographic \(lqleading\(rq,
1731 since any preceding text, set in the specified display space,
1732 will be visible at the top of the viewing window,
1733 when the reference is selected.
1736 Just as the view associated with outline references may be changed,
1738 .CW PDFBOOKMARK.VIEW ,
1739 so the view associated with marked reference destinations may be changed,
1743 .CW PDFHREF.VIEW.LEADING ;
1744 such changes will become effective for all reference destinations marked
1746 these definitions are changed.
1747 (Notice that, since the specification of
1748 .CW PDFHREF.VIEW.LEADING
1749 is shared by both outline reference views and marked reference views,
1750 if it is changed, then the views for
1752 reference types are changed accordingly).
1754 It may again be noted, that the
1756 register is used in the definition of
1758 just as it is in the definition of
1759 .CW PDFBOOKMARK.VIEW ;
1761 .pdfhref F SECREF L -D outline-view
1763 relating to its use, and indeed to page position computations in general,
1764 apply equally to marked reference views and to outline reference views.
1766 .XN -N link-named -- Linking to a Marked Reference Destination
1768 Any named destination, such as those marked by the
1771 .CWB M \& \& \(rq \(lq
1772 operator, may be referred to from any point in
1774 PDF document, using an
1776 such active links are created by again using the
1778 macro, but in this case, with the
1779 .CWB L \& \& \(rq \(lq
1781 This operator provides support for two distinct cases,
1782 depending on whether the reference destination is defined in
1783 the same document as the link,
1784 .XR link-intern ), (
1785 or is defined as a named destination in a different PDF document,
1786 .XR link-extern ). (
1788 .XN -N link-intern -- References within a Single PDF Document
1790 The general syntactic form for invoking the
1793 when creating a link to a named destination within the same PDF document is
1801 .BI prefix-text >] <
1803 .BI affixed-text >] <
1809 .I "descriptive text ...\
&" ] [
1813 specifies the name of the link destination,
1814 as specified using the
1816 .CWB M \& \& \(rq \(lq
1817 operation; (it may be defined either earlier in the document,
1818 to create a backward reference, or later, to create a forward reference).
1820 .\" Here's a example of how to add an iconic annotation.
1822 .\".pdfnote -T "Internal Cross References
" \
1823 .\" This description is rather terse, and could benefit from \
1824 .\" the inclusion of an example.
1827 .CWI descriptive \& \& \~\c
1829 arguments are specified, then they will be inserted into the
1831 output stream, to define the text appearing in the \(lqhot\(hyspot\(rq
1833 this will be printed in the link colour specified by the string,
1834 .CW PDFHREF.TEXT.COLOUR ,
1835 which is described in
1836 .XR-NO-PREFIX set-colour .
1839 option is also specified, then the
1840 .CWI descriptive \& \& \~\c
1842 will be augmented, by prefacing it with page and section number indicators,
1843 in accordance with the reference formatting rules which are in effect,
1845 such indicators will be included within the active link region,
1846 and will also be printed in the link colour.
1852 .CWBI dest\(hyname > <
1856 .CWI descriptive \& \& \~\c
1859 .EM "but
not both
" ,
1863 .CWBI dest\(hyname > <
1864 option is omitted, then the first word of
1865 .CWI descriptive \& \& \~\c
1867 i.e.\~all text up to but not including the first space,
1868 will be interpreted as the
1869 .CWBI dest\(hyname > <
1870 for the link; this text will also appear in the running text of the document,
1871 within the active region of the link.
1872 Alternatively, if the
1874 .CWBI dest\(hyname > <
1878 .CWI descriptive \& \& \~\c
1881 then the running text which defines the reference,
1882 and its active region,
1883 will be derived from the reference description which is specified
1884 when the named destination is marked,
1886 and will be formatted according to the reference formatting rules
1887 which are in effect, when the reference is placed,
1889 in this case, it is not necessary to specify the
1891 option to activate automatic formatting of the reference \(em it is implied,
1892 by the omission of all
1893 .CWI descriptive \& \& \~\c
1899 .CWBI prefix\(hytext > <
1902 .CWBI affixed\(hytext > <
1903 options may be used to specify additional text
1904 which will be placed before and after the linked text respectively,
1905 with no intervening space.
1906 Such prefixed and affixed text will be printed in the normal text colour,
1907 and will not be included within the active region of the link.
1908 This feature is mostly useful for creating parenthetical references,
1909 or for placing punctuation adjacent to,
1910 but not included within,
1911 the text which defines the active region of the link.
1913 The operation of the
1915 macro, when used with its
1916 .CWB L \& \& \(rq \(lq
1917 operator to place a link to a named PDF destination,
1918 may best be illustrated by an example.
1919 However, since the appearance of the link will be influenced by
1920 factors established when the named destination is marked,
1922 and also by the formatting rules in effect when the link is placed,
1923 the presentation of a suitable exanple will be deferred,
1924 until the formatting mechanism has been explained,
1927 .XN -N link-extern -- References to Destinations in Other PDF Documents
1932 .CWB L \& \& \(rq \(lq
1933 operator is not restricted to creating reference links
1934 within a single PDF document.
1935 When the link destination is defined in a different document,
1936 then the syntactic form for invoking
1938 is modified, by the addition of options to specify the
1939 name and location of the PDF file in which the destination is defined.
1942 syntactic form becomes
1966 .BI prefix-text >] <
1968 .BI affixed-text >] <
1974 .I "descriptive text ...\
&" ] [
1981 purposes: it both indicates to the
1983 macro that the specified reference destination
1984 is defined in an external PDF file,
1985 and it also specifies the normal path name,
1986 which is to be used to locate this file,
1987 when a user selects the reference.
1994 be specified when referring to a destination in an external PDF file,
1997 .CWBI dos\(hyfile > < ,
1999 .CWBI mac\(hyfile > < ,
2001 .CWBI unix\(hyfile > <
2004 .CWBI win\(hyfile > <
2005 options may be used to specify the location of the file
2006 containing the reference destination,
2007 in a variety of operating system dependent formats.
2008 These options assign their arguments to the
2014 keys of the generated
2016 respectively; thus when any of these options are specified,
2017 .EM "in addition
to"
2021 option, and the document is read on the appropriate operating systems,
2022 then the path names specified by
2023 .CWBI dos\(hyfile > < ,
2024 .CWBI mac\(hyfile > < ,
2025 .CWBI unix\(hyfile > <
2027 .CWBI win\(hyfile > <
2030 of the path name specified by
2033 .CW MS\(hyDOS \*(rg,
2035 .CW Macintosh \*(rg,
2038 .CW MS\(hyWindows \*(rg
2039 operating systems, respectively; see the
2041 for further details.
2043 Other than the use of these additional options,
2044 which specify that the reference destination is in an external PDF file,
2045 the behaviour of the
2047 .CWB L \& \& \(rq \(lq
2051 option, remains identical to its behaviour
2054 .XR link-intern ), (
2055 with respect to the interpretation of other options,
2057 .CWI descriptive \& \& \~\c
2059 arguments, and the formatting of the displayed reference.
2061 Once again, since the appearance of the reference is determined by
2062 factors specified in the document reference map,
2063 and also by the formatting rules in effect when the reference is placed,
2064 the presentation of an example of the placing of
2065 a reference to an external destination will be deferred,
2066 until the formatting mechanism has been explained,
2069 .XN -N add-weblink -- Linking to Internet Resources
2071 In addition to supporting the creation of cross references
2072 to named destinations in PDF documents, the
2074 macro also has the capability to create active links to Internet resources,
2077 resource which may be specified by a Uniform Resource Identifier,
2078 (which is usually abbreviated to the acronym \(lqURI\(rq,
2079 and sometimes also referred to as a Uniform Resource Locator,
2082 Since the mechanism for creating a link to a URI differs somewhat
2083 from that for creating PDF references, the
2085 macro is invoked with the
2086 .CWB W \& \& \(rq \(lq
2087 (for \(lqweb\(hylink\(rq) operator, rather than the
2088 .CWB L \& \& \(rq \(lq
2089 operator; nevertheless, the invocation syntax is similar, having the form
2097 .BI prefix-text >] <
2099 .BI affixed-text >] <
2104 .I "descriptive text ...\
&"
2109 modifier specifies the address for the target Internet resource,
2111 .EM "Uniform Resource Identifier
"
2115 argument specifies the text which is to appear in the \(lqhot\(hyspot\(rq
2118 .CWBI prefix\(hytext > <
2121 .CWBI affixed\(hytext > <
2122 options have the same effect as in the case of local document links,
2123 .XR link-intern ). (
2125 Notice that it is not mandatory to include the
2128 in the link specification; if it
2130 specified, then it is not necessary for the URI to appear,
2131 in the running text of the document \(em the
2134 argument exactly defines the text
2135 which will appear within the \(lqhot\(hyspot\(rq region,
2136 and this need not include the URI.
2140 specification is omitted, then the
2147 representation of the URI, which
2149 therefore, appear as the entire content of the \(lqhot\(hyspot\(rq.
2150 For example, we could introduce a reference to
2151 .pdfhref W -D \*[ROFF-WEBSITE] -A , the @T_ROFF@ web site
2152 in which the actual URI is concealed, by using mark up such as:\(en
2155 For example, we could introduce a reference to
2156 \&.pdfhref W -D \*[ROFF-WEBSITE] -A , the @T_ROFF@ web site
2157 in which the actual URI is concealed,
2160 to refer the reader to the @T_ROFF@ web site,
2161 making it obvious that the appropriate URI is
2162 .pdfhref W -A , \*[ROFF-WEBSITE]
2163 the requisite mark up might be:\(en
2166 to refer the reader to the @T_ROFF@ web site,
2167 making it obvious that the appropriate URI is
2168 \&.pdfhref W -A , \*[ROFF-WEBSITE]
2169 the requisite mark up might be:\e(en
2172 .XN -N set-format -- Establishing a Format for References
2174 There are two principal aspects to be addressed,
2175 when defining the format to be used when displaying references.
2176 Firstly, it is desirable to provide a visual cue,
2177 to indicate that the text describing the reference is imbued
2178 with special properties \(em it is dynamically linked to the reference
2179 destination \(em and secondly, the textual content should
2180 describe where the link leads, and ideally,
2181 it should also describe the content of the reference destination.
2184 that a text region defines a dynamically linked reference,
2185 is most commonly provided by printing the text within the active
2186 region in a distinctive colour.
2187 This technique will be employed automatically by the
2191 \(em unless the user specifically chooses to adopt, and implement,
2192 some alternative strategy.
2194 .XN -N set-colour -- Using Colour to Demarcate Link Regions
2196 Typically, when a PDF document contains
2198 references to other locations, either within the same document,
2199 or even in other documents, or on the World Wide Web,
2200 it is usually desirable to make the regions
2201 where these active links are placed stand out from the surrounding text.
2203 .XN -N user-format -- Specifying Reference Text Explicitly
2205 .XN -N auto-format -- Using Automatically Formatted Reference Text
2207 .XN -N custom-format -- Customising Automatically Formatted Reference Text
2209 It is incumbent on the user,
2210 if employing automatic formatting of the displayed reference,
2212 to ensure that an appropriate reference definition
2213 is created for the reference destination,
2214 and is included in the reference map for the document
2215 in which the reference will appear;
2216 thus, it may be easiest to
2218 use manual formatting for external references.
2220 .XN Problematic Links
2222 Irrespective of whether a
2224 reference is placed using the
2225 .CWB L \& \& \(rq \(lq
2227 .CWB W \& \& \(rq \(lq
2228 operator, there may be occasions when the resulting link
2229 does function as expected.
2230 A number of scenarios, which are known to be troublesome,
2231 are described below.
2233 .XN -N page-trap -- Links with a Page Transition in the Active Region
2235 When a link is placed near the bottom of a page,
2236 it is possible that its active region, or \(lqhot\(hyspot\(rq,
2237 may extend on to the next page.
2238 In this situation, a page trap macro is required
2239 to intercept the page transition, and to restart the mapping of
2240 the \(lqhot\(hyspot\(rq boundary on the new page.
2244 macro package includes a suitable page trap macro, to satisfy this requirement.
2245 However, to avoid pre\(hyempting any other requirement the user may have for
2246 a page transition trap, this is
2248 installed as an active page trap,
2249 unless explicitly requested by the user.
2251 To enable proper handling of page transitions,
2252 which occur within the active regions of reference links,
2253 the user should:\(en
2257 Define a page transition macro, to provide whatever features may be required,
2258 when a page transition occurs \(em e.g.\& printing footnotes,
2259 adding page footers and headers, etc.
2260 This macro should end by setting the output position at the correct
2261 vertical page offset, where the printing of running text is to restart,
2262 following the page transition.
2264 Plant a trap to invoke this macro, at the appropriate vertical position
2265 marking the end of normal running text on each page.
2270 hook into this page transition trap, by invoking
2278 .CWBI macro-name > <
2279 is the name of the user supplied page trap macro,
2282 will correctly restart mapping of active link regions,
2283 at the start of each new page.
2288 It may be observed that this initialisation of the
2290 page transition hook is, typically, required only once
2292 document formatting begins.
2293 Users of document formatting macro packages may reasonably expect that
2294 this initialisation should be performed by the macro package itself.
2295 Thus, writers of such macro packages which include
2297 bindings, should provide appropriate initialisation,
2298 so relieving the end user of this responsibility.
2299 The following example, abstracted from the sample
2303 illustrates how this may be accomplished:\(en
2306 \&.\e" @T_ROFF@
"ms" provides the
"pg@bottom" macro
, which has already
2307 \
&.\e
" been installed as a page transition trap. To ensure proper
2308 \&.\e" mapping
of "pdfhref" links which overflow the bottom
of any
2309 \
&.\e
" page, we need to install the "pdfhref
" page transition hook,
2310 \&.\e" as an addendum
to this macro.
2312 \
&.pdfhref I
-PT pg@bottom
2315 .XN
-N add
-note
-- Annotating a PDF Document using Pop-Up Notes
2317 .XN
-N pdfsync
-- Synchronising Output and \F[C]pdfmark\F[] Contexts
2319 It has been noted previously
, that the
2329 macro
, when used
to create a document outline
,
2330 .XR add
-outline
), (
2331 do not immediately write their
2333 output
to the PostScript\
*(rg data stream
;
2334 instead
, they cache their output
, in a
2336 diversion
, in the
case of the
2340 macros
, or in an ordered collection
of strings
and numeric registers
,
2341 in the
case of the document outline
,
2342 until a more appropriate
time for copying it out.
2347 \
(lqmeta\
(hydata\
(rq
,
2348 this \
(lqmore appropriate
time\
(rq is explicitly chosen
by the user
;
2349 in the
case of document outline data
,
2351 cached data may be implicitly written out
as the document outline is compiled
,
2354 be some remaining data
, which must be explicitly flushed out
, before the
2356 formatting process is allowed
to complete.
2358 To allow the user
to choose when cached
2360 data is
to be flushed
to the output stream
, the
2362 macro package provides the
2364 macro
, (to synchronise the cache
and output states
).
2365 In its simplest form
, it is invoked without arguments
, i.e.
2370 This form
of invocation ensures that
2372 the \
(lqmeta\
(hydata cache\
(rq
, containing
2378 the \
(lqoutline cache\
(rq
,
2379 containing any previously uncommitted document outline data
,
2380 are flushed
; ideally
, this should be included
in a
2382 \
(lqend macro\
(rq
, to ensure that
2384 caches are flushed
, before
2389 it may be desirable
to flush either the \
(lqmeta\
(hydata cache\
(rq
,
2390 without affecting the \
(lqoutline cache\
(rq
, or vice\
(hyversa
,
2391 at a user specified
time, prior
to reaching the end
of the document.
2392 This may be accomplished
, by invoking the
2394 macro
with an argument
, i.e.
2399 to flush only the \
(lqmeta\
(hydata cache\
(rq
, or
2404 to flush only the \
(lqoutline cache\
(rq.
2406 The \
(lqmeta\
(hydata cache\
(rq can normally be safely flushed
2407 in this manner
, at any
time
2409 output
of the first page has started
;
2410 (it may cause formatting problems
,
2411 most notably the appearance
of unwanted white space
, if flushed earlier
,
2412 or indeed
, if flushed immediately after a page transition
,
2413 but before the output
of the content
on the new page has commenced
).
2414 Caution is required
, however
, when explicitly flushing the
2415 \
(lqoutline cache\
(rq
, since
if the outline is
to be
2416 subsequently extended
, then the first outline entry after flushing
2418 be specified
at level 1.
2419 Nevertheless
, such explicit flushing may occasionally be necessary
;
2427 .CW
".pdfsync\ O" \
(rq \
(lq
2428 to ensure that the outline
for the \
(lqbody\
(rq section
of the document
2431 it commences the formatting
of the table
of contents section.
2434 .XN
-N pdf
-layout
-- PDF Document Layout
2438 macros described
in the preceding section
,
2439 .XR pdf
-features
), (
2440 provide no inherent document formatting capability
of their own.
2442 they may be used
in conjunction
with any other
2444 macro package
of the user's choice
,
2445 to add such capability.
2447 In preparing this document
, the standard
2449 macro package
, supplied
as a component
of the @T_ROFF@ distribution
,
2451 To facilitate the use
of the
2456 a binding macro package
,
2459 The use
of this binding macro package is described
in the following section
,
2461 it may also serve
as an example
to users
of other standard
2466 macros may be employed
with their chosen primary macro package.
2468 .XN
-N using
-spdf
-- Using \F[C]pdfmark\F[] Macros with the \F[C]ms\F[] Macro Package
2470 The use
of the binding macro package
,
2472 allows
for the use
of the
2474 macros
in conjunction
with the
2484 .I
"-options ...\&" ] [
2491 input files may be marked up using any
of the standard
2493 macros
to specify document formatting
,
2494 while PDF features may be added
,
2497 macros described previously
,
2498 .XR pdf
-features
).
(
2501 defines a number
of convenient extensions
to the
2503 macro
set, to better accomodate the use
of PDF features within the
2505 formatting framework
,
2506 and to address a number
of
2508 document layout issues
,
2509 which require special handling when producing PDF documents.
2510 These additional macros
,
2511 and the issues they are intended
to address
,
2512 are described below.
2514 .XN \F
[C
]ms\F
[] Section Headings
in PDF Documents
2522 macros
, to specify section headings.
2524 there is no standard mechanism
for generating a
2525 table
of contents entry based
on the text
of the section heading
;
2526 neither is there any recognised standard method
for establishing a
2527 cross reference link
to the section.
2537 to be used
in conjunction
with the
2541 .XN
-N xn
-macro
-- The \F[C]XN\F[] Macro
2543 .XN The PDF Publishing Process
2545 .XN
-N
do-xref
-- Resolving Cross References
2547 .XN
-N create
-map
-- Creating a Document Reference Map
2549 .XN
-N import
-map
-- Deploying a Document Reference Map