PDFlib API Reference 8.0.2

Add to my manuals
236 Pages

advertisement

PDFlib API Reference 8.0.2 | Manualzz
ABC
PDFlib, PDFlib+PDI, PPS
A library for generating PDF on the fly
Version 8.0.2
API Reference
Edition for COM, .NET, and REALbasic
Copyright © 1997–2011 PDFlib GmbH and Thomas Merz. All rights reserved.
PDFlib users are granted permission to reproduce printed or digital copies of this manual for internal use.
PDFlib GmbH
Franziska-Bilek-Weg 9, 80339 München, Germany
www.pdflib.com
phone +49 • 89 • 452 33 84-0
fax +49 • 89 • 452 33 84-99
If you have questions check the PDFlib mailing list and archive at tech.groups.yahoo.com/group/pdflib
Licensing contact: [email protected]
Support for commercial PDFlib licensees: [email protected] (please include your license number)
This publication and the information herein is furnished as is, is subject to change without notice, and
should not be construed as a commitment by PDFlib GmbH. PDFlib GmbH assumes no responsibility or liability for any errors or inaccuracies, makes no warranty of any kind (express, implied or statutory) with respect to this publication, and expressly disclaims any and all warranties of merchantability, fitness for particular purposes and noninfringement of third party rights.
PDFlib and the PDFlib logo are registered trademarks of PDFlib GmbH. PDFlib licensees are granted the
right to use the PDFlib name and logo in their product documentation. However, this is not required.
Adobe, Acrobat, PostScript, and XMP are trademarks of Adobe Systems Inc. AIX, IBM, OS/390, WebSphere,
iSeries, and zSeries are trademarks of International Business Machines Corporation. ActiveX, Microsoft,
OpenType, and Windows are trademarks of Microsoft Corporation. Apple, Macintosh and TrueType are
trademarks of Apple Computer, Inc. Unicode and the Unicode logo are trademarks of Unicode, Inc. Unix is a
trademark of The Open Group. Java and Solaris are trademarks of Sun Microsystems, Inc. HKS is a registered trademark of the HKS brand association: Hostmann-Steinberg, K+E Printing Inks, Schmincke. Other
company product and service names may be trademarks or service marks of others.
PANTONE® colors displayed in the software application or in the user documentation may not match
PANTONE-identified standards. Consult current PANTONE Color Publications for accurate color. PANTONE®
and other Pantone, Inc. trademarks are the property of Pantone, Inc. © Pantone, Inc., 2003.
Pantone, Inc. is the copyright owner of color data and/or software which are licensed to PDFlib GmbH to
distribute for use only in combination with PDFlib Software. PANTONE Color Data and/or Software shall
not be copied onto another disk or into memory unless as part of the execution of PDFlib Software.
PDFlib contains modified parts of the following third-party software:
ICClib, Copyright © 1997-2002 Graeme W. Gill
GIF image decoder, Copyright © 1990-1994 David Koblas
PNG image reference library (libpng), Copyright © 1998-2004 Glenn Randers-Pehrson
Zlib compression library, Copyright © 1995-2002 Jean-loup Gailly and Mark Adler
TIFFlib image library, Copyright © 1988-1997 Sam Leffler, Copyright © 1991-1997 Silicon Graphics, Inc.
Cryptographic software written by Eric Young, Copyright © 1995-1998 Eric Young ([email protected])
Independent JPEG Group’s JPEG software, Copyright © 1991-1998, Thomas G. Lane
Cryptographic software, Copyright © 1998-2002 The OpenSSL Project (www.openssl.org)
Expat XML parser, Copyright © 1998, 1999, 2000 Thai Open Source Software Center Ltd
ICU International Components for Unicode, Copyright © 1995-2009 International Business Machines Corporation and others
Reference sRGB ICC color profile data, Copyright (c) 1998 Hewlett-Packard Company
PDFlib contains the RSA Security, Inc. MD5 message digest algorithm.
Contents
1 Option Lists
7
1.1 Option List Syntax 7
1.2 Basic Types 10
1.3 Fontsize, Color, and Action 12
1.4 Geometric Types 14
1.5 Limits 16
2 General Functions
17
2.1 Function Scopes 17
2.2 Parameter and Option Handling 18
2.3 Setup 21
2.4 PDFlib Virtual File System (PVF) 23
2.5 Exception Handling 25
2.6 Logging 27
3 Document and Page Functions
29
3.1 Document Functions 29
3.2 Fetching PDF Documents from Memory 37
3.3 Page Functions 38
3.4 Layers 43
4 Font and Text Functions
49
4.1 Font Handling 49
4.2 Type 3 Font Definition 59
4.3 Encoding Definition 61
4.4 Simple Text Output 62
4.5 Unicode Conversion Functions 66
5 Text and Table Formatting
67
5.1 Text Options 67
5.2 Single-Line Text with Textlines 71
5.3 Multi-Line Text with Textflows 75
5.4 Table Formatting 90
6 Object Fitting and Matchboxes
99
6.1 Object Fitting 99
6.2 Matchboxes 105
Contents
3
7 Graphics Functions
109
7.1 Graphics Appearance Parameters and Options 109
7.2 Graphics State 112
7.3 Coordinate System Transformations 117
7.4 Path Construction 119
7.5 Painting and Clipping 123
7.6 Path Objects 125
8 Color Functions
129
8.1 Setting Color and Color Space 129
8.2 ICC Profiles 133
8.3 Patterns and Shadings 137
9 Image and Template Functions
141
9.1 Images 142
9.2 Templates 150
9.3 Thumbnails 153
10 PDF Import (PDI) and pCOS Functions
10.1 Document Functions 155
10.2 Page Functions 158
10.3 Other PDI Processing 162
10.4 pCOS Functions 163
11 Block Filling Functions (PPS)
167
11.1 Rectangle Options for Block Filling Functions 167
11.2 Textline and Textflow Blocks 168
11.3 Image Blocks 170
11.4 PDF Blocks 171
12 Interactive Features
173
12.1 Parameters for Interactive Elements 173
12.2 Actions 173
12.3 Named Destinations 178
12.4 Annotations 180
12.5 Form Fields 188
12.6 Bookmarks 194
12.7 PDF Packages and Portfolios 196
4
Contents
155
13 3D and Geospatial Features
201
13.1 3D Artwork 201
13.2 Geospatial Features 205
14 Document Interchange
207
14.1 Document Information Fields 207
14.2 XMP Metadata 209
14.3 Tagged PDF 210
14.4 Marked Content 213
A List of all Functions
215
B List of all Parameters
217
C List of all Options and Keywords
D Revision History
Index
219
231
233
Contents
5
1 Option Lists
Option lists are a powerful yet easy method for controlling API function calls. Instead of
requiring a multitude of function parameters, many API methods support option lists,
or optlists for short. These are strings which can contain an arbitrary number of options.
Option lists support various data types and composite data like lists. In most language
bindings optlists can easily be constructed by concatenating the required keywords and
values.
Bindings .NET language binding: C# programmers should keep in mind that the AppendFormat( )
StringBuilder method uses the { and } braces to represent format items which will be replaced by the string representation of arguments. On the other hand, the Append( )
method does not impose any special meaning on the brace characters. Since the option
list syntax makes use of the brace characters, care must be taken in selecting the
AppendFormat( ) or Append( ) method appropriately.
1.1 Option List Syntax
Formal option list syntax definition. Option lists must be constructed according to following rules:
> All elements (keys and values) in an option list must be separated by one or more of
the following separator characters: space, tab, carriage return, newline, equal sign ’=’.
> An outermost pair of enclosing braces is not part of the element. The sequence { }
designates an empty element.
> Separators within the outermost pair of braces no longer split elements, but are part
of the element. Therefore, an element which contains separators must be enclosed
with braces.
> An element which contains braces at the beginning or end must be enclosed with
braces.
> If an element contains unbalanced braces, these must be protected with a preceding
backslash character. A backslash in front of the closing brace of an element must also
be preceded by a backslash character.
> Option lists must not contain binary zero values.
An option may have a list value according to its documentation in this PDFlib Reference. List values contain one or more elements (which may themselves be lists). They
are separated according to the rules above, with the only difference that the equal sign
is no longer treated as a separator.
Simple option lists. In many cases option lists will contain one or more key/value
pairs. Keys and values, as well as multiple key/value pairs must be separated by one or
more whitespace characters (space, tab, carriage return, newline). Alternatively, keys
can be separated from values by an equal sign ’=’:
key=value
key = value
key value
key1 = value1
key2 = value2
1.1 Option List Syntax
7
To increase readability we recommend to use equal signs between key and value and
whitespace between adjacent key/value pairs.
Since option lists will be evaluated from left to right an option can be supplied multiply within the same list. In this case the last occurrence will overwrite earlier ones. In
the following example the first option assignment will be overridden by the second,
and key will have the value value2 after processing the option list:
key=value1 key=value2
List values. Lists contain one or more separated values, which may be simple values or
list values in turn. Lists are bracketed with { and } braces, and the values in the list must
be separated by whitespace characters. Examples:
dasharray={11 22 33}
position={ center bottom }
(list containing three numbers)
(list containing two keywords)
A list may also contain nested lists. In this case the lists must also be separated from
each other by whitespace. While a separator must be inserted between adjacent } and {
characters, it can be omitted between braces of the same kind:
polylinelist={{10 20 30 40} {50 60 70 80}}
(list containing two lists)
If the list contains exactly one list the braces for the nested list must not be omitted:
polylinelist={{10 20 30 40}}
(list containing one nested list)
Nested option lists and list values. Some options accept the type option list or list of
option lists. Options of type option list contain one or more subordinate options. Options
of type list of option lists contain one or more nested option lists. When dealing with
nested option lists it is important to specify the proper number of enclosing braces.
Several examples are listed below.
The value of the option metadata is an option list which itself contains a single option filename:
metadata={filename=info.xmp}
The value of the option fill is a list of option lists containing a single option list:
fill={{ area=table fillcolor={rgb 1 0 0} }}
The value of the option fill is a list of option lists containing two option lists:
fill={{ area=rowodd fillcolor={rgb 0 1 0} } { area=roweven fillcolor={rgb 1 0 0} }}
List containing one option list with a value that includes spaces:
attachments={{filename={foo bar.xml} }}
List containing three strings:
itemnamelist = {{Isaac Newton} {James Clark Maxwell} {Albert Einstein}
List containing two keywords:
position={left bottom}
8
Chapter 1: Option Lists (Edition for COM, .NET, and REALbasic)
List containing different types (float and keyword):
position={10 bottom}
List containing one rectangle:
boxes={{10 20 30 40}}
List containing two polylines with percentages:
polygons = {{10 20 40 60 90 120}} {12 87 34 98 34% 67% 34% 7%}}
Common traps and pitfalls. This paragraph lists some common errors regarding option list syntax.
Braces are not separators; the following is wrong:
key1 {value1}key2 {value2}
WRONG!
This will trigger the error message Unknown option 'value2'. Similarly, the following are
wrong since the separators are missing:
key{value}
key={{value1}{value2}}
WRONG!
WRONG!
Braces must be balanced; the following is wrong:
key={open brace {}
WRONG!
This will trigger the error message Braces aren't balanced in option list 'key={open brace {}'.
A single brace as part of a string must be preceded by an additional backslash character:
key={closing brace \} and open brace \{}
CORRECT!
A backslash at the end of a string value must be preceded by another backslash if it is
followed by a closing brace character:
filename={C:\path\name\}
filename={C:\path\name\\}
WRONG!
CORRECT!
1.1 Option List Syntax
9
1.2 Basic Types
String. Strings are plain ASCII strings which are generally used for non-localizable keywords. Strings containing whitespace or ’=’ characters must be bracketed with { and }:
password={ secret string }
contents={length=3mm}
(string value contains three blanks)
(string value containing one equal sign)
The characters { and } must be preceded by an additional \ character if they are supposed to be part of the string:
password={weird\}string}
(string value contains a right brace)
A backslash in front of the closing brace of an element must be preceded by a backslash
character:
filename={C:\path\name\\}
(string ends with a single backslash)
An empty string can be constructed with a pair or braces:
{}
Content strings, hypertext strings and name strings: these can hold Unicode content in
various formats. Single bytes can be expressed by an escape sequence if the parameter
escapesequence is set. For details on these string types and encoding choices for string
options see the PDFlib Tutorial.
Unichar. A Unichar is a single Unicode value where several syntax variants are supported: decimal values ¹ 10 (e.g. 173), hexadecimal values prefixed with x, X, 0x, 0X, or U+
(xAD, 0xAD, U+00AD), numerical references, character references, and glyph name references but without the ’&’ and ’;’ decoration (shy, #xAD, #173). Alternatively, literal characters can be supplied. Unichars must be in the range 0-65535 (0-0xFFFF). Example:
replacementchar=?
replacementchar=63
replacementchar=x3F
replacementchar=0x3F
replacementchar=U+003F
replacementchar=euro
replacementchar=.question
replacementchar=.marina
(literal)
(decimal)
(hexadecimal)
(hexadecimal)
(Unicode notation)
(HTML character reference)
(standard glyph name reference)
(font-specific glyph name reference)
Single characters which happen to be a number are treated literally, not as decimal Unicode values:
replacementchar=3
(U+0033 THREE, not U+0003!)
Unicode range. A Unicode range identifies a contiguous range of Unicode characters
via start and end characters of the range. The start and end values of a Unicode range
must be separated by a minus sign ’-’ without any spaces, e.g.
forcechars={U+03AC-U+03CE}
10
Chapter 1: Option Lists (Edition for COM, .NET, and REALbasic)
Boolean. Booleans have the values true or false; if the value of a Boolean option is
omitted, the value true is assumed. As a shorthand notation noname can be used instead
of name=false:
embedding
noembedding
(equivalent to embedding=true)
(equivalent to embedding=false)
Keyword. An option of type keyword can hold one of a predefined list of fixed keywords. Example:
blendmode=overlay
For some options the value hold either a number or a keyword.
Number. Option list support several numerical types.
Integer types can hold decimal and hexadecimal integers. Positive integers starting
with x, X, 0x, or 0X specify hexadecimal values:
-12345
0
0xFF
Floats can hold decimal floating point or integer numbers; period and comma can be
used as decimal separators for floating point values. Exponential notation is also supported. The following values are all equivalent:
size
size
size
size
=
=
=
=
-123.45
-123,45
-1.2345E2
-1.2345e+2
Percentages are numbers with a % character directly after the numerical value. Some
options allow negative percentages:
leading=120%
topoffset=-20.5%
Handle. Handles identify various types of objects, e.g. fonts, images, or actions. Technically these are integer values which have been returned earlier by an API function. For
example, a font handle is returned by load_font( ). Handles must always be treated as
opaque types; they must never be modified or created by the application directly (as opposed to using a handle returned by an API function). Handles must always be valid for
the respective type of object. For example, an option which expects an image handle
must be supplied with a font handle, although both handles are integer types.
1.2 Basic Types
11
1.3 Fontsize, Color, and Action
Fontsize. A fontsize can be defined in several ways which allow the size of text to be
specified in absolute values, relative to some external entity, or relative to some font
property. In general the fontsize must be different from 0 unless the option description
mentions otherwise.
In the most common case a fontsize contains a single float value which specifies refers to units in the user coordinate system:
fontsize = 12
The second variant contains a percentage, where the basis of the percentage depends on
the context (e.g. the width of the fitbox for fit_textline( ):
fontsize = 8%
In the third variant, the fontsize is specified as an option list which must contain a keyword and a number. The keyword describes the desired font metric according to Table
1.1, and the number contains the desired size. PDFlib will calculate the proper fontsize so
that the selected text metric matches the supplied value:
fontsize = {capheight 5}
Table 1.1 Suboptions for options of type fontsize
option
explanation
ascender
The number will be interpreted as ascender height.
bodyheight
The number will be interpreted as minimum distance between baselines, i.e. descenders and ascenders of
adjacent lines may exactly touch if this value is used as leading. This is the default behavior if no keyword is provided.
capheight
The number will be interpreted as capital letter height.
xheight
The number will be interpreted as lowercase letter height.
Color. Colors can be defined in three different forms: using an RGB color name, hexadecimal RGB values, or a flexible option list for colors in any color space.
In the first form all valid color names from SVG 1.1 can be supplied directly to specify
an RGB color, e.g.
strokecolor=pink
The color names are case-insensitive. A list of valid color names can be found at the following location:
www.w3.org/TR/SVG11/types.html#ColorKeywords
In the second form a hash ’#’ character followed by any combination of three pairs of
hexadecimal digits 00-FF can be supplied to specify an RGB color value, e.g.
strokecolor=#FFC0CB
In the third form an color option list specified a color space and color value. A color option list contains a colorspace keyword and a list with a variable number of float values
12
Chapter 1: Option Lists (Edition for COM, .NET, and REALbasic)
depending on the particular color space. Color space keywords are the same as for
setcolor( ) (see Section 8.1, »Setting Color and Color Space«, page 129). Table 1.2 contains
specific descriptions and examples. As detailed in the respective function descriptions,
a particular option list may supply only a subset of the keywords presented above.
Cookbook A full code sample can be found in the Cookbook topic color/starter_color.
Table 1.2 Keywords for the color data type in option lists
keyword
additional values
example
gray
single float value for the grayscale color space
{ gray 0.5 }
rgb
three float values for the RGB color space
{ rgb 1 0 0 }
(no keyword) HTML color name or hexadecimal values for an RGB color
pink
#FFC0CB
cmyk
four float values for the CMYK color space
{ cmyk 0 1 0 0 }
lab
three float values for the Lab color space
{ lab 100 50 30 }
spot
spot color handle and a float specifying the tint value
{ spot 1 0.8 }
spotname
(up to 63 bytes; fewer Unicode characters depending on format
and encoding) spot color name and a float specifying the tint value
{ spotname {PANTONE 281 U} 0.5 }
spotname
Similar to the simple form of spotname above, but a color value
{ spotname {PDFlib Blue} 0.5
can be added to specify the alternate color for a custom spot color
{ lab 100 50 30 } }
(i.e. a spot color name which is not known internally to PDFlib). If
multiple options define the same custom spot color name all definitions must be consistent (i.e. define the same alternate color).
iccbasedgray single float value
{ iccbasedgray 0.5 }
iccbasedrgb
three float values
{ iccbasedrgb 1 0 0 }
iccbasedcmyk
four float values
{ iccbasedcmyk 0 1 0 0 }
pattern
pattern handle
{ pattern 1 }
none
specifies the absence of color
none
Action list. An action list specifies one or more actions. Each entry in the list consists
of an event keyword (trigger) and a list of action handles which must have been created
with create_action( ). Actions will be performed in the listed order. The set of allowed
events (e.g. docopen) and the type of actions (e.g. JavaScript) are documented separately
for the respective options.
List containing a single trigger with three actions:
action={ activate { 0 1 2 } }
List containing three triggers with one action for each:
action={ keystroke=0 format=1 validate=2 }
1.3 Fontsize, Color, and Action
13
1.4 Geometric Types
Line. A line is a list of four float values specifying the x and y coordinates of the start
and end point of a line segment. The coordinate system for interpreting the coordinates
(default or user coordinate system) varies depending on the option, and is documented
separately:
line = {10 40 130 90}
Polyline. A polyline is a list containing an even number n of float values with n>2. Each
pair in the list specifies the x and y coordinates of a point; these points will be connected
by line segments. The coordinate system for interpreting the coordinates (default or
user coordinate system) varies depending on the option, and is documented separately:
polyline = {10 20 30 40 50 60}
The following option lists are equivalent:
polyline = {10 20 30r 40r 50r 60r}
polyline = {10 20 40 60 90 120}
Quadrilaterals are a special type of polylines: these are rectangles which may be rotated
and for which exactly four points must be specified.
Another special type are polygons: these are polylines which will automatically be
closed by a line segment.
Rectangle. A rectangle is a list of four float values specifying the x and y coordinates of
the lower left and upper right corners of a rectangle. The coordinate system for interpreting the coordinates (default or user coordinate system) varies depending on the option, and is documented separately. Some options accept percentages, where the basis
for the percentage depends on the context (e.g. the fitbox of a Textflow). Relative coordinates can be supplied by adding the suffix r immediately after a number. Within a coordinate list a relative coordinate relates to the previous x or y coordinate. Relative coordinates at the beginning of a list relate to the origin, i.e. they are absolute coordinates.
Examples:
cropbox={ 0 0 500 600 }
box={40% 30% 50% 70%}
The following options are equivalent:
box={12 34 56r 78r}
box={12 34 68 112}
Circle. A circle is specified as a list of four float values where the first pair specifies the
x and y coordinates of the center, and the second pair specifies the x and y coordinates
of an arbitrary point on the circle. The coordinate system for interpreting the coordinates (default or user coordinate system) varies depending on the option, and is documented separately:
circle={200 325 200 200}
14
Chapter 1: Option Lists (Edition for COM, .NET, and REALbasic)
Curve list. A curve list consists of two or more connected third-order Bézier curve segments. A Bézier curve is specified by four control points. The first control point is the
starting point and the fourth point is the end point of the curve. The second and third
point control the shape of the curve. In a curve list the last point of a segment serves as
the first point for the next segment. A curve list is therefore specified as a list of 6 x n
float values with n¹2:
curve={200 700 240 600 80 580 400 660 400 660 440 620}
The last control point will become the new current point after drawing the curves.
1.4 Geometric Types
15
1.5 Limits
PDFlib imposes limits on certain entities in order to create PDF output which conforms
to the limitations imposed by the PDF Reference, Acrobat, or some PDF standard. These
limits are documented below.
The following limits will be enforced by suitably modifying the values:
> Smallest absolute floating point value in PDF: 0.000015. Numbers with a smaller absolute value will be replaced with 0.
> Largest absolute value which can be expressed as floating point number in PDF:
32768.0. Numbers with a larger absolute value will be replaced with the closest integer.
Violations of the following limits will result in an exception:
> Although PDFlib doesn’t have any static limits regarding the PDF output file size, it
must enforce certain limits when generating PDF/A-1, PDF/X-4 and PDF/X-5. See the
PDFlib Tutorial for details.
> Largest allowed numerical value in PDF: 2.147.483.647.
> Maximum length of hypertext strings: 65535.
> Maximum length of text strings on the page: 32.763 bytes (i.e. 16.381 characters for
CID fonts) if kerning=false and wordspacing=0; otherwise 4095 characters
> The following options are limited to a maximum of 8191 list entries:
views, namelist, polylinelist, fieldnamelist, itemnamelist, itemtextlist, children, group
> Maximum number of indirect objects in a PDF/A-1, PDF/X-4 or PDF/X-5 document:
8.388.607
16
Chapter 1: Option Lists (Edition for COM, .NET, and REALbasic)
2 General Functions
2.1 Function Scopes
PDFlib applications must obey certain structural rules which are easy to understand.
For example, you obviously begin a document before ending it. Since the PDFlib API is
closely modelled after the document/page paradigm, generating documents the »natural« way leads to well-formed PDFlib client programs. PDFlib enforces correct ordering
of function calls with a strict scoping system. The scope definitions can be found in Table 2.1. Figure 2.1 depicts the nesting of scopes. The function descriptions specify the allowed scope for each function. Calling a function outside of the allowed scopes will trigger an exception. You can query the current scope with the scope parameter.
Cookbook A full code sample can be found in the Cookbook topic general/function_scopes.
Table 2.1 Function scope definitions
scope name
definition
path
started by one of moveto( ), circle( ), arc( ), arcn( ), or rect( ), ellipse( );
terminated by any of the functions in Section 7.5, »Painting and Clipping«, page 123
page
between begin_page( ) and end_page( ) but outside of path scope
template
between begin_template_ext( ) and end_template_ext( ), but outside of path scope
pattern
between begin_pattern( ) and end_pattern() , but outside of path scope
font
between begin_font( ) and end_font( ), but outside of glyph scope
glyph
between begin_glyph( ) and end_glyph( ), but outside of path scope
document
between begin_document( )and end_document( ,) but outside of page, template, pattern, and font
scope
object
Anytime during the lifetime of the PDFlib object, but outside of document scope
null
object
document
page
page
path
...
pattern
page
font
glyph
page
path
page
glyph
page
...
path
template
path
glyph
path
path
...
page
path
template
document
page
pattern
font
glyph
path
Fig. 2.1
Nesting of scopes
2.1 Function Scopes
17
2.2 Parameter and Option Handling
PDFlib’s operation can be controlled by a variety of global parameters. There are string
parameters and numerical values for controlling PDFlib and the appearance of the PDF
output. Four functions are available for setting and retrieving numerical and string parameters. At the beginning of each section the relevant parameter key names and values are described; a summary of all supported parameters is available in Appendix B,
»List of all Parameters«.
These parameters will retain their settings across the life span of the PDFlib object, or
until they are explicitly changed by the client. However, some parameters will explicitly
be reset at the beginning of each page (this is mentioned in the respective descriptions).
VB RB Function get_value(key As String, modifier As Double) As Double
C# double get_value(String key, double modifier)
Get the value of some PDFlib parameter with numerical type.
key
The name of the parameter to be queried.
modifier An optional modifier to be applied to the parameter. Whether a modifier is
required and what it relates to is explained in the various parameter tables. If the modifier is unused it must be 0. Many parameters require handles to be passed as modifier.
Returns The numerical value of the parameter.
Scope Depends on key.
VB RB Sub set_value(key As String, value As Double)
C# void set_value(String key, double value)
Set the value of some PDFlib parameter with numerical type.
key
value
The name of the parameter to be set.
The new value of the parameter to be set.
Scope Depends on key.
VB RB Function get_parameter(key As String, modifier As Double) As String
C# String get_parameter(String key, double modifier)
Get the contents of some PDFlib parameter with string type.
key
The name of the parameter to be queried.
modifier An optional modifier to be applied to the parameter. Whether a modifier is
required and what it relates to is explained in the various parameter tables. If the modifier is unused it must be 0.
Returns The string value of the parameter as a hypertext string. The returned string can be used
until the end of the surrounding document scope. If no information is available an empty string will be returned.
18
Chapter 2: General Functions (Edition for COM, .NET, and REALbasic)
Scope Depends on key.
VB RB Sub set_parameter(key As String, value As String)
C# void set_parameter(String key, String value)
Set some PDFlib parameter with string type.
key
value
The name of the parameter to be set.
(Name string) The new value of the parameter to be set.
Scope Depends on key.
VB RB Sub set_option(optlist As String)
C# void set_option(String optlist)
Set one or more global options.
optlist An option list specifying global options according to Table 2.2. If an option is
provided more than once the last instance will override all previous ones. In order to
supply multiple values for a single option (e.g. searchpath) supply all values in a list argument to this option. The following options can be used:
filenamehandling, logging, resourcefile, searchpath, shutdownstrategy
Details Except for searchpath, the new value will override the old one. set_option( ) supports a
subset of the parameters of set_parameter( ).
Scope any
Table 2.2 Options for set_option( )
option
description
filenamehandling
(Keyword; not required on Windows) Target encoding for file names (default: unicode on Mac OS X, otherwise legacy):
ascii
7-bit ASCII
basicebcdic Basic EBCDIC according to code page 1047, but only Unicode values <= U+007E
basicebcdic_37
Basic EBCDIC according to code page 0037, but only Unicode values <= U+007E
honorlang The environment variable LANG will be interpreted and applied to file names if it specifies
utf8, UTF-8, cpXXXX, CPXXXX, iso8859-x, or ISO-8859-x.
legacy
Use host encoding (i.e. the current system encoding) to interpret the file name and interpret
the LANG variable if the honorlang parameter is set.
unicode
Unicode encoding in (EBCDIC-) UTF-8 format
all valid encoding names
Any (internal or user-defined) encoding recognized by PDFlib (see Table 4.3) except glyphid
and builtin
logging
(Option list) Logging options according to Table 2.8
resourcefile
(Name string) Relative or absolute file name of the PDFlib UPR resource file. The resource file will be loaded immediately. Existing resources will be kept; their values will be overridden by new ones if they are set
again.
2.2 Parameter and Option Handling
19
Table 2.2 Options for set_option( )
option
description
searchpath
(List of name strings) Relative or absolute path name(s) of a directory containing files to be read. The
search path can be set multiply; the entries will be accumulated and used in least-recently-set order (see
PDFlib Tutorial for details). An empty string deletes all existing search path entries. On Windows the
search path can also be set via a registry entry. Default: empty
shutdownstrategy
(Integer) Strategy for releasing global resources which are allocated once for all PDFlib objects. Each
global resource is initialized on demand when it is first needed. This option must be set to the same value
for all PDF objects in a process; otherwise the behavior is undefined (default: 0):
20
0
A reference counter keeps track of how many PDFlib objects use the resource. When the last
PDFlib object is deleted and the reference counter drops to zero, the resource is released.
1
The resource is kept until the end of the process. This may slightly improve performance, but
requires more memory after the last PDFlib object is deleted.
Chapter 2: General Functions (Edition for COM, .NET, and REALbasic)
2.3 Setup
Table 2.3 and Table 2.4 list relevant parameter and value key names for PDFlib setup (see
Section 2.2, »Parameter and Option Handling«, page 18).
Table 2.3 Setup-related keys for get/set_parameter( )
key
explanation
any resource
category
name
Entries in any of the resource categories. get_parameter( ): Modifier contains the index of the entry
(starting with 1). If there are no more entries an empty string will be returned. See PDFlib Tutorial for a
list of category names. Scope: any
filenamehandling
Target encoding for file names according to Table 2.2
honorlang
(Deprecated, use filenamehandling=honorlang instead) If true, the environment variable LANG will be
interpreted and applied to file names if it specifies utf8, UTF-8, cp1252, CP1252, iso8859-x, or ISO8859-x. Default: false. Scope: object
license1
Set the license key for PDFlib, PDFlib+PDI, or PPS. The key can be set before the first call to begin_
document( ). License keys for the wrong platform will silently be ignored; use the nodemostamp parameter to make sure that missing license keys will not accidentally result in a demo stamp. Scope: object
licensefile
Set the name of a file containing the license key. The license file can only be set once before the first call
to begin_document( ). Scope: object
nodemostamp
If true, an exception will be thrown when no valid license key was found; if false, a demo stamp will be
created on all pages. This option must be set before the first call to begin_document( ). Default: false.
Scope: object
resourcefile
Relative or absolute file name of the PDFlib UPR resource file. The resource file will be loaded immediately. Existing resources will be kept; their values will be overridden by new ones if they are set again. Scope:
any
scope2
Name of the current scope (see Table 2.1). Scope: any
SearchPath
Relative or absolute path name of a directory containing files to be read. The SearchPath can be set multiply; the entries will be accumulated and used in least-recently-set order. An empty string deletes all entries from the SearchPath list (including the default entries).
get_parameter( ): Modifier contains the index of the entry (starting with 1). If there are no more entries
an empty string will be returned. The returned string will be encoded in UTF-8. Scope: any
string2
Return a string identified by the string index supplied in the modifier. The returned string is valid until
the next call to any API function. Scope: any
version2
Full PDFlib version string in the format <major>.<minor>.<revision>, possibly suffixed with additional
qualifiers such as beta, rc, etc. Scope: any, null
1. Only for set_parameter( )
2. Only for get_parameter( )
2.3 Setup
21
Table 2.4 Setup-related keys for get/set_value( )
key
explanation
compress
Compression level from 0=no compression, 1=best speed, etc. to 9=best compression. This parameter
does not affect image data handled in passthrough mode. Default: 6. Scope: page, document
major minor
revision1
Major, minor, or revision number of PDFlib, respectively. Scope: any, null
maxfilehandles
(Unsupported; implemented on Windows only) New maximum for the number of simultaneously open
files (in the C runtime). The number must be greater or equal than 20 and less or equal than 2048. An exception will be thrown if the new value is not accepted by the C runtime. Scope: object
1. Only for get_value( )
22
Chapter 2: General Functions (Edition for COM, .NET, and REALbasic)
2.4 PDFlib Virtual File System (PVF)
Cookbook A full code sample can be found in the Cookbook topic general/starter_pvf.
VB RB Sub create_pvf(filename As String, data, optlist As String)
C# void create_pvf(String filename, byte[] data, String optlist)
Create a named virtual read-only file from data provided in memory.
filename (Name string; will be interpreted according to the global filenamehandling option or parameter, see Table 2.2) The name of the virtual file. This is an arbitrary string
which can later be used to refer to the virtual file in other PDFlib calls. The name of the
virtual file will be subject to the SearchPath mechanism if it uses only slash ’/’ characters
as directory or file name separators.
data A variant (in REALbasic: MemoryBlock) containing the data comprising the virtual file.
optlist
An option list according to Table 2.5. The following options can be used: copy
Details The virtual file name can be supplied to any API function which uses input files (virtual
files cannot be used for the generated PDF output; use an empty file name in begin_
document( ) to achieve this). Some of these functions may set a lock on the virtual file
until the data is no longer needed. Virtual files will be kept in memory until they are deleted explicitly with delete_pvf( ), or automatically in delete( ).
Each PDFlib object will maintain its own set of PVF files. Virtual files cannot be
shared among different PDFlib objects, but they can be used for creating multiple documents with the same PDFlib object. Multiple threads working with separate PDFlib objects do not need to synchronize PVF use. If filename refers to an existing virtual file an
exception will be thrown. This function does not check whether filename is already in
use for a regular disk file.
Unless the copy option has been supplied, the caller must not modify or free (delete)
the supplied data before a corresponding successful call to delete_pvf( ). Not obeying to
this rule will most likely result in a crash.
Scope any
Table 2.5 Options for create_pvf( )
option
description
copy
(Boolean) PDFlib will immediately create an internal copy of the supplied data. In this case the caller may
dispose of the supplied data immediately after this call. The copy option will automatically be set to true
in the COM, .NET, and Java bindings (default for other bindings: false). In other language bindings the
data will not be copied unless the copy option is supplied.
VB RB Function delete_pvf(filename As String) As Long
C# int delete_pvf(String filename)
Delete a named virtual file and free its data structures (but not the contents).
filename (Name string; will be interpreted according to the global filenamehandling option or parameter, see Table 2.2) The name of the virtual file as supplied to create_pvf( ).
2.4 PDFlib Virtual File System (PVF)
23
Returns -1 if the virtual file exists but is locked, and 1 otherwise.
Details If the file isn’t locked, PDFlib will immediately delete the data structures associated with
filename. If filename does not refer to a valid virtual file this function will silently do
nothing. After successfully calling this function filename may be reused. All virtual files
will automatically be deleted in delete( ).
The detailed semantics depend on whether or not the copy option has been supplied
to the corresponding call to create_pvf( ): If the copy option has been supplied, both the
administrative data structures for the file and the actual file contents (data) will be
freed; otherwise, the contents will not be freed, since the client is supposed to do so.
Scope any
24
Chapter 2: General Functions (Edition for COM, .NET, and REALbasic)
2.5 Exception Handling
Table 2.6 lists relevant options for this section. These options are supported by many
functions as indicated in the corresponding option list descriptions. These options can
also be used as parameter key name for get/set_parameter( ) (see Section 2.2, »Parameter
and Option Handling«, page 18).
Table 2.6 Exception-related keys for get/set_parameter( ) (also available as option)
key
explanation
errorpolicy
(Keyword) Controls the behavior of various functions in case of an error. The parameter errorpolicy can
be overridden by the errorpolicy option of many functions, and serves as default for this option. Supported keywords (default: legacy; scope: any):
legacy
(Deprecated) The behavior of the functions is the same as in PDFlib 6.
return
If an error occurs the function will return. Functions which can return an error code (e.g. load_
image( )) return -1. Functions which return result strings (e.g. fit_table( )) return the string _
error. Application developers must check the return value against -1 or _error to detect
error situations. In case of an error a detailed description can be queried with get_errmsg( ).
This setting is recommended for new applications.
exception If an error occurs, the function will throw an exception. The exception must be caught in
client code using a binding-specific mechanism. The partial PDF output generated so far will
be unusable and must be discarded.
VB RB Function get_errnum( ) As Long
C# int get_errnum( )
Get the number of the last thrown exception or the reason of a failed function call.
Returns The error code of the most recent error condition.
Scope Between an exception thrown by PDFlib and the death of the PDFlib object. Alternatively, this function may be called after a function returned a -1 error code, but before
calling any other function except those listed in this section.
Bindings In .NET and REALbasic this function is also available as get_errnum( ) in the PDFlibException object.
VB RB Function get_errmsg( ) As String
C# String get_errmsg( )
Get the text of the last thrown exception or the reason of a failed function call.
Returns Text containing the description of the most recent error condition.
Scope Between an exception thrown by PDFlib and the death of the PDFlib object. Alternatively, this function may be called after a function returned a -1 error code, but before
calling any other function except those listed in this section.
Bindings In .NET and REALbasic this function is also available as get_errmsg( ) in the PDFlibException object.
2.5 Exception Handling
25
VB RB Function get_apiname( ) As String
C# String get_apiname( )
Get the name of the API function which threw the last exception or failed.
Returns The name of the API function which threw an exception, or the name of the most recently called function which failed with an error code.
Scope Between an exception thrown by PDFlib and the death of the PDFlib object. Alternatively, this function may be called after a function returned a -1 error code, but before
calling any other function except those listed in this section.
Bindings In .NET and REALbasic this function is also available as get_apiname( ) in the PDFlibException object.
26
Chapter 2: General Functions (Edition for COM, .NET, and REALbasic)
2.6 Logging
The logging feature can be used to trace API calls. The contents of the log file may be
useful for debugging purposes, or may be requested by PDFlib GmbH support. Table 2.7
lists the parameter key names for the logging feature (see Section 2.2, »Parameter and
Option Handling«, page 18).
Table 2.7 Logging-related keys for set_parameter( )
key
explanation
logging
Option list with logging options according to Table 2.8
logmsg
String which will be copied to the log file
The logging options can be supplied in the following ways:
> As an option list for the logging option of set_option( ), e.g.:
p.set_option("logging", "filename=debug.log remove")
> As an option list for the logging option of set_parameter( ), e.g.:
p.set_parameter("logging", "filename=debug.log remove")
> In an environment variable called PDFLIBLOGGING. Doing so will activate the log output starting with the very first call to one of the API functions.
Table 2.8 Options for the logging parameter
key
explanation
(empty list)
Enable log output
disable
(Boolean) Disable logging output
enable
(Boolean) Enable logging output
filename
(String) Name of the log file; stdout and stderr will be recognized as special names. On CICS this option
will be ignored, and logging output will always be written to stderr. Output will be appended to any existing contents. Default:
pdflog
on MVS
PDFlib.log
on Mac and iSeries
\PDFlib.log
on Windows
/tmp/PDFlib.log
on all other systems
The log file name can alternatively be supplied in an environment variable called PDFLIBLOGFILE.
flush
(Boolean) If true, the log file will be closed after each output, and reopened for the next output to make
sure that the output will actually be flushed. This may be useful when chasing program crashes where
the log file is truncated, but significantly slows down processing. If false, the log file will be opened only
once. Default: false
remove
(Boolean) If true, an existing log file will be deleted before writing new output. Default: false
stringlimit
(Integer) Limit for the number of characters per line, or 0 for unlimited. Default: 0
2.6 Logging
27
Table 2.8 Options for the logging parameter
key
explanation
classes
(Option list) List containing options of type integer, where each option describes a logging class and the
corresponding value describes the granularity level. Level 0 disables a logging class, positive numbers enable a class. Increasing levels provide more and more detailed output. The following options are provided
(default: {api=1 warning=1}):
api
Log all API calls with their function parameters and results. If api=2 a timestamp will be
created in front of all API trace lines, and deprecated functions and options will be marked. If
api=3 try/catch calls will be logged (useful for debugging problems with nested exception
handling).
filesearch Log all attempts related to locating files via SearchPath or PVF.
resource
28
Log all attempts at locating resources via Windows registry, UPR definitions as well as the
results of the resource search.
user
User-specified logging output supplied with the logmsg parameter.
warning
Log all PDFlib warnings, i.e. error conditions which can be ignored or fixed internally. If
warning=2 messages from functions which do not throw any exception, but hook up the
message text for retrieval via get_errmsg( ), and the reason for all failed attempts at opening
a file (searching for a file in searchpath) will also be logged.
Chapter 2: General Functions (Edition for COM, .NET, and REALbasic)
3 Document and Page Functions
3.1 Document Functions
VB RB Function begin_document(filename As String, optlist As String) As Long
C# int begin_document(String filename, String optlist)
Create a new PDF document subject to various options.
filename (Name string; will be interpreted according to the global filenamehandling option or parameter, see Table 2.2) Absolute or relative name of the PDF output file to be
generated. If filename is empty, the PDF document will be generated in memory instead
of on file, and the generated PDF data must be fetched by the client with the get_buffer( )
function. On Windows it is OK to use UNC paths or mapped network drives.
optlist An option list specifying document options:
> General option: errorpolicy (see Table 2.6)
> Document options according to Table 3.1. Options specified in end_document( ) have
precedence over identical options specified in begin_document( ). The following options can be used:
attachmentpassword, attachments, autoxmp, compatibility, destination, groups, inmemory,
labels, lang, linearize, masterpassword, metadata, moddate, objectstreams, openmode,
optimize, pagelayout, pdfa, pdfx, permissions, rolemap2, search, tagged, tempdirname, uri,
userpassword, viewerpreferences
Returns -1 on error, and 1 otherwise. If filename is empty this function will always succeed, and
never return the -1 error value.
Details This function creates a new PDF file using the supplied filename. PDFlib will attempt to
open a file with the given name, and close the file when the PDF document is finished.
Scope object; this function starts document scope if the file could successfully be opened, and
must always be paired with a matching end_document( ) call.
Bindings ASP: the MapPath facility should be used to construct full path names to be passed to
this function.
VB RB Sub end_document(optlist As String)
C# void end_document(String optlist)
Close the generated PDF document and apply various options.
optlist An option list specifying document processing options:
> General options: errorpolicy (see Table 2.6)
> Document options according to Table 3.1. Options specified in end_document( ) have
precedence over identical options specified in begin_document( ). The following options can be used:
action, attachmentpassword, attachments, autoxmp, createpvf, destination, destname,
3.1 Document Functions
29
labels, metadata, moddate, objectstreams, openmode, pagelayout, portfolio, rolemap2,
search, uri, viewerpreferences
Details This function finishes the generated PDF document, frees all document-related resources, and closes the output file if the PDF document has been opened with begin_
document( ). This function must be called when the client is done generating pages, regardless of the method used to open the PDF document.
When the document was generated in memory (as opposed to on file), the document
buffer will still be kept after this function is called (so that it can be fetched with get_
buffer( )), and will be freed in the next call to begin_document( ), or when the PDFlib object goes out of scope.
Scope document; this function terminates document scope, and must always be paired with a
matching call to PDF_begin_document( ).
Table 3.1 Document options for begin_document( ) and end_document( )
option
action
description
1
(Action list; not allowed for PDF/A) List of document actions for one or more of the following events. Default: empty list.
open
Actions to be performed when the document is opened. Due to the execution order in Acrobat
document-level JavaScript must not be used for open actions.
didprint/didsave/willclose/willprint/willsave
(PDF 1.4) JavaScript actions to be performed after printing/after saving/before closing/before
printing/ before saving the document.
attachmentpassword2, 3
(String; PDF 1.6; will be ignored if userpassword or masterpassword are set; can not be combined with
the linearize and optimize options) File attachments will be encrypted using the supplied string as
password. The rest of the document will not be encrypted.
attachments (List of option lists) Specifies document-level file attachments (as opposed to attachment annotations
which are bound to a particular location on a page). It is ok to supply file attachments both in begin_
document( ) and end_document( ). Supported options:
description (Hypertext string; PDF 1.6) Descriptive text associated with the file.
filename
(Hypertext string; required) Name of the file. Unicode file names are supported, but require
PDF 1.7 for correct display in Acrobat.
mimetype (String) MIME type of the file; Acrobat will use it for launching the appropriate application
when the attachment is activated.
name
autoxmp
30
(Hypertext string) Name of the attachment. Default: filename without any path components
(Boolean; will be forced to true in PDF/X-3/4/5 and PDF/A-1 modes) If true, PDFlib will create XMP document metadata from document info fields (see Section 14.2, »XMP Metadata«, page 209). Default: false
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
Table 3.1 Document options for begin_document( ) and end_document( )
option
description
2
compatibility
(Keyword; will be ignored if one of the pdfx or pdfa options is used with a value different from none) Set
the document’s PDF version to one of the keywords listed below. This option affects which PDF creation
features are available and which PDF documents can be imported with PDFlib+PDI (default: 1.7):
1.3
PDF 1.3 requires Acrobat 4 or above.
1.4
PDF 1.4 requires Acrobat 5 or above.
1.5
PDF 1.5 requires Acrobat 6 or above.
1.6
PDF 1.6 requires Acrobat 7 or above.
1.7
PDF 1.7 is specified in ISO 32000-1 and requires Acrobat 8 or above.
1.7ext3
PDF 1.7 extension level 3 requires Acrobat 9 or above.
1.7ext8
PDF 1.7 extension level 8 requires Acrobat X.
createpvf2
(Boolean) If true, generate the PDF file in memory instead of on file. The supplied file name is the name
of a virtual file which will be created with the call of end_document( ). In this case get_buffer( ) cannot
be called to fetch the PDF output data; instead, the name of the generated PVF file can be supplied to
other PDFlib functions. This may be useful when generating documents which will be included in a PDF
Portfolio. Default: false
destination
(Option list; will be ignored if an open action has been specified) An option list specifying the document
open action according to Table 12.5.
destname1
(Hypertext string; will be ignored if the destination option has been specified) The name of a destination which has been defined with add_nameddest( ), and will be used as the document open action.
groups2
(List of strings) Define the names and ordering of the page groups used in the document. Page groups
keep pages together (useful e.g. for attaching page labels); pages can be assigned to one of the page
groups defined in the document, and referenced within the respective group. If page groups are defined
for a document, all pages must be assigned to a page group.
inmemory2
(Boolean) If true and the linearize or optimize option is true as well, PDFlib will not create any temporary files for linearization, but will process the file in memory. This can result in tremendous performance gains on some systems (especially MVS), but requires memory twice the size of the document. If
false, a temporary file will be created for linearization and optimization. Default: false
labels
(List of option lists) A list containing one or more option lists according to Table 3.2 specifying symbolic
page names. The page name will be displayed as a page label (instead of the page number) in Acrobat’s
status line. The combination of style/prefix/start must be unique within a document. Default: none
lang2
(String; recommended if tagged=true) Set the natural language of the document as a two-character
ISO 639 language code (examples: DE, EN, FR, JA), optionally followed by a hyphen and a two-character
ISO 3166 country code (examples: EN-US, EN-GB, ES-MX). Case is not significant.
The language specification can be overridden for individual items on all levels of the structure tree, but
must be set initially for the document as a whole.
linearize2
(Boolean) If true, the output document will be linearized. Default: false
masterpassword2, 3
(String; required if permissions has been specified; not for PDF/A and PDF/X) The master password for
the document. If it is empty no master password will be applied. Default: empty
metadata
(Option list; PDF 1.4) Supply XMP document metadata (see Section 14.2, »XMP Metadata«, page 209). The
XMP will overwrite document info entries supplied with set_info( ). In PDF/A mode the supplied XMP
metadata must conform to additional requirements (see PDFlib Tutorial).
moddate
(Boolean) If true, the ModDate (modification date) document info key will be created for compliance with
some preflight tools. Default: false
3.1 Document Functions
31
Table 3.1 Document options for begin_document( ) and end_document( )
option
description
objectstreams
2
(List of keywords; PDF 1.5; will be forced to false if optimize or linearize is true) Generate compressed
object streams which significantly reduce output file size (default: {other nodocinfo}):
bookmarksCompress bookmark objects.
docinfo
Compress document info fields.
fields
Compress form fields.
names
Compress objects for named destinations.
none
Don’t generate any compressed object streams (except for categories which are explicitly enabled after this option).
other
All categories which are not explicitly disabled after this keyword, plus other object types
which don’t have their own keyword.
pages
Compress the objects comprising the page tree.
tags
Compress marked content tags.
xref
Generate a compressed xref stream. This category will automatically be enabled if at least
one of the other categories is enabled.
Except for none and other, all keywords can be prefixed with no (e.g. nodocinfo) to disable compression
for the specified category. If at least one such negative keyword is supplied, the keyword other will be
prepended to the list.
openmode
2
optimize
pagelayout
2
(Keyword) Set the appearance when the document is opened. Default: bookmarks if the document contains any bookmarks, otherwise none.
none
Open with no additional panel visible.
bookmarks
Open with the bookmark panel visible.
thumbnails
Open with the thumbnail panel visible.
fullscreen
Open in fullscreen mode (does not work in the browser).
layers
(PDF 1.5) Open with the layer panel visible.
attachments
(PDF 1.6) Open with the attachments panel visible.
(Boolean) If true, the output document will be optimized in a separate pass after generating it. Optimization reduces file size by eliminating redundant duplicate objects. In general optimization will not have
any significant effect except for inefficient client code (e.g. loading the same image or ICC profile multiply instead of reusing the handle). Default: false
(Keyword) The page layout to be used when the document is opened. Default: default.
default
The default setting of the Acrobat viewer.
singlepage
Display one page at a time.
onecolumn
Display the pages continuously in one column.
twocolumnleft
Display the pages in two columns, odd pages on the left.
twocolumnright
Display the pages in two columns, odd pages on the right
twopageleft
(PDF 1.5) Display the pages two at a time, with odd-numbered pages on the left.
twopageright
(PDF 1.5) Display the pages two at a time, with odd-numbered pages on the right.
pdfa
(Keyword) Set the PDF/A conformance level to one of PDF/A-1a:2005, PDF/A-1b:2005, or none. The value
PDF/A-1a:2005 will automatically enable Tagged PDF mode. PDF/A-1 output can at the same time conform to the PDF/X-1a:2003, PDF/X-3:2003, and PDF/X-4 settings of the pdfx option. Default: none
pdfx2
(Keyword) Set the PDF/X conformance level to one of PDF/X-1a:2001, PDF/X-1a:2003, PDF/X-3:2002,
PDF/X-3:2003, PDF/X-4, PDF/X-4p, PDF/X-5g, PDF/X-5pg, or none. Default: none
32
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
Table 3.1 Document options for begin_document( ) and end_document( )
option
description
permissions
2
(Keyword list; not for PDF/A and PDF/X) The access permission list for the output document. It contains
any number of the following keywords (default: empty):
noprint
Acrobat will prevent printing the file.
nohiresprint
(PDF 1.4) Acrobat will prevent high-resolution printing. If noprint isn’t set, printing is restricted to the »print as image« feature which prints a low-resolution rendition of the page.
nomodify Acrobat will prevent editing or cropping pages and creating or changing form fields.
noassemble (PDF 1.4; implies nomodify) Acrobat will prevent inserting, deleting, or rotating pages and
creating bookmarks and thumbnails.
noannots Acrobat will prevent creating or changing annotations and form fields.
noforms
(PDF 1.4; implies nomodify and noannots) Acrobat will prevent form field filling.
nocopy
Acrobat will prevent copying and extracting text or graphics; the accessibility interface will
be controlled by noaccessible.
noaccessible
(PDF 1.4) Acrobat will prevent extracting text or graphics for accessibility purposes (such as a
screenreader program).
plainmetadata
(PDF 1.5) Keep XMP document metadata unencrypted even for encrypted documents.
portfolio1
2
(Option list) Suboptions for creating a PDF portfolio according to Table 12.15
rolemap
(List of pairs; the first entry in each pair is a name string, the second entry is a string; only for Tagged PDF)
Mapping of custom element types to standard element types. Each pair contains the name of a standard
or custom element type and the name of the standard element type to which the custom type will be
mapped. Standard element type names can be mapped to other types in order to assign different semantics to existing element types. See Section 14.3, »Tagged PDF«, page 210, regarding the use of custom element types in Tagged PDF.
search
(Option list) Instruct Acrobat to attach a search index when opening the document. The following suboptions are supported:
filename (Hypertext string; required) The name of a file containing a search index. The file name of the
index may be relative to the document, but the user is responsible for supplying correct index
file names.
indextype (Name string) The type of the index; must be PDX for Acrobat. Default: PDX
tagged
2
(Boolean; PDF 1.4) If true, generate Tagged PDF output. Proper structure information must be provided
by the client in Tagged PDF mode (see Section 14.3, »Tagged PDF«, page 210). If the pdfa option has the
value »PDF/A-1a:2005« this option will automatically be forced to true. Default: false
tempdirname2 (String) Directory where temporary files for the linearize and optimize options will be created. If empty, PDFlib will generate temporary files in the current directory. This option will be ignored if the
tempfilenames option has been supplied. Default: empty
uri
(String) Set the document’s base URL. This is useful when a document with relative Web links is moved to
a different location. Adjusting the base URL makes sure that relative links will still work. Default: none
userpassword2, 3
(String; not for PDF/A and PDF/X) The user password for the document. If it is empty no user password
will be applied. Default: empty
viewerpreferences
(Option list) Option list specifying various viewer preferences according to Table 3.3. Default: empty
1. Only for end_document( )
2. Only for begin_document( )
3. Characters outside of Winansi encoding are only allowed in passwords if PDF 1.7 extension level 3 or higher is generated.
3.1 Document Functions
33
Table 3.2 Suboptions for the labels option in begin/end_document( ) and label option in begin/end_page_ext( )
option
description
group
(String; only for begin_document( ); required if the document uses page groups, but not allowed otherwise) The label will be applied to all pages in the specified group and all pages in all subsequent groups
until a new label is applied. The group name must have been defined with the groups option in begin_
document( ).
pagenumber (Integer; only for end_document( ); required if the document does not use page groups, but not allowed
otherwise) The label will be applied to the specified page and subsequent pages until a new label is applied.
prefix
(Hypertext string) The label prefix for all labels in the range. Default: none
start
(Integer >= 1) Numeric value for the first label in the range. Subsequent pages in the range will be numbered sequentially starting with this value. Default: 1
style
(Keyword) The numbering style to be used. Default: none.
34
none
no page number; labels will only consist of the prefix.
D
decimal arabic numerals (1, 2, 3, ...)
R
uppercase roman numerals (I, II, III, ...)
r
lowercase roman numerals (i, ii, iii, ...)
A
uppercase letters (A, B, C, ..., AA, BB, CC, ...)
a
lowercase letters (a, b, c, ..., aa, bb, cc, ...)
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
Table 3.3 Suboptions for the viewerpreferences option in begin_document( ) and end_document( )
option
description
centerwindow (Boolean) Specifies whether to position the document’s window in the center of the screen. Default:
false
direction
(Keyword) The reading order of the document, which affects the scroll ordering in double-page view and
the side (left/right) of the first page for double-page layout in Acrobat (default l2r):
l2r
Left to right
r2l
Right to left (including vertical writing systems)
displaydoctitle (Boolean) Specifies whether to display the Title document info field in Acrobat’s title bar (true) or the
file name (false). Default: false
duplex
(Keyword; PDF 1.7) Paper handling option for the print dialog (default: none):
DuplexFlipShortEdge
Duplex and flip on the short edge of the sheet.
DuplexFlipLongEdge
Duplex and flip on the long edge of the sheet.
fitwindow
No paper handling specified.
Simplex
Print single-sided.
(Boolean) Specifies whether to resize the document’s window to the size of the first page. Default: false
1
(Boolean) Specifies whether to hide Acrobat’s menu bar. Default: false
1
(Boolean) Specifies whether to hide Acrobat’s tool bars. Default: false
hidemenubar
hidetoolbar
none
hidewindowui1
(Boolean) Specifies whether to hide Acrobat’s window controls. Default: false
nonfullscreenpagemode
(Keyword; only relevant if the openmode option is set to fullscreen) Specifies how to display the document on exiting full-screen mode. Default: none
bookmarks
display page and bookmark pane
thumbnails
display page and thumbnail pane
layers
display page and layer pane
none
display page only
numcopies
(Integer in the range 1-5, PDF 1.7) The number of copies for the print dialog. Default: viewer-specific
picktraybypdfsize
(Boolean; PDF 1.7; no effect on Mac OS) Specifies whether the PDF page size is used to select the input paper tray in the print dialog. Default: viewer-specific
printscaling
(Keyword; PDF 1.6) Page scaling option to be selected when a print dialog is presented for the document.
Supported keywords (default: appdefault):
none
No page scaling; this may be useful for printing page contents at their exact sizes.
appdefault Use the current print scaling as specified in Acrobat.
printpagerange
(List with pairs of integers; PDF 1.7) Page numbers for the print dialog. Each pair denotes the start and
end page numbers of a page range to be printed (first page is 1). Default: viewer-specific
printarea
printclip
viewarea
viewclip
(Keyword; for PDF/X only media and bleed are allowed) The type of the page boundary box representing
the area of a page to be displayed or clipped when viewing the document on screen or printing it. Acrobat ignores this setting, but it may be useful for other applications. Supported keywords (default: crop):
art
Use the ArtBox
bleed
Use the BleedBox
crop
Use the CropBox
media
Use the MediaBox
trim
Use the TrimBox
3.1 Document Functions
35
1. Acrobat 8 and above does not support the combination of hidemenubar, hidetoolbar, and hidewindowui (i.e. all user interface elements hidden). The menu bar will still be visible if all three elements are set to hidden.
36
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
3.2 Fetching PDF Documents from Memory
If a non-empty filename parameter has been supplied to begin_document( ) PDFlib will
write PDF documents to a named disk file. Alternatively, PDF document data will be
generated in memory if the filename parameter is empty. In this case the PDF document
data must be fetched from memory with get_buffer( ). This is especially useful when
shipping PDF from a Web server.
VB RB Function get_buffer( )
C# byte[] get_buffer( )
Get the contents of the PDF output buffer.
Returns A buffer full of binary PDF data for consumption by the client. Most COM clients will use
a Variant type to hold the buffer contents. JavaScript with COM does not allow to retrieve the length of the returned variant array (but it does work with other languages
and COM). The returned buffer must be used by the client before calling any other PDFlib function. Remember to copy the data if you want to use it while calling other PDFlib
functions (in particular, before calling create_pvf( ) to create a PVF file containing the data).
Details Fetch the full or partial buffer containing the generated PDF data. If this function is
called between page descriptions, it will return the PDF data generated so far. If generating PDF into memory, this function must at least be called after end_document( ), and
will return the remainder of the PDF document. It can be called earlier to fetch partial
document data. If there is only a single call to this function which happens after end_
document( ) the returned buffer is guaranteed to contain the complete PDF document in
a contiguous buffer.
Since PDF output contains binary characters, client software must be prepared to accept non-printable characters including null values.
Scope object, document (in other words: after end_page_ext( ) and before begin_page_ext( ), or
after end_document( ) and before delete( ). This function can only be used if an empty
filename has been supplied to begin_document( ).
If the linearize option in begin_document( ) has been set to true, the scope is restricted
to object, i.e. this function can only be called after end_document( ).
3.2 Fetching PDF Documents from Memory
37
3.3 Page Functions
Table 3.4 and Table 3.5 list relevant parameter and value key names for this section (see
Section 2.2, »Parameter and Option Handling«, page 18).
Table 3.4 Page-related keys for get/set_parameter( )
key
explanation
topdown
If true, the origin of the coordinate system at the beginning of a page, pattern, or template will be assumed in the top left corner of the page, and y coordinates will increase downwards; otherwise the default coordinate system will be used. See PDFlib Tutorial for details. Scope: document. Default: false
Table 3.5 Page-related keys for get/set_value( )
key
explanation
pagewidth
pageheight
Get the page size of the current page (dimensions of the MediaBox). Scope: page, path
VB RB Sub begin_page_ext(width As Double, height As Double, optlist As String)
C# void begin_page_ext(double width, double height, String optlist)
Add a new page to the document and specify various options.
width, height The width and height parameters are the dimensions of the new page in
points (or user units, if the userunit option has been specified). They can be overridden
by the options with the same name (the dummy value 0 can be used for the parameters
in this case). A list of commonly used page formats can be found in Table 3.6. The PDFlib
Tutorial lists applicable page size limits in Acrobat. See also Table 3.7 for more details
(options width and height).
Table 3.6 Common standard page size dimensions in points1
format
width
height
format
width
height
format
width
height
a0
2380
3368
a4
595
842
letter
612
792
a1
1684
2380
a5
421
595
legal
612
1008
a2
1190
1684
a6
297
421
ledger
1224
792
a3
842
1190
11x17
792
1224
1. More information about ISO, Japanese, and U.S. standard formats can be found at
www.cl.cam.ac.uk/~mgk25/iso-paper.html
optlist An option list according to Table 3.7. These options have lower priority than
identical options specified in end_page_ext( ). The following options can be used:
action, artbox, bleedbox, cropbox, defaultcmyk, defaultgray, defaultrgb, duration, group,
height, label, mediabox, metadata, pagenumber, rotate, separationinfo, taborder, topdown,
transition, transparencygroup, trimbox, userunit, viewports, width
Details This function resets all text, graphics, and color state parameters for the new page to
their defaults.
38
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
Scope document; this function starts page scope, and must always be paired with a matching
end_page_ext( ) call.
VB RB Sub end_page_ext(optlist As String)
C# void end_page_ext(String optlist)
Finish a page and apply various options.
optlist An option list according to Table 3.7. Options specified in end_page_ext( ) have
priority over identical options specified in begin_page_ext( ). The following options can
be used:
action, artbox, bleedbox, cropbox, defaultcmyk, defaultgray, defaultrgb, duration, group,
height, label, mediabox, metadata, rotate, taborder, transition, transparencygroup, trimbox,
userunit, viewports, width
Scope page; this function terminates page scope, and must always be paired with a matching
begin_page_ext( ) call.
Table 3.7 Page options for begin_page_ext( ) and end_page_ext( )
option
description
action
(Action list) List of page actions for one or more of the following events (default: empty list):
open
Actions to be performed when the page is opened.
close
Actions to be performed when the page is closed.
artbox
bleedbox
cropbox
(Rectangle) Specify the ArtBox, BleedBox, or CropBox for the current page, respectively. The coordinates
are specified in the default coordinate system. Default: no box entries
defaultgray
defaultrgb
defaultcmyk
(ICC handle) Set a default gray, RGB, or CMYK color space for the page according to the supplied profile
handle.
duration
(Float) Set the page display duration in seconds for the current page if openmode=fullscreen (see Table
3.1). Default: 1
group1
(String; required if the document uses page groups, but not allowed otherwise) Name of the page group
to which the page will belong. This name can be used to keep pages together in a page group and to address pages with resume_page( ). The group name must have been defined with the groups option in
begin_document( ).
height
(Float or keyword; not allowed if the topdown option or parameter is true) The dimensions of the new
page in points (or user units, if the userunit option has been specified). In order to produce landscape
pages use width > height or the rotate option. PDFlib uses width and height to construct the page’s
MediaBox, but the MediaBox can also explicitly be set using the mediabox option. The width and height
options will override the parameters with the same name.
The following symbolic page size names can be used as keywords by appending .width or .height (e.g.
a4.width, a4.height):
a0, a1, a2, a3, a4, a5, a6, b5, letter, legal, ledger, 11x17
label
(Option list) An option list according to Table 3.2 specifying symbolic page names. The page name will be
displayed as a page label (instead of the page number) in Acrobat’s status line. The specified numbering
scheme will be used for the current and subsequent pages until it is changed again. The combination of
style/prefix/start values must be unique within a document.
3.3 Page Functions
39
Table 3.7 Page options for begin_page_ext( ) and end_page_ext( )
option
description
mediabox
(Rectangle; not allowed if the topdown option or parameter is true) Change the MediaBox for the current page. The coordinates are specified in the default coordinate system. By default, the MediaBox will
be created by using the width and height parameters. The mediabox option will override the width and
height options and parameters.
metadata
pagenumber
(Option list; PDF 1.4) Supply metadata for the page (see Section 14.2, »XMP Metadata«, page 209)
1
(Integer) If this option is specified with a value n, the page will be inserted before the existing page n
within the page group specified in the group option (or the document if the document doesn’t use page
groups). If this option is not specified the page will be inserted at the end of the group.
rotate
(Integer) The page rotation value. The rotation will affect page display, but does not modify the coordinate system. Possible values are 0, 90, 180, 270. Default: 0
separationinfo1
(Option list) An option list containing color separation details for the current page. This will be ignored in
Acrobat, but may be useful in third-party software for identifying and correctly previewing separated
pages in a preseparated workflow:
pages
(Integer; required for the first page of a set of separation pages, but not allowed for subsequent pages of the same set) The number of pages which belong to the same set of separation pages comprising the color data for a single composite page. All pages in the set must
appear sequentially in the file.
spotname (String; required unless spotcolor has been supplied) The name of the colorant for the current page.
spotcolor (Spot color handle) A color handle describing the colorant for the current page.
taborder
(Keyword; PDF 1.5) Keyword specifying the tab order for form fields and annotations on the page (Default: none):
column
Form fields and annotations are visited column by column from top to bottom, where columns are ordered as specified by the direction suboption of the viewerpreferences option
of begin/end_document( ).
none
The tab order is unspecified.
structure Form fields and annotations are visited in the order in which they appear in the structure
tree. The order for annotations that are not included in the structure tree is unspecified.
row
topdown1
40
Form fields and annotations are visited row by row starting at the topmost row, where the
direction within a row is as specified by the direction suboption of the viewerpreferences
option of begin/end_document( ).
(Boolean) If true, the origin of the coordinate system at the beginning of the page will be assumed in the
top left corner of the page, and y coordinates will increase downwards; otherwise the default coordinate
system will be used. Default: false
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
Table 3.7 Page options for begin_page_ext( ) and end_page_ext( )
option
description
transition
(Keyword) Set the page transition for the current page in order to achieve special effects which may be
useful when displaying the PDF in Acrobat’s fullscreen mode as presentations if openmode=fullscreen
(see Table 3.1). Default: replace
split
Two lines sweeping across the screen reveal the page
blinds
Multiple lines sweeping across the screen reveal the page
box
A box reveals the page
wipe
A single line sweeping across the screen reveals the page
dissolve
The old page dissolves to reveal the page
glitter
The dissolve effect moves from one screen edge to another
replace
The old page is simply replaced by the new page
fly
(PDF 1.5) The new page flies into the old page.
push
(PDF 1.5) The new page pushes the old page off the screen
cover
(PDF 1.5) The new page slides on to the screen and covers the old page.
uncover
(PDF 1.5) The old page slides off the screen and uncovers the new page.
fade
(PDF 1.5) The new page gradually becomes visible through the old one.
transparency (Option list; PDF 1.4; not allowed for PDF/A, PDF/X-1, and PDF/X-3; certain rules apply for PDF/X-4 and
group
PDF/X-5, see PDFlib Tutorial) Specifies transparency group attributes for the generated page, an imported page, or a template. Supported options:
colorspace (Keyword; required) Specifies the color space of the transparency group with one of the following keywords: DeviceGray, DeviceRGB, DeviceCMYK.
isolated
(Boolean) Specifies whether the transparency group is isolated. Default: false
knockout (Boolean) Specifies whether the transparency group is a knockout group. Default: false
Default: if a page contains image masks with more than 1 bit or the opacityfill/opacitystroke options of create_gstate( ) the following option list will automatically be created to improve output quality: transparencygroup={colorspace=DeviceRGB}
trimbox
(Rectangle) Specify the TrimBox for the current page. The coordinates are specified in the default coordinate system. Default: no TrimBox entry
userunit
(Float or keyword; PDF 1.6) A number in the range 1..75 000 specifying the size of a user unit in points, or
one of the keywords mm, cm, or m which scales to the respective unit. User units don’t change the actual
page contents; they are only a hint to Acrobat which is used when printing the page or using the measurement tools. Default: 1 (i.e. one unit is one point)
viewports
(List of option lists; PDF 1.7ext3) Specifies one or more georeferenced areas (viewports) on the page; see
Section 13.2, »Geospatial Features«, page 205, for details.
Viewports allow different geospatial references (specified by the georeference option) to be used on different areas of the page, e.g. for multiple maps. The ordering of the option lists in the viewports list is
relevant for overlapping viewports: the last viewport which contains a point will be used for that point.
width
(Float or keyword; not allowed if the topdown option or parameter is true) See height option above.
1. Only for begin_page_ext( )
3.3 Page Functions
41
VB RB Sub suspend_page(optlist As String)
C# void suspend_page(String optlist)
Suspend the current page so that it can later be resumed.
optlist
An option list for future use.
Details The full graphics (graphics, color, text, etc.) and layer state of the current page will be
saved internally. It can later be resumed with resume_page( ) to add more content. Suspended pages must be resumed before they can be closed.
Scope page; this function starts document scope, and must always be paired with a matching
resume_page( ) call. This function must not be used in Tagged PDF mode.
VB RB Sub resume_page(optlist As String)
C# void resume_page(String optlist)
Resume a page to add more content to it.
optlist An option list according to Table 3.8. The following options can be used:
group, pagenumber
Details The page must have been suspended with suspend_page( ). It will be opened again so
that more content can be added. All suspended pages must be resumed before they can
be closed, even if no more content has been added.
Scope document; this function starts page scope, and must always be paired with a matching
suspend_page( ) call.
Table 3.8 Options for resume_page( )
option
description
group
(String; required if the document uses page groups, but not allowed otherwise) Name of the page group
of the resumed page. The group name must have been defined with the groups option in begin_
document( ).
pagenumber (Integer) If this option is supplied, the page with the specified number within the page group chosen in
the group option (or in the document if the document doesn’t use page groups) will be resumed. If this
option is missing the last page in the group will be resumed.
42
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
3.4 Layers
Cookbook A full code sample can be found in the Cookbook topic graphics/starter_layer.
VB RB Function define_layer(name As String, optlist As String) As Long
C# int define_layer(String name, String optlist)
Create a new layer definition (requires PDF 1.5).
name
(Hypertext string) The name of the layer.
optlist An option list specifying layer settings according to Table 3.9. The following options can be used:
> Layer control options:
creatorinfo, defaultstate, initialexportstate, initialprintstate, initialviewstate, intent,
language, onpanel, pageelement, printsubtype, removeunused, zoom
Returns A layer handle which can be used in calls to begin_layer( ) and set_layer_dependency( ) until the end of the enclosing document scope.
Details PDFlib will issue a warning if a layer was defined but hasn’t been used in the document.
Layers which are used on multiple pages should be defined only once (e.g. before creating the first page). If define_layer( ) is called repeatedly on multiple pages, the layer definitions will accumulate (even if they have the same name), which is usually not desired.
PDF/X: Layers are not allowed in PDF/X-1/2/3. In order to use layers with PDF/X-4 or
PDF/X-5 some options are restricted, and at least two layer variants must be specified in
set_layer_dependency( ).
Scope document, page
Table 3.9 Options for define_layer( )
option
explanation
creatorinfo
(Option list; not for PDF/X) An option list describing the content and the creating application. Both of the
following entries are required if this option is used:
creator
(Hypertext string) The name of the application which created the layer
subtype
(String) The type of content. Suggested values are Artwork and Technical.
defaultstate
(Boolean) Specifies whether or not the layer will be visible by default. Default: true
initialexportstate
(Boolean; not for PDF/X) Specifies the layer’s recommended export state. If true, Acrobat will include the
layer when converting/exporting to older PDF versions or other document formats. Default: true
initialprintstate
(Boolean; not for PDF/X) The layer’s recommended printing state. If true, Acrobat will include the layer
when printing the document. Default: true
initialviewstate
(Boolean; not for PDF/X) The layer’s recommended viewing state. If true, Acrobat will display the layer
when opening the document. Default: true
intent
(Keyword) Intended use of the graphics: View or Design. Default: View
language
(Option list; not for PDF/X) Specifies the language of the layer:
lang
(String; required) The language and possibly locale in the format described in Table 3.1 for the
lang option
preferred (Boolean) If true this layer is used if there is only a partial match between the layer and the
system language. Default: false
3.4 Layers
43
Table 3.9 Options for define_layer( )
option
explanation
onpanel
(Boolean; not for PDF/X) If false, the layer name will not be visible in Acrobat’s layer panel, and therefore cannot be manipulated by the user. Default: true
pageelement (Keyword; not for PDF/X) Specifies that the layer contains a pagination artifact: one of HF (header/footer), FG (foreground image or graphic), BG (background image or graphic), or L (logo).
printsubtype (Option list; not for PDF/X) Specifies whether the layer is intended for printing:
subtype
(Keyword) One of Trapping, PrintersMarks, or Watermark specifying the kind of content in
the layer.
printstate (Boolean) If true, Acrobat will activate the layer contents upon printing.
removeunused (Boolean) If true and the layer is not used on a page, the layer will not be included in the page’s layer list.
A layer is considered in use on a page if it has been supplied to begin_layer( ) at least once on that page.
Default: false unless the layer is included in a non-default variant with listmode=visiblepages.
zoom
(List of floats or percentages; not for PDF/X) One or two values specifying the layer’s visibility depending
on the zoom factor (1.0 means a zoom factor of 100 percent). If one value is provided, it will be used as
the maximum zoom factor at which the layer should be visible; if two values are provided they specify
the minimum and maximum zoom factor. The keyword maxzoom can be used to specify the largest possible zoom factor.
VB RB Sub set_layer_dependency(type As String, optlist As String)
C# void set_layer_dependency(String type, String optlist)
Define layer relationships and variants (requires PDF 1.5).
type
The type of dependency or relationship according to Table 3.10.
Table 3.10 Dependency and relationship types for layers
type
notes; options specific for this type
GroupAllOn
(Not for PDF/X) The layer specified in the depend option will be visible if all layers specified in the group
option are visible. Options specific for this type: depend, group
GroupAnyOn (Not for PDF/X) The layers specified in the depend option will be visible if any layer specified in the group
option is visible. Options specific for this type: depend, group
GroupAllOff
(Not for PDF/X) The layer specified in the depend option will be visible if all layers specified in the group
option are invisible. Options specific for this type: depend, group
GroupAnyOff
(Not for PDF/X) The layer specified in the depend option will be visible if any layer specified in the group
option is invisible. Options specific for this type: depend, group
Lock
(PDF 1.6) The layers specified in the group option will be locked, i.e. their state cannot be changed interactively in Acrobat. Options specific for this type: group
Parent
(Not for PDF/X) Specify a hierarchical relationship between the layer specified in the parent option and
the layers specified in the children option. A layer can not belong to more than one parent layer. Options specific for this type: children, parent
Radiobtn
Specify a radiobutton relationship between the layers specified in the group option. This means that at
most one layer in the group will be visible at a time, which is particularly useful for multiple language
layers. Option specific for this type: group
Title
(Not for PDF/X) The layer handle specified in the parent option does not control any page contents directly, but serves as the parent layer node for the layers specified in the children option. Options specific
for this type: children, parent
44
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
Table 3.10 Dependency and relationship types for layers
type
notes; options specific for this type
Variant
Specify a document variant, i.e. a combination of one or more layers. Later calls to set_layer_
dependency( ) can supply the variantname option again in order to specify dependency rules for this configuration. Options specific for this type: basestate, defaultvariant, includelayers,
invisiblelayers, visiblelayers
optlist An option list specifying layer dependencies according to Table 3.11. The following options can be used:
> Layer dependency options:
basestate, children, createorderlist, defaultvariant, depend, includelayers, invisiblelayers,
group, visiblelayers, listmode, parent, variantname.
Details Layer relationships specify the presentation of layer names in Acrobat’s layer pane, as
well as the visibility of one or more layers when the user interactively enables or disables layers.
Variants can be regarded as a fixed combination of layers to enhance production
safety. Instead of manipulating individual layers the user can only enable or disable a
variant. If a document contains variants, Acrobat 9 will not display individual layer
names but only the names of the variants. Layer variants are presented in Acrobat 9
only for PDF/X documents. Acrobat X does not display layer variants.
PDF/X: Layers are not allowed in PDF/X-1/2/3. In order to use layers with PDF/X-4 or
PDF/X-5 at least two layer variants (i.e. type=Variant) must be specified. Several values of
type are restricted for PDF/X.
Scope document, page; Layer relationships should be specified after all layers have been
defined.
Table 3.11 Options for set_layer_dependency( )
option
explanation
basestate
(Keyword; only for type=Variant; not for PDF/X) Specify the visibility of all layers which are not explicitly configured in the visiblelayers and invisiblelayers options. Supported keywords (default: on):
on
All layers will be visible for the selected variant.
off
All layers will be invisible for the selected variant.
unchanged The state of all layers will be left unmodified for the selected variant.
children
(List of layer handles; only for type=Parent and Title) One or more layer handles specifying the layers
subordinate to the provided parent layer.
createorderlist
(Boolean; only for type=Variant and defaultvariant=true) Include all layers in the /Order array
which can be used to present all layers in a user interface. Setting this option to true has the following
implications:
> Acrobat 9 displays the layer variants in its Layers panel, but not the layer names. Acrobat 9 emits PDF/
X-4 validation errors for documents with createorderlist since this option not allowed in PDF/X4:2008.
> Acrobat X displays the layer names in its Layers panel, but not the layer variants. Acrobat X successfully validates documents with createorderlist since this option is allowed in PDF/X-4:2010.
Default: false for PDF/X, true otherwise
defaultvariant
(Boolean; only for type=Variant) If true, the specified variant is the default variant, i.e. it will be active
when the document is opened. Exactly one variant must be specified as default variant. Default: false
3.4 Layers
45
Table 3.11 Options for set_layer_dependency( )
option
explanation
depend
(Layer handle; only for type=GroupAllOn, GroupAnyOn, GroupAllOff, and GroupAnyOff) The layer which
is controlled by the layers specified in the group option.
group
(List of layer handles; only for type=GroupAllOn, GroupAnyOn, GroupAllOff, GroupAnyOff, Lock, and
Radiobtn) One or more layer handles comprising the group. For type=Lock all layers in the group will be
locked.
includelayers (List of layer handles; only for type=Variant) Specify the layers which belong to the variant. Default: all
layers defined so far in the document
invisiblelayers
(List of layer handles; only for type=Variant) Specify a list of layers which will initially be invisible for the
selected variant. A layer must not be listed in a variant’s visiblelayers and invisiblelayers lists at
the same time. If defaultvariant=true this option overrides the defaultstate option of define_layer( ).
Default (depends on the basestate option): all layers in the includelayers list if basestate=off; empty list if basestate=on;
listmode
(Keyword; only for type=Variant) Specify which layer names will be displayed in Acrobat’s layer pane.
Supported keywords (default: visiblepages):
allpages
The names of all layers on all pages will be displayed.
visiblepages The names of all layers on the currently visible page(s) will be displayed. This implies the default value removeunused=true for all layers which belong to the variant.
In Acrobat this will have an effect only if defaultvariant=true.
parent
(Layer handle; only for type=Parent and Title) The layer which is the parent of the layers specified in
the children option.
variantname (Hypertext string; required for type=Variant) Name of the selected variant. If type=Variant each variant name must be specified only once. Default if type is different from Variant: the default variant
visiblelayers
(List of layer handles; only for type=Variant) Specify a list of layers which will initially be visible in the
selected variant. A layer must not be listed in a variant’s visiblelayers and invisiblelayers lists at
the same time. If defaultvariant=true this option overrides the defaultstate option of define_layer( ).
Default (depends on the basestate option): all layers in the includelayers list if basestate=on; empty
list if basestate=off;
VB RB Sub begin_layer(layer As Long)
C# void begin_layer(int layer)
Start a layer for subsequent output on the page (requires PDF 1.5).
layer
The layer’s handle, which must have been retrieved with define_layer( ).
Details All content placed on the page after this call, but before any subsequent call to begin_
layer( ) or end_layer( ) will be part of the specified layer. The content’s visibility depends
on the layer’s settings.
This function activates the specified layer, and deactivates any layer which may be
currently active.
Layers for annotations, images, templates, and form fields can be controlled with the
layer option of the respective functions.
Scope page
46
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
VB RB Sub end_layer( )
C# void end_layer( )
Deactivate all active layers (requires PDF 1.5).
Details Content placed on the page after this call will not belong to any layer. All layers must be
closed at the end of a page.
In order to switch from layer A to layer B a single call to begin_layer( ) is sufficient; it
is not required to explicitly call end_layer( ) to close layer A. end_layer( ) is only required
to create unconditional content (which is always visible), and to close all layers at the
end of a page.
Scope page
3.4 Layers
47
48
Chapter 3: Document and Page Functions (Edition for COM, .NET, and REALbasic)
4 Font and Text Functions
4.1 Font Handling
Table 4.1 lists relevant parameter and value key names for this section (see Section 2.2,
»Parameter and Option Handling«, page 18).
Table 4.1 Font-related keys for get/set_parameter( )
key and explanation
Encoding, FontAFM, FontPFM, FontOutline, HostFont
The corresponding resource file line as it would appear for the respective category in a UPR file. Multiple calls add new
entries to the internal list. See also resourcefile in Table 2.3. Scope: any
VB RB Function load_font(fontname As String, encoding As String, optlist As String) As Long
C# int load_font(String fontname, String encoding, String optlist)
Search for a font and prepare it for later use.
fontname (Name string) Name of the font. It can alternatively be provided via the
fontname option which will override this parameter. See option fontname in Table 4.3
for details.
encoding Name of the encoding. It can alternatively be provided via the encoding option which will override this parameter. See option encoding in Table 4.3 for details. Note
the following list of common encoding-related problems:
> An 8-bit encoding was supplied but the font does not contain any glyph for this encoding, or the font is a standard CJK font.
> The encoding builtin was supplied, but the font does not contain any internal encoding. This can only happen for TrueType fonts.
> A predefined CMap was supplied but doesn’t match the font.
optlist An option list with the following options:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Font loading options according to Table 4.3:
ascender, autocidfont, autosubsetting, capheight, descender, dropcorewidths, embedding,
encoding, fallbackfonts, fontname, fontstyle, initialsubset, keepfont, keepnative, linegap,
metadata, monospace, optimizeinvisible, readfeatures, readkerning, readshaping, replacementchar, skipposttable, subsetlimit, subsetminsize, subsetting, unicodemap, vertical,
xheight
A font handle for later use with info_font( ), text output functions, and the font text appearance option. If the requested font/encoding combination cannot be loaded due to a
configuration problem (e.g. a font, metrics, or encoding file could not be found, or a mismatch was detected), an error code of -1 will be returned or an exception raised. The error behavior can be changed with the errorpolicy parameter or option.
If the function returns -1you can request the reason of the failure with get_errmsg( ).
Otherwise, the value returned by this function can be used as font handle when calling
4.1 Font Handling
49
other font-related functions. The returned handle doesn’t have any significance to the
user other than serving as a font handle.
The returned font handle is valid until the font is closed with close_font( ). Finishing
the document with end_document( ) closes each open font handle unless the option
keepfont has been supplied in the respective load_font( ) call, or the font has been loaded
in object scope (i.e. outside of any document).
Details This function prepares a font for later use.
Repeated calls: when this function is called again with the same font name, the same
encoding, and the same options, the same font handle as in the first call will be returned. Exceptions: if one of the following options has been specified in the first call,
but not in the subsequent call, the second font handle will nevertheless be identical to
the first font handle: embedding, readkerning, replacementchar, fallbackfonts, metadata.
Similarly, the initialsubset option will be ignored when comparing fonts, e.g. if the font
has first been loaded without initialsubset and is loaded again with initialsubset, a handle
to the first font will be returned and initialsubset will not have any effect.
Trying to load a font again will fail if embedding=false in the first call and embedding=
true in the second call. This situation usually points to a problem in the application.
Implicit font loading: in addition to explicitly loading a font with load_font( ), some
API functions (e.g. add/create_textflow( ) or fill_textblock( )) can implicitly load a font for
which the font name and encoding have been specified in an option list. A new font
handle will be created unless the font has already been loaded earlier.
Some text output features are not available for certain encodings (see Table 4.2).
Table 4.2 Availability of PDFlib features for various encodings
unicode and
Unicode CMaps
feature
Textflow
glyph replacement
fallback fonts
shaping
OpenType layout features
yes
2
yes
2
yes
2
yes
yes
8-bit
encodings
yes
yes
yes
–
–
legacy CMaps,
cp936 etc.
yes
yes
yes
1
–
yes
1
–
yes
1
yes
yes
1
yes
1. This feature is not available for CJK fonts with keepnative=true.
2. This feature is not available for standard CJK fonts with Unicode CMaps or keepnative=true.
Scope any
Params See Table 4.1.
50
glyphid
1
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
Table 4.3 Font loading options for load_font( ) and implicit font loading
option
description
ascender
(Integer between -2048 and 2048) Force the corresponding typographic property to the specified value.
This will override any values found in the font, and is especially useful if the font does not contain any
such information (e.g. Type 3 fonts). Default: the value in the font if present, or an estimated value otherwise (which can be queried with info_font( ))
autocidfont
(Boolean) If true, TrueType fonts with 8-bit encodings which are not a subset of winansi regarding the
set of Unicode values and OpenType fonts without glyph names will automatically be stored as CID
fonts. This avoids problems with certain non-accessible glyphs outside winansi encoding. Default: true
autosubsetting
(Boolean) Dynamically decide whether or not the font will be subset, subject to the subsetlimit and
subsetminsize options and the actual usage of glyphs. This option will be ignored if the subsetting option has been supplied. Default: true
capheight
(Integer between -2048 and 2048) See ascender above.
descender
(Integer between -2048 and 2048) See ascender above.
dropcorewidths
(Boolean; unsupported; will be forced to false in PDF/A and PDF/X mode) The widths for unembedded
core fonts will not be emitted in the generated PDF. The slightly reduces output file size, but may create
incorrect text rendering for certain characters. It is strongly recommended to keep this option at its default value. Default: false
embedding
(Boolean; must be true for PDF/A and PDF/X; will be ignored for SING and Type 3 fonts which are always
embedded) Controls whether or not the font will be embedded. If a font is to be embedded, the font outline file must be available in addition to the metrics information (this is irrelevant for TrueType and
OpenType fonts), and the actual font outline definition will be included in the PDF output. If a font is not
embedded, only general information about the font is included in the PDF output.
Default: generally false, but true in certain situations involving TrueType and OpenType fonts with encodings which result in conversion to a CID font. Although PDFlib will automatically embed such fonts,
font embedding can be prevented by setting embedding to false. In this case the font must be installed
on the system where the PDF documents are viewed or printed.
The option embedding=false will be ignored if the same font has already been loaded earlier with
embedding=true. The embedding behavior for fonts with invisible text can be modified with the
optimizeinvisible option even for embedding=true.
encoding
(String; required for implicit font loading except for fill_textblock( ) and if the text appearance option
font is not specified) The encoding in which incoming text for this font will be expected (case is significant):
Wide character encodings:
> unicode and the names of Unicode CMaps
> the name of a non-Unicode (legacy) CMap, or Identity-H or Identity-V for CID addressing
> glyphid: all glyphs in the font can be addressed by their font-specific ID
Byte- and multibyte encodings:
> one of the predefined 8-bit encodings winansi, macroman, macroman_apple, ebcdic, ebcdic_37,
pdfdoc, iso8859-X, or cpXXXX, and non-Unicode CMaps
> host or auto for an automatically selected encoding;
> the name of a user-defined encoding loaded from file or defined via encoding_set_char( );
> builtin to select the font’s internal encoding (mostly for symbolic fonts);
> an encoding name known to the operating system (not available on all platforms)
load_font( ): this option can alternatively be provided as function parameter.
fill_textblock( ): this option is required unless the string in the text parameter is empty and the defaulttext property is used, or the font option has been supplied.
4.1 Font Handling
51
Table 4.3 Font loading options for load_font( ) and implicit font loading
option
description
fallbackfonts (List of option lists according to Table 4.4) Specify one or more fallback fonts for the loaded font. Each
fallback font must be defined by a font handle in the font suboption or suitable suboptions for implicit
font loading. Fallback fonts are not supported for some combinations of font type and encoding (see Table 4.2).
If glyphcheck=replace and the text contains a character which is not part of the base font’s 8-bit encoding, or the base font does not contain a glyph for the character, or glyph replacement is forced via the
forcechars suboption, PDFlib will search a glyph for this character in all specified fallback fonts in the
order in which they are listed. If a suitable glyph is found in one of the fallback fonts, the character will
be rendered with this glyph; otherwise the usual glyph replacement mechanism applies.
fontname
(Name string; required for implicit font loading except for fill_textblock( ) if the text appearance option
font is not specified) Real or alias name of the font (case is significant). This name will be used to find the
font data.On Windows, font style names can be appended to the font name after a comma (see PDFlib
Tutorial for details). If fontname starts with an ’@’ character the font will be applied in vertical writing
mode.
load_font( ): can alternatively be provided as function parameter.
fontstyle
(Keyword) Controls the creation of artificial font styles. Possible keywords are normal, bold, italic,
bolditalic. For TrueType (not TTC) and OpenType fonts which are not embedded the artificial font style
will be created by Acrobat, otherwise by PDFlib (using the same emboldening method as in the fakebold
parameter or option). In the latter case the slanting angle can be controlled with the italicangle parameter or option. If this option is applied to one of the core fonts, the appropriate bold, italic, or bolditalic font variant will be chosen instead of creating an artificial font style. If no such font is available
(e.g. applying bold to Times-Bold), the option will be ignored. Default: normal
initialsubset
(List of Unichars or Unicode ranges, or list of keywords; only relevant for embedding=true and subsetting=true) Specify the Unicode values for which glyphs will be included in the initial font subset.
This can be used to reduce the font size in PDF while still creating identical subsets, which in turn facilitates later optimizations when merging multiple documents. The Unicode values can be specified explicitly by Unichars or Unicode ranges, or implicitly by the name of an 8-bit encoding. Unichars and Unicode
ranges have precedence over encoding names. Supported keywords (default: empty):
empty
The initial font subset will be empty; the contents of the subset will be determined by the
text in the document.
any 8-bit encoding name
All Unicode values found in the encoding will be included in the initial subset. Glyphs for
additional characters will be added to the subset automatically if required by the text in the
document or by the features and shaping text options.
keepfont
(Boolean; not allowed for Type 3 fonts) If false the font will be deleted automatically in end_
document( ). If true the font can also be used in subsequent documents until close_font( ) has been
called. Default: true if load_font( ) is called in object scope, otherwise false
keepnative
(Boolean; only relevant for unembedded CJK fonts with a predefined CMap; will be ignored for other
fonts; will be forced to false if embedding=true) If false, text in this font will be converted to CID values
when creating PDF output. This does not affect the text supplied to API functions which must still match
the selected CMap (e.g. Shift-JIS). However, the font can be used in Textflow and all simple text output
functions (but not in form fields). Except for glyph replacement and fallback fonts which are unavailable,
a font with Unicode CMaps will behave as with encoding=unicode.
If true, text in this font will be written to the PDF output in its native format according to the specified
CMap. The font can be used in form fields and all simple text output functions, but not in Textflow.
Default: false for TrueType fonts or embedding=true, and true otherwise.
kerning
Deprecated, use the readkerning option to control parsing of kerning data from the font.
linegap
(Integer between -2048 and 2048) See ascender above.
metadata
(Option list; PDF 1.4) Supply metadata for the font (see Section 14.2, »XMP Metadata«, page 209)
52
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
Table 4.3 Font loading options for load_font( ) and implicit font loading
option
description
monospace
(Integer between 1 and 2048; not for PDF/A) Forces all glyphs in the font to use the specified width (in the
font coordinate system: 1000 units equal the font size). For Type 3 fonts all glyph widths which are different from 0 will be modified. This option is only recommended for standard CJK fonts, and not supported
for core fonts; it will be ignored if the font is embedded. Default: absent (metrics from the font will be
used)
optimizeinvisible
(Boolean; not for PDF/X-1/2/3) If true, fonts which are exclusively used for invisible text (i.e. textrendering=3) will not be embedded even if embedding=true. This may be useful to avoid font embedding for PDF/A output with invisible text containing OCR results. Even if the font is not embedded, font
files must be configured as usual since PDFlib decides about non-embedding only at the end of the document. Default: false
readfeatures (Boolean; only relevant for TrueType and OpenType fonts and encoding=unicode, glyphid, or Unicode
CMaps) Specifies whether the feature tables of a TrueType or OpenType font will be read from the font.
Actually applying OpenType features to text is controlled by the features text option (see Table 5.3). Setting this option to false may speed up font loading if OpenType features are not required. Default: true
readkerning
(Boolean) Controls whether or not kerning values will be read from the font. Actually applying the kerning values to text is controlled by the kerning text option (see Table 5.3). Setting this option to false
may speed up font loading if kerning is not required. Default: true
readshaping
(Boolean; only relevant for TrueType and OpenType fonts and the encodings unicode and glyphid)
Specifies whether the shaping tables of a TrueType or OpenType font will be read, which is a requirement
for complex script shaping. Actually shaping text is controlled by the shaping text option (see Table 5.3).
Setting this option to false can save memory if shaping is not required. Default: true
replacementchar
(Unichar; only relevant if glyphcheck=replace; ignored for fonts loaded with a non-Unicode CMap or
glyphid encoding) Glyphs which are not available in the selected font and which cannot be substituted
by fallback fonts or typographically similar characters will be replaced with the specified Unicode value.
U+0000 can be used to specify the font’s »missing glyph« symbol; however, this is not allowed for the
PDF/A-1, PDF/X-4, and PDF/X-5 standards. For symbolic fonts loaded with encoding=builtin the code
must be supplied instead of the Unicode value.
Default: U+00A0 (NO-BREAK SPACE) if available in the font; otherwise U+0020 (SPACE) if available in
the font, otherwise U+0000 (but not for PDF/A-1, PDF/X-4, and PDF/X-5). These values will also be used if
the font doesn’t contain any glyph for the specified replacementchar.
skipposttable
(Boolean; unsupported; only relevant for TrueType and OpenType fonts) Specifies whether the post table
of TrueType/OpenType fonts will be parsed to determine glyph names. Setting this option to true can
speed up font loading, but glyph name references to glyphs with non-standard names will not work for
the font (this mainly affects symbolic fonts, but usually not text fonts). Default: false
subsetlimit
(Float or percentage; will be ignored for Type 3 fonts) Automatic font subsetting will be disabled if the
percentage of glyphs used in the document related to the total number of glyphs in the font exceeds the
provided percentage. Default: 100%
subsetminsize
(Float; will be ignored for Type 3 fonts) Automatic font subsetting will be disabled if the size of the original font file is less than the provided value in KB. Default: 50
subsetting
(Boolean) Controls whether or not the font will be subset. Subsetting for Type 3 fonts requires a two-pass
definition of the font (see PDFlib Tutorial), and the subsetting option must be provided in the first call
to load_font( ). Default: false
unicodemap
(Boolean; must not be set to false for pdfa=PDF/A-1a:2005) Controls the generation of ToUnicode
CMaps. This option will be ignored in Tagged PDF mode. Default: true
vertical
(Boolean; only for TrueType and OpenType fonts; will be ignored for predefined CMaps, and will be
forced to true if the font name starts with @) If true, the font will be prepared for vertical writing mode.
xheight
(Integer between -2048 and 2048) See ascender above.
4.1 Font Handling
53
Table 4.4 Suboptions for the fallbackfonts option of load_font( )
option
description
font loading
options
If the font is specified implicitly (i.e. via the fontname and encoding options, as opposed to the font option), all font loading options according to Table 4.3 except fallbackfonts can be supplied as suboptions. Fonts loaded with a non-Unicode CMap can not be used as fallback fonts.
font
(Font handle) A font handle returned by a call to load_font( ) without the fallbackfonts option. If this
option is supplied, all font loading options (including fontname and encoding) will be ignored. The font
must not be a standard CJK font with embedding=false and keepnative=true.
fontsize
(Float or percentage) Size of the fallback font in user coordinates or as a percentage of the current font
size. This option can be used to adjust the size of the fallback font if the design size of the fallback font
doesn’t match that of the base font. Default: 100%
forcechars
(List of Unichars or Unicode ranges, or single keyword) Specify characters which will always be rendered
with glyphs from the fallback font (regardless of the glyphcheck setting). The fallback font must contain
glyphs for the specified characters (if individual characters are specified), or at least glyphs for the first
and last characters in the specified Unicode range. Unicode values can be specified for this option even if
an 8-bit encoding has been specified for the base font.
The following keyword can be supplied:
gaiji
textrise
The fallback font must refer to a SING font, and this keyword can be used as a shortcut for the
Unicode value of the main glyph of the SING font.
(Float or percentage) Text rise value (see Table 5.2). Percentages are based on the size specified for the
fallback font (i.e. after applying the fontsize suboption if present). This option can be used to adjust the
position of text in the fallback font if the design size of the fallback font doesn’t match that of the base
font. Default: 0
VB RB Sub close_font(font As Long)
C# void close_font(int font)
Close an open font handle which has not yet been used in the document.
font A font handle returned by load_font( ) which has not already been used in the document or closed.
Details This function closes a font handle, and releases all resources related to the font. The font
handle must not be used after this call. Usually fonts will automatically be closed at the
end of a document. However, closing a font is useful in the following situations:
> After querying font properties with info_font( ) it was determined that the font will
not be used in the current PDF document.
> A font was retained across document boundaries (with the keepfont option of load_
font( )), but now it should be disposed because it is no longer required.
If the font has already been used in the current document it must not be closed.
Scope any
54
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
VB RB Function info_font(font As Long, keyword As String, optlist As String) As Double
C# double info_font(int font, String keyword, String optlist)
Query detailed information about a loaded font.
font
A font handle returned by load_font( ), or -1for some keywords.
keyword A keyword specifying the requested information according to Table 4.6. The
following keywords can be used:
> Keywords for glyph mapping: cid, code, glyphid, glyphname, unicode
> Font metrics: ascender, capheight, descender, italicangle, linegap, xheight
> Font file, name, and type: cidfont, familyname, fontfile, fontname, fonttype, metricsfile,
outlineformat, singfont, standardfont, supplement
> Technical font information: feature, featurelist, fontstyle, hostfont, kerningpairs,
monospace, numglyphs, shapingsupport, vertical
> Font/encoding relationship: codepage, codepagelist, encoding, fallbackfont, keepnative,
maxcode, numcids, numusableglyphs, predefcmap, replacementchar, symbolfont,
unicodefont, unmappedglyphs
> Results of font processing for the current document: numusedglyphs, usedglyph,
willembed, willsubset
optlist An option list which additionally qualifies the selected keyword. The following
options can be used:
> Keyword-specific options which are detailed along with the corresponding keyword
in Table 4.6.
> Mapping options according to Table 4.5 for specifying glyphs: cid, code, glyphid,
glyphname, unicode. These options define the source value for the mapping keywords
cid, code, glyphid, glyphname, and unicode. The mapping options are mutually exclusive. The code, glyphname, and unicode options can be combined with the encoding
option.
Table 4.5 Options for specifying glyphs in info_font( )
option
description
cid
(Number) CID value of the glyph; only reasonable if cidfont=1
code
(Number in the range 0...255; only for fonts with 8-bit encoding) Encoding slot
glyphid
(Number in the range 0...65535) Internal glyph id
glyphname
(String) Name of a glyph; not reasonable if cidfont=1
unicode
(Unichar) Unicode character
Returns The value of some font or encoding property as requested by keyword and in some cases
auxiliary options. For unspecified combinations of keyword and options -1 will be returned. Some keywords will return a string indirectly by returning its string index. The
corresponding string can be retrieved via get_parameter( ) and the string parameter (see
Table 2.3).
Details This function supplies information from the following distinct sources:
> If a valid font handle is supplied it returns information gathered from the font. Examples: font metrics, name, or type; unicode value for a particular glyphid.
4.1 Font Handling
55
> If font = -1and the encoding option is supplied it returns information about this encoding. Example: unicode value for a code in the encoding.
> If font = -1and the encoding option is not supplied it returns information gathered
from PDFlib’s internal tables. Example: unicode value for a particular glyphname.
Scope any except object
Table 4.6 Keywords and options for info_font( )
keyword
explanation and options
ascender
Metrics value for the ascender. Supported options (default: fontsize=1000):
faked
(Boolean) 1 if the value had to be estimated because it was not available in the font or metrics
file, otherwise 0
fontsize
(Fontsize) Value will be scaled to the specified font size
capheight
Metrics value for the capheight. See ascender.
cid
CID for the specified glyph, or -1 if not available. Supported options: cid, glyphid, unicode
cidfont
1 if the font will be embedded as a CID font, otherwise 0
code
Number in the range 0...255 specifying an encoding slot or -1 if no such slot was found in the font or in
the encoding (if the encoding option was supplied and font=-1). Supported options are the mapping options code, glyphid, glyphname, unicode plus the following:
encoding (String) Name of an 8-bit encoding
codepage
Check whether the font supports a specific codepage. The information will be taken from the OS/2 table
of TrueType/OpenType fonts if available. Supported option:
name
(String; required) Specifies the name of a codepage in the form cpXXXX, where XXXX indicates
the decimal number of a codepage (e.g. cp437, cp1252)
The following return values indicate whether the specified codepage is supported by the font:
-1
Unknown because the font is not a TrueType or OpenType font.
0
Font does not support the specified codepage.
1
Font supports the specified codepage.
codepagelist
String index of a space-separated list of all codepages supported by the font (in the form cpXXXX), or -1 if
the codepage list is unknown because the font is not a TrueType or OpenType font (see codepage).
descender
Metrics value for the descender. See ascender.
encoding
String index of the name of the font’s encoding or CMap. Supported options (default: actual):
api
(Boolean) If true, the encoding name as specified in the API
actual
(Boolean) If true, the name of the actual encoding used for the font
fallbackfont
Handle of the base or fallback font which will be used to render the character specified in the unicode
option. This can be used to check which font in the chain of fallback fonts actually provides the glyph
used for the specified character. If the character cannot be rendered with any of the base or fallback
fonts, -1 will be returned. Supported option: unicode
familyname
String index of the name of the font family, or -1 if unavailable
56
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
Table 4.6 Keywords and options for info_font( )
keyword
explanation and options
feature
Check whether the font contains a specific OpenType feature table which is supported by PDFlib.
Supported options:
language (String; only if script is supplied) Specifies the language name.
name
(String; required) Specifies the four-character name of an OpenType feature table, e.g. liga
(standard ligatures), ital (italic forms in CJK fonts), vert (vertical writing). Feature kern can
not be queried.
script
(String) Specifies the script name.
The following return values indicate whether the specified OpenType feature table is present in the font
and supported by PDFlib:
-1
No feature tables available in the font.
0
The feature table is not available or not supported by PDFlib.
1
The feature table is available for the specified script and language and is supported by PDFlib.
featurelist
String index of a space-separated list of all features which are available in the font and supported by
PDFlib, or -1 if no feature tables are available.
fontfile
String index of the path name for the font outline file, or -1 if unavailable
fontname
String index of the font name, or -1 if unavailable. Supported options (default: acrobat):
fontstyle
api
(Boolean) If true, the font name as specified in the API
full
(Boolean) If true, the /FontName entry in the PDF font descriptor
acrobat
(Boolean) If true, the font name as displayed in Acrobat
String index for the value of the fontstyle option (normal, bold, italic, or bolditalic). Supported option:
faked
1 if fontstyle will be realized by PDFlib, 0 if fontstyle will be realized by Acrobat
fonttype
String index of the font type, or -1 if unavailable. Known font types are Multiple Master, OpenType,
TrueType, TrueType (CID), Type 1, Type 1 (CID), Type 1 CFF, Type 1 CFF (CID), Type 3
glyphid
Number in the range 0...65535 specifying the font-internal id (GID) of the specified glyph, or -1 if no such
glyph was found. Supported options are the mapping options cid, code, glyphid, glyphname, unicode.
glyphname
String index of the name of the specified glyph, or -1 if no such glyph was found in the font or in the specified encoding (if the encoding option was supplied and font=-1). Supported options are the mapping
options code, glyphid, glyphname, unicode plus the following:
encoding (String) Name of an 8-bit encoding
hostfont
1 if the font is a host font, 0 otherwise
italicangle
Italic angle of the font (ItalicAngle in the PDF font descriptor)
keepnative
The resulting value of the keepnative option.
kerningpairs
Number of kerning pairs in the font
linegap
Metrics value for the linegap. See ascender.
maingid
Glyph ID of the main glyph (member mainGID of SING table).
maxcode
Highest code value for the font’s encoding, in particular: 0xFF for single-byte encodings, numglyphs-1 for
encoding=glyphid, and the highest Unicode value in the encoding otherwise.
metricsfile
String index of the path name for the font metrics file (AFM or PFM), or -1 if unavailable
monospace
The value of the monospace option, or 0 if it hasn’t been supplied.
numcids
Number of CIDs if the font uses a standard CMap, otherwise -1
4.1 Font Handling
57
Table 4.6 Keywords and options for info_font( )
keyword
explanation and options
numglyphs
Number of glyphs in the font (including the .notdef glyph). Since GIDs start at 0 the highest possible GID
value is one smaller than numglyphs.
numusableglyphs
Number of glyphs in the font which can be reached by the encoding supplied in load_font( )
numusedglyphs
Number of glyphs used in generated text so far.
outlineformat
Font format; one of PFA, PFB, LWFN, TTF, OTF, TTC
predefcmap
String index of the name of a predefined CMap which was specified as encoding for the font, or -1 if unavailable.
replacement
char
Unicode value of the character specified in the replacementchar option. For symbolic fonts loaded with
encoding=builtin the code will be returned instead of the Unicode value.
shapingsupport
1 if the font supports shaping and the readshaping option was supplied in load_font( ), otherwise 0
singfont
1 if the font is a SING (gaiji) font, otherwise 0
standardfont
1 if the font is a PDF core font or a standard CJK font, otherwise 0
supplement
Supplement number of the character collection for fonts with a standard CJK CMap, otherwise 0
symbolfont
1 if the font is a symbolic font, 0 otherwise (symbol flag in the PDF font descriptor)
unicode
Unicode UTF-32 value for the specified glyph, or -1 if no Unicode value was found in the font or encoding
(if the encoding option was supplied and font=-1). Supported options are the mapping options cid,
code, glyphid, glyphname, unicode plus the following:
encoding (String) Name of an 8-bit encoding
unicodefont
1 if the font/encoding combination provides Unicode mapping for the glyphs, otherwise 0. CJK fonts with
non-Unicode CMaps and keepnative=true will return 0.
unmappedglyphs
Number of glyphs in the font which are mapped to Unicode PUA values, regardless of whether the PUA
value was already present in the font or has been assigned by PDFlib.
usedglyph
1 if the specified glyph ID was used in the text, otherwise 0. Supported option: glyphid
vertical
1 if the font is for vertical writing mode, otherwise 0
weight
Font weight in the range 100...900; 400=normal, 700=bold
willembed
1 if the font will be embedded (via the embedding option or forced font embedding), otherwise 0
willsubset
1 if a font subset will be created (if autosubsetting=true, the subsetlimit must be reached for subsetting to be activated), otherwise 0
xheight
Metrics value for the xheight. See ascender.
58
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
4.2 Type 3 Font Definition
Cookbook A full code sample can be found in the Cookbook topic fonts/starter_type3font .
VB RB Sub begin_font(fontname As String, a As Double, b As Double , c As Double,
d As Double, e As Double, f As Double, optlist As String)
C# void begin_font(String fontname,
double a, double b, double c, double d, double e, double f, String optlist)
Start a Type 3 font definition.
fontname (Name string) The name under which the font will be registered, and can
later be used with load_font( ).
a, b, c, d, e, f (Will be ignored in the second pass of the font definition for Type 3 font
subsets) The elements of the font matrix. This matrix defines the coordinate system in
which the glyphs will be drawn. The six values make up a matrix in the same way as in
PostScript and PDF (see references). In order to avoid degenerate transformations, a*d
must not be equal to b*c. A typical font matrix for a 1000 x 1000 coordinate system is
[0.001, 0, 0, 0.001, 0, 0].
optlist (Ignored in the second pass for subset fonts) An option list according to Table
4.7. The following options can be used: colorized, familyname, stretch, weight, widthsonly
Details This function will reset all text, graphics, and color state parameters to their defaults.
The font may contain an arbitrary number of glyphs. The font can be used until the end
of the current document scope.
Scope document, page; this function starts font scope, and must always be paired with a
matching end_font( ) call. For the second pass of subsetted fonts only document scope is
allowed.
Table 4.7 Options for begin_font( )
option
description
colorized
(Boolean) If true, the font may explicitly specify the color of individual characters. If false, all characters
will be drawn with the current color (at the time the font is used, not when it is defined), and the glyph
definitions must not contain any color operators or images other than masks. Default: false
familyname1 (String; PDF 1.5) Name of the font family
stretch1
(Keyword; PDF 1.5) The font stretch value. Keywords: ultracondensed, extracondensed, condensed,
semicondensed, normal, semiexpanded, expanded, extraexpanded, ultraexpanded. Default: normal
weight1
(Integer or keyword; PDF 1.5) The font weight. Possible numbers or equivalent keywords are 100=thin,
200=extralight, 300=light, 400=normal, 500=medium, 600=semibold, 700=bold, 800=extrabold,
900=black. Default: normal
widthsonly
(Boolean) If true (pass 1 for Type 3 font subsetting), only the metrics of the font and glyphs will be defined. No other API functions should be called between begin_glyph( ) and end_glyph( ). If other functions are called nevertheless, they will not have any effect on the PDF output, and will not raise any exception.
If widthsonly=false (pass 2 for Type 3 font subsetting) the actual glyph outlines can be defined. This
two-pass definition enables PDFlib to perform subsetting on Type 3 fonts. Default: false
1. These options are strongly recommended when creating Tagged PDF, and will be ignored otherwise.
4.2 Type 3 Font Definition
59
VB RB Sub end_font( )
C# void end_font( )
Terminate a Type 3 font definition.
Scope font; this function terminates font scope, and must always be paired with a matching
begin_font( ) call.
VB RB Sub begin_glyph(glyphname As String,
wx As Double, llx As Double, lly As Double, urx As Double, ury As Double)
C# void begin_glyph(String glyphname, double wx, double llx, double lly, double urx, double ury)
Start a glyph definition for a Type 3 font.
glyphname The name of the glyph. This name must be used in any encoding which
will be used with the font. It is strongly recommended to use glyph names according to
the Adobe Glyph List (AGL). Glyph names within a font must be unique.
wx (Will be ignored in the second pass of the font definition for Type 3 font subsets)
The width of the glyph in the glyph coordinate system, as specified by the font’s matrix.
llx, lly, urx, ury (Will be ignored in the second pass of the font definition for Type 3
font subsets) If the font’s colorized option is false (which is default), the coordinates of
the lower left and upper right corners of the glyph’s bounding box. The bounding box
values must be correct in order to avoid problems with PostScript printing. If the font’s
colorized option is true, all four values must be 0.
Details The glyphs in a font can be defined using text, graphics, and image functions. Images,
however, can only be used if the font’s colorized option is true, or the image has been
opened with the mask option. It is strongly suggested to use the inline image feature for
defining bitmaps in Type 3 fonts.
Since the complete graphics state of the surrounding page will be inherited for the
glyph definition when the colorized option is true, the glyph definition should explicitly
set any aspect of the graphics state which is relevant for the glyph definition (e.g.
linewidth).
PDFlib will determine the Unicode value for each glyph by searching the glyph name
in its internal list. If the glyph name isn’t found, a PUA Unicode value will be assigned to
the glyph name (starting with U+E000). This value can be queried with info_font( ).
Scope page, font; this function starts glyph scope, and must always be paired with a matching
end_glyph( ) call. If widthsonly=true in begin_font( ) all API function calls between begin_
glyph( ) and end_glyph( ) will be ignored.
VB RB Sub end_glyph( )
C# void end_glyph( )
Terminate a glyph definition for a Type 3 font.
Scope glyph; this function terminates glyph scope, and must always be paired with a matching
begin_glyph( ) call.
60
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
4.3 Encoding Definition
VB RB Sub encoding_set_char(encoding As String, slot As Long, glyphname As String, uv As Long)
C# void encoding_set_char(String encoding, int slot, String glyphname, int uv)
Add a glyph name and/or Unicode value to a custom 8-bit encoding.
encoding The name of the encoding. This is the name which must be used with load_
font( ). The encoding name must be different from any built-in encoding and all previously used encodings.
slot The position of the character to be defined, with 0 <= slot <= 255. A particular slot
must only be filled once within a given encoding.
glyphname
uv
The character’s name.
The character’s Unicode value.
Details This function is only required for specialized applications which must work with nonstandard 8-bit encodings. It can be called multiply to define up to 256 character slots in
an encoding. More characters may be added to a particular encoding until it has been
used for the first time; otherwise an exception will be raised. Not all code points must be
specified; undefined slots will be filled with .notdef and U+0000.
There are three possible combinations of glyph name and Unicode value:
> glyphname supplied, uv=0: this parallels an encoding file without Unicode values;
> uv supplied, but no glyphname supplied: this parallels a codepage file;
> glyphname and uv supplied: this parallels an encoding file with Unicode values.
It is strongly recommended to supply each glyph name/Unicode value only once in an
encoding (with the exception of .notdef/U+0000).
If the encoding is intended for use with Type 3 fonts it is recommended to specify
the encoding slots only with glyph names.
The defined encoding can be used until the end of the current object scope.
Scope any
4.3 Encoding Definition
61
4.4 Simple Text Output
Note All text supplied to the functions in this section must match the encoding selected with load_
font( ) and the specified textformat. Due to restrictions in Acrobat, text strings must not exceed 32 KB in length.
Table 4.8 and Table 4.9 lists relevant parameters and values for this section (see Section
2.2, »Parameter and Option Handling«, page 18).
Table 4.8 Text-related keys for get/set_parameter( )
key
explanation
autospace
If true and the current font contains a glyph for U+0020, PDFlib will automatically add a space character after each text output generated with a show operation. This may be useful for generating Tagged
PDF. Note that adding spaces changes the current text position after the show operation. Default: false.
Scope: any
charref
See Table 5.1. Unlike the option with the same name this parameter also affects hypertext strings and
name strings. Default: false. Scope: any
decorationabove
See Table 5.2. Default: false. Scope: any
escapesequence
See Table 5.1. Unlike the option with the same name this parameter also affects hypertext strings and
name strings. For example, Windows UNC file names must start with four backslash characters if
escapesequence=true. Warning: this parameter also affects environment variables (e.g. PDFLIBLICENSEFILE). Since path names in environment variables on Windows usually contain backslash characters this parameter should better be avoided on Windows system; supply the option of the same name
to specific functions instead. Default: false. Scope: any
fakebold
See Table 5.2. Default: false. Scope: page, pattern, template, glyph, document
glyphcheck
See Table 5.1. Default: replace. Scope: any
kerning
See Table 5.2. Default: true. Scope: any
underline
overline
strikeout
See Table 5.2. Default: false. Scope: page, pattern, template, glyph, document
Table 4.9 Text-related keys for get/set_value( )
key
explanation
charspacing
font
1
See Table 5.2. Only float values are supported. Scope: page, pattern, template, glyph, document
Identifier of the current font which has been set with setfont( ), or -1 if no font is set. Scope: page,
pattern, template, glyph
fontsize1
Size of the current font which must have been previously set with setfont( ). Scope: page, pattern,
template, glyph
horizscaling
See Table 5.2. Only float values are supported. Scope: page, pattern, template, glyph, document
italicangle
See Table 5.2. Scope: page, pattern, template, glyph, document
leading
Leading, which is the distance between baselines of adjacent lines of text. The leading is used for
continue_text( ). It is set to the value of the font size when a new font is selected using setfont( ). Setting
the leading equal to the font size results in dense line spacing (leading = 0 will result in overprinting
lines). However, ascenders and descenders of adjacent lines will generally not overlap. Scope: page,
pattern, template, glyph
62
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
Table 4.9 Text-related keys for get/set_value( )
key
explanation
textrendering
See Table 5.2. Scope: page, pattern, template, glyph, document
textrise
See Table 5.2. Only float values are supported. Scope: page, pattern, template, glyph
1
textx
texty1
The x or y coordinate of the current text position. Default: 0. Scope: page, pattern, template, glyph
underlineposition
See Table 5.2. Only float values specifying a fraction of the font size are supported. The value 1000000
can be supplied to set a font-specific value which will be retrieved from the font metrics or outline file.
Default: 1000000
underlinewidth
See Table 5.2. Only float values are supported. The value 0 uses a font-specific value from the font metrics
or outline file if available, otherwise 5% of the fontsize. Default: 0
wordspacing See Table 5.2. Only float values are supported. Scope: page, pattern, template, glyph, document
1. Only for get_value( )
VB RB Sub setfont(font As Long, fontsize As Double)
C# void PDF_setfont(int font, double fontsize)
Set the current font in the specified size.
font
A font handle returned by load_font( ).
fontsize Size of the font, measured in units of the current user coordinate system. The
font size must not be 0; a negative font size will result in mirrored text relative to the
current transformation matrix.
Details This function sets the font which will be used by low-level text output functions, e.g.
show( ). The font must be set on each page before calling any of the simple text output
functions. Font settings will not be retained across pages. The current font can be
changed an arbitrary number of times per page.
Scope page, pattern, template, glyph
Params This function automatically sets the leading parameter to fontsize.
VB RB Sub set_text_pos(x As Double, y As Double)
C# void set_text_pos(double x, double y)
Set the position for simple text output on the page.
x, y
The current text position to be set.
Details The text position is set to the default value of (0, 0) at the beginning of each page. The
current point for graphics output and the current text position are maintained separately.
Scope page, pattern, template, glyph
Params See Table 4.8 and Table 4.9.
4.4 Simple Text Output
63
VB RB Sub show(text As String)
C# void show(String text)
Print text in the current font and size at the current text position.
text
(Content string) The text to be printed.
Details The font must have been set before with setfont( ). The current text position is moved to
the end of the printed text.
Scope page, pattern, template, glyph
Params See Table 4.8 and Table 4.9.
VB RB Sub show_xy(text As String, x As Double, y As Double)
C# void show_xy(String text, double x, double y)
Print text in the current font at the specified position.
text
(Content string) The text to be printed.
x, y
The position in the user coordinate system where the text will be printed.
Details The font must have been set before with setfont( ). The current text position is moved to
the end of the printed text.
Scope page, pattern, template, glyph
Params See Table 4.8 and Table 4.9.
VB RB Sub continue_text(text As String)
C# void continue_text(String text)
Print text at the next line.
text (Content string) The text to be printed. If this is an empty string, the text position
will be moved to the next line anyway.
Details The positioning of text (x and y position) and the spacing between lines is determined
by the leading parameter and the most recent call to fit_textline( ), show_xy( ) or set_text_
pos( ). The current point will be moved to the end of the printed text; the x position for
subsequent calls of this function will not be changed.
Scope page, pattern, template, glyph; this function should not be used in vertical writing mode.
Params See Table 4.8 and Table 4.9.
VB RB Function stringwidth(text As String, font As Long, fontsize As Double) As Double
C# double stringwidth(String text, int font, double fontsize)
Calculate the width of text in an arbitrary font.
64
text
(Content string) The text for which the width will be queried.
font
A font handle returned by load_font( ).
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
fontsize Size of the font, measured in units of the user coordinate system (see
setfont( )).
Returns The width of text in a font which has been selected with load_font( ) and the supplied
fontsize. The returned width value may be negative (e.g. when negative horizontal scaling has been set). In vertical writing mode the width of the widest glyph will be returned
(use info_textline( ) to determine the actual height of the text).
If character spacing has been specified, it will be applied after the last glyph as well (this
behavior differs from info_textline( )).
Details The width calculation takes the current values of the following text parameters into account: horizscaling, kerning, charspacing, and wordspacing.
Scope font, page, pattern, template, path, glyph, document
Params See Table 4.8 and Table 4.9.
4.4 Simple Text Output
65
4.5 Unicode Conversion Functions
This section does not apply to COM, .NET, and REALbasic.
66
Chapter 4: Font and Text Functions (Edition for COM, .NET, and REALbasic)
5 Text and Table Formatting
5.1 Text Options
This section lists text options for fit_textline( ), info_textline( ), and add/create_textflow( ).
Text options also apply to table cells and text Blocks:
> input filter options according to Table 5.1;
> text appearance options according to Table 5.2;
> shaping and typographic options according to Table 5.3;
Table 5.1 Input filter options
option
explanation
charref
(Boolean) If true, enable substitution of numeric and character entity references and glyph name references. Default: the global charref parameter
escapesequence
(Boolean) If true, enable substitution of escape sequences in strings. In text for create_textflow( ) with
inline option lists the begin character for an inline option list can be expressed by an escape sequence.
However, escape sequences don’t work in inline option lists including the end character. Default: the global escapesequence parameter
glyphcheck
(Keyword) Glyph checking policy: what happens if text contains a code which cannot be mapped to a
glyph in the selected font (default:1 replace):
none
No checking
error
An exception will be thrown for unavailable glyphs. A detailed error message can be retrieved
with get_errmsg( ).
replace
PDFlib will try to replace unavailable glyphs with appropriate replacement glyphs in the base
and fallback fonts if available; ligatures will be decomposed. If a suitable replacement is not
available, the glyph will be replaced with replacementchar if specified
1. Default for fit_textline( ) and info_textline( ) if inittextstate=false: the parameter with the same name as the option (see Table
4.8 and Table 4.9)
Table 5.2 Text appearance options
option
explanation
charspacing
(Float or percentage) Character spacing, i.e. the shift of the current point after placing individual characters in a string. Float values specify units of the user coordinate system; percentages are based on
fontsize. In order to spread characters apart use positive values for horizontal writing mode, and negative values for vertical writing mode. Default1: 0
dasharray
(List of two floats) The lengths of dashes and gaps for stroked (outline) text and decoration. Default:
{0 0} (i.e. a solid line)
decorationabove
(Boolean) If true, the text decoration enabled with the underline, strikeout, and overline options will
be drawn above the text, otherwise below the text. Changing the drawing order affects visibility of the
decoration lines. Default1: false
fakebold
(Boolean) If true, simulate bold font by triple overprinting. It is strongly recommended to use bold font
variations for emphasis; this option will create text output which is inferior to real bold text, and may inhibit text extraction. Default1: false
5.1 Text Options
67
Table 5.2 Text appearance options
option
explanation
fillcolor
(Color) Fill color of the text. Default for fit_textline( ) if inittextstate=false: the corresponding parameter in the current graphics state. Default: {gray 0} (in PDF/A mode: {lab 0 0 0})
font
(Font handle) Handle for the font to be used. If this option is supplied, all font loading options (including
fontname and encoding) will be ignored. Using the font option instead of implicit font loading with the
fontname/encoding options offers performance benefits.
Default: the implicitly loaded font if available, else the font in the current text state (only for Textline
and inittextstate=false). Otherwise no font is available, which will trigger an error.
fontsize
(Fontsize; required) Size of the font, measured in units of the current user coordinate system. In fit_
textline( ) percentages relate to the box width (for orientate=north and south) or height (for
orientate=east and west). With Textflows percentages relate to the size of the preceding text. Default:
the current font size
gstate
(Gstate handle) Handle for a graphics state retrieved with create_gstate( ). The graphics state affects all
text created with this function. Default: no graphics state (i.e. current settings will be used).
horizscaling
(Float or percentage; must be different from 0) Horizontal text scaling to the given percentage (must be
different from 0). Text scaling shrinks or expands the text by a given percentage. Text scaling always relates to the horizontal coordinate. Default1: 100%
italicangle
(Float) The italic (slant) angle of text in degrees (between -90° and 90°). Negative values can be used to
simulate italic text when only a regular font is available, especially for CJK fonts. Default1: 0
kerning
(Boolean) If true, enable kerning for fonts which have been opened with the readkerning option; disable otherwise. Default: the global kerning parameter
overline
(Boolean) Overline mode. Default1: false
strikeout
(Boolean) Strikeout mode. Default1: false
strokecolor
(Color; only effective if textrendering is set to stroke text) Stroke color of the text. Default: see
fillcolor
strokewidth
(Float, percentage, or keyword; only effective if textrendering is set to outline text) Line width for outline text (in user coordinates or as a percentage of the fontsize). The keyword auto or the value 0 uses a
built-in default. Default: auto
textrendering
(Integer) Text rendering mode. Only the value 3 has an effect on Type 3 fonts (default1: 0):
0
P
1
2
3
P
fill text
4
fill text and add it to the clipping path
stroke text (outline)
5
stroke text and add it to the clipping path
fill and stroke text
6
fill and stroke text and add it to the clipping path
invisible text
7
add text to the clipping path (does not have any
effect with fit_textline( ) or fit_textflow( ))
textrise
(Float or percentage) Textrise parameter, which specifies the distance between the desired text position
and the baseline. Positive values of textrise move the text up. The textrise always relates to the vertical
coordinate. This may be useful for superscripts and subscripts. Percentages are based on fontsize.
Default1: 0
underline
(Boolean) Underline mode. Default1: false
68
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.2 Text appearance options
option
explanation
underlineposition
(Float, percentage, or keyword) Position of the stroked line for underlined text relative to the baseline
(absolute values or relative to the fontsize; a typical value is -10%). The keyword auto specifies a fontspecific value which will be retrieved from the font metrics or outline file. Default1: auto
underlinewidth
(Float, percentage, or keyword) Line width for underlined text (absolute value or percentage of the fontsize). The keyword auto or the value 0 uses a font-specific value from the font metrics or outline file if
available, otherwise 5%. Default1: auto
wordspacing (Float or percentage) Wordspacing, i.e. the shift of the current point after placing individual words in a
line. In other words, the current point is moved horizontally after each space character (U+0020). The
value is specified in user coordinates or a percentage of the fontsize. Default1: 0
1. Default for fit_textline( ) and info_textline( ) if inittextstate=false: the parameter with the same name as the option (see Table
4.8 and Table 4.9)
Table 5.3 Shaping and typographic options
option
explanation
features
(List of keywords) Specifies which typographic features of an OpenType font will be applied to the text,
subject to the script and language options. Keywords for features which are not present in the font will
silently be ignored. The following keywords can be supplied:
_none
Apply none of the features in the font. As an exception, the vert feature must explicitly be
disabled with the novert keyword.
<name>
Enable a feature by supplying its four-character OpenType tag name. Some common feature
names are liga, ital, tnum, smcp, swsh, zero. The full list with the names and descriptions of
all supported features can be found in the PDFlib Tutorial.
no<name> The prefix no in front of a feature name (e.g. noliga) disables this feature.
Default: _none for horizontal writing mode, vert for vertical writing mode.
language
(Keyword; only relevant if script is supplied) The text will be processed according to the specified language, which is relevant for the features and shaping options. A full list of keywords can be found in
the PDFlib Tutorial, e.g. ARA (Arabic), JAN (Japanese), HIN (Hindi). Default: _none (undefined language)
script
(Keyword; required if shaping=true) The text will be processed according to the specified script, which is
relevant for the features, shaping, and advancedlinebreak options. The most common keywords for
scripts are the following: _none (undefined script), latn, grek, cyrl, armn, hebr, arab, deva, beng, guru,
gujr, orya, taml, thai, laoo, tibt, hang, kana, han. A full list of keywords can be found in the PDFlib Tutorial. The keyword _auto selects the script to which the majority of characters in the text belong, where _
latn and _none are ignored. Default: _none
shaping
(Boolean) If true, complex script shaping and bidirectional reordering will be applied to the text according to the script and language options. The script option must have a value different from _none and
the font must obey certain conditions (see PDFlib Tutorial). Shaping is only done for characters in the
same font. Shaping is not available for right-to-left text in Textflows (only in Textlines). Default: false
5.1 Text Options
69
Table 5.4 Suboptions for the leader option for fit_textline( ) and add/create_textflow( ) and inline options in create_
textflow( )
option
explanation
font loading
options
If the font is specified implicitly (i.e. via the fontname and encoding options, as opposed to the font option), all font loading options according to Table 4.3 can be supplied as suboptions.
alignment
(One or two keywords) Textline: The first keyword specifies the alignment of the leader between the left
border of the fitbox and the Textline; the second keyword specifies the alignment of the leader between
the Textline and the right border of the fitbox. If only one keyword is specified it will be used for the leader between the Textline and the right border of the fitbox. Supported keywords (default for Textline:
{none grid}; default for Textflow: grid):
center
Textline: the leader is justified between the Textline and the border of the fitbox.
Textflow: the leader is centered between the last text fragment (or the start of the line if
there is no text) and the tab position (or the end of the line if there is no tab).
grid
PDFlib snaps the position of the leader text to the next multiple of one half of the width of
the leader text to the left or right of the Textline. This may result in a gap between the
Textline and the leader text which spans at most 50% of the width of the leader text.
justify
Textline: the leader is justified between the Textline and the border of the fitbox by applying
a suitable character spacing.
Textflow: the leader is justified between the last text fragment (or the start of the line if there
is no text) and the tab position (or the end of the line if there is no tab) by applying a suitable
character spacing.
left
The leader is repeated starting from the left border of the fitbox or the end of the Textline,
respectively. This may result in a gap at the start of the Textline or the right border of the
fitbox, respectively.
none
No leader
right
The leader is repeated starting from the right border of the fitbox or the beginning of the
Textline, respectively. This may result in a gap at the end of the Textline or the left border of
the fitbox, respectively.
fillcolor
(Color) Color of the leader. Default: color of the text line
font
(Font handle) Handle for the font to be used for the leader. Default: font of the text line
fontsize
(Fontsize) Size of the leader. Default: font size of the Textline
text
(Content string) The text which will be used for the leader. Default: U+002E ’.’ (period)
yposition
(Float or keyword) Specifies the vertical position of the leader relative to the baseline as a numerical value or as one of the keywords fontsize, ascender, xheight, baseline, descender, textrise. Default:
baseline
70
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
5.2 Single-Line Text with Textlines
Cookbook A full code sample can be found in the Cookbook topic text_output/starter_textline.
VB RB Sub fit_textline(text As String, x As Double, y As Double, optlist As String)
C# void fit_textline(String text, double x, double y, String optlist)
Place a single line of text at position (x, y) subject to various options.
text
(Content string) The text to be placed on the page.
x, y The coordinates of the reference point in the user coordinate system where the
text will be placed, subject to various options. See Section 6.1, »Object Fitting«, page 99,
for a description of the fitting algorithm.
optlist An option list specifying font, text, and formatting options. The following options are supported:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Font loading options according to Table 4.3 for implicit font loading (i.e. font option
in the text appearance group not supplied):
ascender, autocidfont, autosubsetting, capheight, descender, embedding, encoding,
fallbackfonts, fontname, fontstyle, keepnative, linegap, metadata, monospace,
readfeatures, replacementchar, subsetlimit, subsetminsize, subsetting, unicodemap, vertical,
xheight
> Input filter options according to Table 5.1:
charref, escapesequence, glyphcheck
> Text appearance options according to Table 5.2:
charspacing, dasharray, decorationabove, fakebold, fillcolor, font, fontsize, gstate,
horizscaling, inittextstate, italicangle, kerning, overline, strikeout, strokecolor, strokewidth,
textrendering, textrise, underline, underlineposition, underlinewidth, wordspacing
> Shaping and typographic options according to Table 5.3:
features, language, script, shaping
> Fitting options according to Table 6.1:
alignchar, blind, boxsize, fitmethod, margin, matchbox, orientate, position, rotate,
showborder, shrinklimit
> Options for Textline formatting according to Table 5.5:
inittextstate, leader, shadow, stamp, textpath, xadvancelist
Details If inittextstate=false (which is the default), the current text and graphics state parameters will be used to control the appearance of the text output unless they are explicitly
overridden by options.
If inittextstate=true the default values of the text and graphics state parameters will
be used to control the appearance of the text output unless they are explicitly overridden by options. The Textline options will not affect any output created after this call to
fit_textline( ).
The current text and graphics state will not be modified by this function (in particular, the current font will be unaffected). However, the textx/texty parameters will be adjusted to point to the end of the generated text output.
Scope page, pattern, template, glyph; this function should not be used in vertical writing mode.
5.2 Single-Line Text with Textlines
71
Params See Table 4.8 and Table 4.9.
Table 5.5 Additional options for fit_textline( )
option
explanation
inittextstate
(Boolean) If true all text appearance options will be initialized with the respective default values. If
false the current text state values will be used. Default: false
leader
(Option list; will be ignored if boxsize is not specified or the width of the box is 0) Specifies filler text (e.g.
dot leaders) and formatting options. Leaders will be inserted repeatedly between the border of the text
box and the text.
See Table 5.4 for a list of supported suboptions. Default: no leader
shadow
(Option list) Create a shadow effect for the text (default: no shadow):
stamp
offset
(List of 2 floats) The shadow’s offset from the reference point of the text line in user
coordinates or as a percentage of the font size. Default: {5% -5%}
fillcolor
(Color) Color of the shadow. Default: {gray 0.8}
gstate
(Gstate handle) Graphics state retrieved with create_gstate( ) which will be applied to the
shadow. Default: none
(Keyword; will be ignored if boxsize is not specified) This option can be used to create a diagonal stamp
within the box specified in the boxsize option. The text comprising the stamp will be as large as possible.
The options position, fitmethod, and orientate (only north and south) will be honored when placing
the stamp text in the box. Default: none.
textpath
ll2ur
The stamp will run diagonally from the lower left corner to the upper right corner.
ul2lr
The stamp will run diagonally from the upper left corner to the lower right corner.
none
No stamp will be created.
(Option list) Draw text along a path. Text beyond the end of the path will not be displayed. See Table 5.6
for a list of supported suboptions. If showborder=true the flattened path will be drawn with the current
linewidth and stroke color.
The following options of fit_textline( ) have modified meaning for text on a path:
matchbox A separate box will be created for each glyph.
position
The first value specifies the starting position of the text relative to the length of the path
(left/center/right). If the text is longer than the path it will always begin at startoffset.
The second value specifies the vertical position of each glyph relative to the path, i.e. which
part of the glyph box will touch the path (bottom/center/top).
rotate
Specifies a rotation angle for each glyph.
The following fitbox-related options will be ignored:
boxsize, margin, fitmethod, orientate, alignchar, showborder, stamp, leader
Kerning and text with CJK legacy encodings are not supported for text on a path.
xadvancelist
(List of floats) Specifies the advance width of all glyphs in the text in user coordinates. The length of the
list must be less or equal than the number of glyphs in the text. The xadvance values will be used instead
of the standard glyph widths. Other effects, such as kerning and character spacing, are unaffected.
VB RB Function info_textline(text As String, keyword As String, optlist As String) As Double
C# double info_textline(text As String, String keyword, String optlist)
Perform Textline formatting without creating output and query the resulting metrics.
text
72
(Content string) The contents of the Textline.
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.6 Suboptions for the textpath option of fit_textline( )
option
explanation
path
(Path handle; required) The path to use as baseline for text output. By default, the text will be placed at
the left side of the path and the path will serve as the text baseline. However, if the second keyword in
the position option is top the text will be placed to the right of the path and the top of the text will
touch the path. The parameters x and y of fit_textline( ) will be used as reference point for the path.
rotate
(Float) Rotate the path, using the reference point as center and the specified value as rotation angle in
degrees. Default: 0
scale
(List with one or two floats) Scale the path, using the reference point as center and the specified value(s)
as horizontal and vertical scaling factor(s). If only one value is supplied it will be used for both directions.
Default: {1 1}
startoffset
(Float or percentage) The offset of the starting point of the text along its path in user coordinates or as
percentage of the path length. Default: 0
tolerance
(Float or percentage) Indicates how much the last glyph on the path is allowed to extend beyond the
path. The value is specified in user coordinates or as a percentage of the fontsize. Default: 25%
subpaths
(List of integers or single keyword) List with the numbers of subpaths to be drawn. The keyword all specifies all subpaths. Default: all
close
(Boolean) If true, each subpath will be closed with a straight line. Default: the value specified when the
path was constructed, or false if no value was specified
round
(Float) For each subpath, adjacent line vertices will be rounded in their joining point by a circular arc
with the line segments as its tangents and with the specified radius. If the radius is negative the arc will
be swept so that the corners are circularly grooved. If close=true and no line from the last to the first
point was specified, the first line and the closing line will also be rounded. If round=0 no rounding will be
done. Default: the value specified when the path was constructed, or 0 if no value was specified
keyword
A keyword specifying the requested information according to Table 5.7.
optlist An option list specifying options for fit_textline( ). Options which are not relevant for the requested keyword will silently be ignored.
Returns The value of some text metric value as requested by keyword.
Details This function will perform all calculations required for placing the text according to the
supplied options, but will not actually create any output on the page. The text reference
position is assumed to be {0 0}.
If errorpolicy=return this function will return 0 in case of an error. If errorpolicy=
exception this function will throw an exception in case of an error (even for the keyword
wellformed).
Scope any except object
Table 5.7 Keywords for info_textline( )
keyword
explanation
angle
Rotation angle of the baseline in degree, i.e. the text rotation
ascender
capheight
descender
Corresponding typographic value in user coordinates
endx, endy
x/y coordinates of the logical text end position in the user coordinate system
5.2 Single-Line Text with Textlines
73
Table 5.7 Keywords for info_textline( )
keyword
explanation
height
Height of the text string according to the boxheight specification of the matchbox
perpendiculardir
Unit vector perpendicular to writingdir; for standard horizontal text this would be (0, 1), for
vertical text (1, 0)
replacedchars
Number of characters which have been replaced with a slightly different glyph from the internal
list of typographically similar characters or with a glyph from a fallback font because they
couldn’t be mapped to a code in the current encoding or to a glyph in the font. This value can
only be different from 0 if glyphcheck=replace.
righttoleft
1 if the global output direction for the text is right-to-left, and 0 for left-to-right or vertical text.
The global direction will be determined based on the initial characters and any directional markers which may be present in the text (e.g. U+202D or &LRO; LEFT-TO-RIGHT OVERRIDE).
scalex, scaley
Horizontal and vertical scaling factors. If these are different from 1 the text had to be scaled to fit
into the box.
scriptlist
String containing the space-separated list of the names of all scripts in the text. This may be useful to prepare text shaping. The script names are sorted by frequency in descending order. The
scripts _none and _latn will be ignored since they are not relevant for shaping. If only _none and
_latn characters are present in the text, -1 will be returned.
startx, starty
x/y coordinates of the logical text start position in the user coordinate system
unknownchars
If glyphcheck=none: number of skipped characters. The number includes character references
which couldn’t be resolved, and characters which couldn’t be mapped to a code in the current encoding or to a glyph in the font.
If glyphcheck=replace: number of characters which were replaced with the specified replacement character (option replacementchar). The number includes characters which couldn’t be
mapped to a code in the current encoding or to a glyph in the font, and characters which couldn't
be replaced with typographically similar characters.
unmappedchars
The number of characters which have been skipped or replaced, i.e. the sum of replacedchars
and unknownchars.
wellformed
1 if the text is wellformed according to the font/encoding (and textformat, if applicable) selected
in the corresponding options, otherwise 0.
width
Width of the text string (in horizontal writing mode) or width of the widest glyph (in vertical
writing mode). Character spacing will not be applied after the last glyph.
writingdirx
writingdiry
x/y coordinates of the dominant writing direction (direction of inline text progression), i.e. unit
vector from (startx, starty) to (endx, endy). For left-to-right horizontal text the values will
be (1, 0), for vertical text (0, -1), and for right-to-left horizontal text (-1, 0). The writing direction will be determined based on the shaping and vertical options as well as the directionality properties of the text.
xheight
Corresponding typographic value in user coordinates
74
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
5.3 Multi-Line Text with Textflows
Cookbook A full code sample can be found in the Cookbook topic text_output/starter_textflow.
VB RB Function add_textflow(textflow as Long, text As String, optlist As String) As Long
C# int add_textflow(int textflow, String text, String optlist)
Create a Textflow object, or add text and explicit options to an existing Textflow.
textflow Textflow handle returned by an earlier call to create_textflow( ) or add_
textflow( ), or -1 to create a new Textflow.
text (Content string) The contents of the Textflow. The text may not contain any inline options.
optlist An option list specifying Textflow options according to Table 5.3 and Table 5.8.
The following options are supported:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Font loading options according to Table 4.3 for implicit font loading (i.e. font option
in the text appearance group not supplied):
ascender, autocidfont, autosubsetting, capheight, descender, embedding, encoding,
fallbackfonts, fontname, fontstyle, keepnative, linegap, metadata, monospace,
readfeatures, replacementchar, subsetlimit, subsetminsize, subsetting, unicodemap, vertical,
xheight
> Input filter options according to Table 5.1:
charref, escapesequence, glyphcheck
> Text appearance options according to Table 5.2:
charspacing, dasharray, decorationabove, fakebold, fillcolor, font, fontsize, gstate,
horizscaling, inittextstate, italicangle, kerning, overline, strikeout, strokecolor, strokewidth,
textrendering, textrise, underline, underlineposition, underlinewidth, wordspacing
> Shaping and typographic options according to Table 5.3:
features, language, script, shaping
> Options for Textflow formatting according to Table 5.8:
alignment, avoidemptybegin, fixedleading, hortabmethod, hortabsize, lastalignment,
leader, leading, leftindent, minlinecount, parindent, rightindent, ruler, tabalignment
> Options for controlling the line break algorithm according to Table 5.9:
adjustmethod, advancedlinebreak, avoidbreak, locale, maxspacing, minspacing, nofitlimit,
shrinklimit, spreadlimit
> Command options according to Table 5.10:
comment, mark, matchbox, nextline, nextparagraph, resetfont, return, space
> Text semantics options according to Table 5.11:
charclass, charmapping, hyphenchar, tabalignchar
Returns A Textflow handle which can be used in Textflow-related function calls. The handle is
valid until the end of the enclosing document scope, or until delete_textflow( ) is called
with this handle.
If the textflow parameter is -1, a new Textflow will be created and the corresponding
handle will be returned. Otherwise the handle supplied in the textflow parameter will be
returned. By default, this function returns -1 in case of an error. However, this behavior
can be changed with the errorpolicy parameter or option. In case of an error the handle
5.3 Multi-Line Text with Textflows
75
supplied in the textflow parameter can no longer be used in subsequent function calls
(except in delete_textflow( ) if it was different from -1).
Details This function processes the supplied text and creates an internal data structure from it.
It determines text portions (e.g. words) which will later be used by the formatter, converts the text to Unicode if possible, determines potential line breaks, and calculates the
width of text portions based on font and text options.
As opposed to create_textflow( ), which expects all text contents and options in a single call, this function is useful for supplying the text contents and options for a Textflow in separate calls. It will add the supplied text and optlist to a new or existing Textflow. Options specified in optlist will be evaluated before processing text. Both text and
optlist may be empty.
If textflow=-1 this function is almost equivalent to create_textflow( ). However, unlike
create_textflow( ) this function will not search for inline options in text. It is therefore
not necessary to redefine the start character for inline option lists or to specify the
length of the text with an inline option (not even for non-Unicode text).
This function will preprocess the supplied text and options, but does not create any
output in the generated PDF document, but only prepares the text. Use fit_textflow( ),
fit_table( ), or fill_textblock( ) to create output with the preprocessed Textflow handle.
By default, a new line will be forced by the characters U+000B (VT), U+2028 (LS),
U+000A (LF), U+000D (CR), CRLF, U+0085 (NEL), U+2029 (PS), and U+000C (FF). These
control characters will not be interpreted for symbolic fonts loaded with encoding=
builtin. All of these except VT and LS force a new paragraph (which means that the
parindent option will be effective). FF immediately stops the process of fitting text to the
current fitbox (the function fit_textflow( ) will be exited with a return string of _
nextpage).
A horizontal tab character (HT) sets a new start position for subsequent text. The details of this are controlled by the hortabmethod and hortabsize options.
Soft hyphen characters (SHY) will be replaced with the character specified in the
hyphenchar option if there is a line break after the soft hyphen.
Vertical writing mode is not supported.
Scope any except object
Table 5.8 Additional formatting options for add/create_textflow( ) and inline options in create_textflow( )
option
explanation
alignment
(Keyword) Specifies formatting for lines in a paragraph. Default: left.
left
Left-aligned, starting at leftindent+parindent (for the first line of a paragraph) and at
leftindent (for all other lines)
center
Centered between leftindent and rightindent
right
Right-aligned, ending at rightindent
justify
Left- and right-aligned
avoidemptybegin
(Boolean) If true, empty lines at the beginning of a fitbox will be deleted. Default: false
fixedleading
(Boolean) If true, the first leading value found in each line will be used. Otherwise the maximum of all
leading values in the line will be used. fixedleading will be forced to true if the wrap option of fit_
textflow( ) or the createwrapbox suboption of the matchbox option will be used to wrap the text
around shapes. Default: false
76
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.8 Additional formatting options for add/create_textflow( ) and inline options in create_textflow( )
option
explanation
hortabmethod
(Keyword) Treatment of horizontal tabs in the text. If the calculated position is to the left of the current
text position, the tab will be ignored. Default: relative.
relative
The position will be advanced by the amount specified in hortabsize.
typewriter The position will be advanced to the next multiple of hortabsize.
ruler
hortabsize
The position will be advanced to the n-th tab value in the ruler option, where n is the
number of tabs found in the line so far. If n is larger than the number of tab positions the
relative method will be applied.
(Float or percentage) Width of a horizontal tab1. The interpretation depends on the hortabmethod option. Default: 7.5%
lastalignment (Keyword) Formatting for the last line in a paragraph. All keywords of the alignment option are supported, plus the following (default: auto):
auto
leader
Use the value of the alignment option if it is different from justify, else left
(Option list) Specifies filler text (e.g. dot leaders) and formatting options. Leaders will be inserted until
the next tab position, or the end of the line if no tab is available. Leaders never span more than one line.
See Table 5.4 for a list of supported suboptions. Default: no leader
leading
(Float or percentage) Distance between adjacent text baselines2. The actual value will be determined as
follows: if there are option lists at the beginning of a line, the leading will be determined by the last relevant option (font, fontsize, leading, etc.). If there are additional option lists on the same line, any
options relevant for leading will only be taken into account if fixedleading=false. If there are no option lists in the line at all, the previous leading value will be taken into account. Default: 100%
leftindent
(Float or percentage) Left indent of text lines1. If leftindent is specified within a line and the resulting
position is to the left of the current text position, this option will be ignored for this line. Default: 0
minlinecount
(Integer) Minimum number of lines in the last paragraph of the fitbox. If there are fewer lines they will
be placed in the next fitbox. The value 2 can be used to prevent single lines of a paragraph at the end of
a fitbox (»orphans«). Default: 1
parindent
(Float or percentage) Left indent of the first line of a paragraph1. The amount will be added to
leftindent. Specifying this option within a line will act like a tab. Default: 0
rightindent
(Float or percentage) Right indentation of text lines1. Default: 0
ruler
(List of floats or percentages) List of absolute tab positions for hortabmethod=ruler1. The list may contain up to 32 non-negative entries in ascending order. Default: integer multiples of hortabsize
tabalignment
(List of keywords; only with hortabmethod=ruler) Alignment for tab stops. Each entry in the list defines
the alignment for the corresponding entry in the ruler option. Default: left.
center
Text will be centered at the tab position.
decimal
The first instance of tabalignchar will be left-aligned at the tab position. If no tabalignchar is found, right alignment will be used instead.
left
Text will be left-aligned at the tab position.
right
Text will be right-aligned at the tab position.
1. In user coordinates or as a percentage of the width of the fitbox
2. In user coordinates or as a percentage of the font size
5.3 Multi-Line Text with Textflows
77
Table 5.9 Additional options for controlling the line break algorithm for add/create_textflow( ) and inline options in
create_textflow( )
option
explanation
adjustmethod (Keyword) Method used to adjust a line when a text portion doesn’t fit into a line after compressing or
expanding the distance between words subject to the limits specified by the minspacing and maxspacing options. Default: auto.
auto
The following methods are applied in order: shrink, spread, nofit, split.
clip
Same as nofit, except that the long part at the right edge of the fitbox (taking into account
the rightindent option) will be clipped.
nofit
The last word will be moved to the next line provided the remaining (short) line will not be
shorter than the percentage specified in the nofitlimit option. Even justified paragraphs
may look slightly ragged.
shrink
If a word doesn’t fit in the line the text will be compressed subject to shrinklimit. If it still
doesn’t fit the nofit method will be applied.
split
The last word will not be moved to the next line, but will forcefully be split after the last
character in the box. If hyphenchar is different from none a hyphen character will be
inserted. Setting hyphenchar=none must be used to suppress the hyphen character (e.g. in
formulae or URLs) since PDFlib does not automatically detect such situations.
spread
The last word will be moved to the next line and the remaining (short) line will be justified
by increasing the distance between characters in a word, subject to spreadlimit. If
justification still cannot be achieved the nofit method will be applied.
advancedlinebreak
(Boolean) Enable the advanced line breaking algorithm which is required for complex scripts. This is required for linebreaking in scripts which do not use space characters for designating word boundaries,
e.g. Thai. The options locale and script will be honored. Default: false
avoidbreak
(Boolean) If true, line breaking opportunities (e.g. at space characters) will be ignored until avoidbreak
is reset to false. Mandatory line breaks (e.g. at a newline) and methods defined by adjustmethod will
be still performed. In particular, adjustmethod=split may still create hyphenation. Default: false
locale
(Keyword) The locale which will be used for localized linebreaking methods if advancedlinebreak=
true. The keywords consists of one or more components, where the optional components are separated
by an underscore character ’_’ (the syntax slightly differs from NLS/POSIX locale IDs):
> A required two- or three-letter lowercase language code according to ISO 639-2 (see www.loc.gov/
standards/iso639-2), e.g. en, (English), de (German), ja (Japanese). This differs from the language option.
> An optional four-letter script code according to ISO 15924 (see www.unicode.org/iso15924/iso15924codes.html), e.g. Hira (Hiragana), Hebr (Hebrew), Arab (Arabic), Thai (Thai).
> An optional two-letter uppercase country code according to ISO 3166 (see www.iso.org/iso/country_
codes/iso_3166_code_lists), e.g. DE (Germany), CH (Switzerland), GB (United Kingdom)
The keyword _none specifies that no locale-specific processing will be done.
Specifying a locale is required for advanced line breaking for some scripts, e.g. Thai. Default: _none
Examples: Thai, de_DE, en_US, en_GB
maxspacing
minspacing
(Float or percentage; only relevant if the line contains at least one space character U+0020 and
alignment=justify) Maximum or minimum distance between words (in user coordinates, or as a percentage of the width of the space character). The calculated word spacing is limited by the provided values (but the wordspacing option will still be added). Defaults: minspacing=50%, maxspacing=500%
nofitlimit
(Float or percentage; only relevant with alignment=justify) Lower limit for the length of a line with
the nofit method1. Default: 75%.
shrinklimit
(Percentage) Lower limit for compressing text with adjustmethod=shrink; the calculated shrinking factor is limited by the provided value, but will be multiplied with the horizscaling option. Default: 85%
spreadlimit
(Float or percentage) Upper limit for the distance between characters for the spread method2; the calculated distance will be added to the value of the charspacing option. Default: 0
78
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.10 Additional command options for add/create_textflow( ) and inline options in create_textflow( )
option
explanation
comment
(String) Arbitrary text which will be ignored; useful for commenting option lists or macros
mark
(Integer) Store the supplied number internally as a mark. The mark which has been stored most recently
can later be retrieved with info_textflow( ) and the lastmark keyword. This may be useful for determining which portions of text have already been placed on the page.
matchbox
(Option list) Option list for creating a matchbox according to Table 6.3
nextline
nextparagraph
(Boolean) Force a new line or paragraph.
resetfont
(Boolean) Reset font and fontsize to the most recently values which were different from the current
settings (either different font or font size). This may be useful to reset the font after inserts, such as italic
text. The font option has precedence over this option. This command only makes sense after the second
setting of any font-related parameters, that differ from the first setting, and will be ignored otherwise.
return
(String; must not start with an underscore _ character) Exit create_textflow( ) or add_textflow( ) with
the supplied string as return value.
space
(Float or percentage) The text position will be advanced by the provided value2.
Table 5.11 Additional text semantics options for add/create_textflow( ) and inline options in create_textflow( )
option
explanation
charclass
(List of pairs, where the first element in each pair is a keyword, and the second element is either a Unichar or a list of Unichars; will be ignored if advancedlinebreak=true) The specified Unichars will be
classified by the specified keyword to determine the line breaking behavior of those character(s):
letter
behave like a letter (e.g. a B)
punct
behave like a punctuation character (e.g. + / ; : )
open
behave like an open parenthesis (e.g. [ )
close
behave like a close parenthesis (e.g. ] )
default
reset all character classes to PDFlib’s builtin defaults
Example: charclass={ close »
charmapping
open «
letter={/ : =} punct & }
(List of pairs, where each pair either contains two unichars or a unichar and a list of unichar and integer)
Replace individual characters with one or more instances of another character. The option list contains
one or more pairs of Unichars. The first character in each pair will be replaced with the second character.
Instead of one-to-one mapping the second element in each pair may be an option list containing a unichar and a count:
count > 0 The replacement character will be repeated count times.
count < 0 A sequence of multiple instances of the character will be reduced to the absolute value of
the specified number.
count = 0 The character will be deleted.
Examples:
charmapping={ hortab space CRLF space LF space
charmapping={ shy {shy 0} }
charmapping={ hortab {space 4} }
CR space }
hyphenchar
(Unichar or keyword) Character which replaces a soft hyphen at line breaks. The value 0 and the keyword none completely suppress hyphens. Default: U+00AD (soft hyphen) if available in the font,
U+002D (hyphen-minus) otherwise
tabalignchar
(Unichar) Character at which decimal tabs will be aligned. Default: U+002E ’.’
5.3 Multi-Line Text with Textflows
79
Macros for Textflow options. Option lists for Textflows (either in the optlist parameter
of create_textflow( ) or add_textflow( ), or inline in the text supplied to create_textflow( ))
may contain macro definitions and macro calls according to Table 5.12. Macros may be
useful for having a central definition of multiply used option values, such as font
names, indentation amounts, etc. Before parsing an option list each contained macros
will be substituted with the contents of the corresponding option list provided in the
macro definition. The resulting option list will then be parsed. The following example
demonstrates a macro definition for two macros:
<macro {
comment { The following macros are used as paragraph styles }
H1 {fontname=Helvetica-Bold encoding=winansi fontsize=14 }
body {fontname=Helvetica encoding=winansi fontsize=12 }
}>
These macros could be used as follows in an option list:
<&H1>Chapter 1
<&body>This chapter talks about...
The following rules apply to macro definition and use:
> Macros may be nested to an arbitrary depth (macro definitions may contain calls to
other macros).
> Macros can not be used in the same option list where they are defined. In create_
textflow( ) a new inline option list which uses the macro can be started immediately
after the end of the inline option list in which the macro is defined. When using add_
textflow( ) one function call is required to define the macro, and another one to use it
(since add_textflow( ) accepts only a single option list at a time).
> Macro names are case-insensitive.
> Undefined macros will result in an exception.
> Macros can be redefined at any time.
Table 5.12 Option list macro definitions and calls for add/create_textflow( ) and fit_textflow( )
option
explanation
macro
(List of pairs) Each pair describes the name and definition of a macro as follows:
name
(string) The name of the macro which can later be used for macro calls. Macros which have
already been defined can be redefined later. The special name comment will be ignored.
suboptlist An option list which will literally replace the macro name when the macro is called. Leading
and trailing whitespace will be ignored.
&name
The macro with the specified name will be expanded, and the macro name (including the & character)
will be replaced by the macro’s contents, i.e. the suboptlist which has been defined for the macro (without the surrounding braces). The macro name is terminated by whitespace, {, }, =, or &. Therefore, these
characters can not be used as part of a macro name.
Nested macros will be expanded without any nesting limit. Macros contained in string options will also
be expanded. Macro substitution must result in a valid option list.
80
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
VB RB Function create_textflow(text As String, optlist As String) As Long
C# int create_textflow(String text, String optlist)
Create a Textflow object from text contents, inline options, and explicit options.
text (Content string) The contents of the Textflow. It may contain text in various encodings, macros (see »Macros for Textflow options«, page 80), and inline option lists according to Table 5.8 and Table 5.13 (see also »Inline option lists for Textflows«, page 81). If
text is an empty string, a valid Textflow handle will be returned nevertheless.
optlist An option list specifying Textflow options. Options specified in the optlist parameter will be evaluated before those in inline option lists in text so that inline options
have precedence over options provided in the optlist parameter. The following options
can be used:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> All options of add_textflow( ) (see option list of add_textflow( ))
> Options for controlling inline option list processing according to Table 5.13:
begoptlistchar, endoptlistchar, textlen
Returns A Textflow handle which can be used in calls to add_textflow( ), fit_textflow( ), info_
textflow( ), and delete_textflow( ). The handle is valid until the end of the enclosing
document scope, or until delete_textflow( ) is called with this handle. By default this function returns -1 in case of an error. This behavior can be changed with the errorpolicy parameter or option.
Details This function accepts options and text to be prepared for Textflow. Unlike add_
textflow( ) the text may contain inline options. Searching for inline option lists can be
disabled for parts or all of the text by supplying the textlen option in the optlist parameter (see »Inline option lists for Textflows«, page 81).
This function does not create any output in the generated PDF document, but only
prepares the text according to the supplied options. Use fit_textflow( ) to create output
with the resulting Textflow handle.
See the Details section of add_textflow( ) for more information regarding special characters, line breaking, etc.
Scope any except object
Table 5.13 Additional options for inline option list processing in create_textflow( )
option
explanation
begoptlistchar
(Unichar or keyword) Character which starts inline option lists. Replacing the default character may be
useful if this character appears in the text literally (see »Inline option lists for Textflows«, page 81). The
keyword none can be used to completely disable the search for option lists. Default: U+003C (<)
endoptlistchar
(Unichar; U+007D ’}’ is not allowed) Character which terminates inline option lists. Default: U+003F (>)
textlen
(Integer or keyword) Number of characters before the next inline option list (see »Inline option lists for
Textflows«, page 81). The characters are counted before character references are resolved, e.g.
<textlen=8>&#x2460;<...>. The keyword all specifies all of the remaining text. Default: the text will
be searched for the next occurrence of begoptlistchar.
Inline option lists for Textflows. The content provided in the text parameter of create_
textflow( ) (but not add_textflow( )) may include an arbitrary number of option lists (in-
5.3 Multi-Line Text with Textflows
81
line options) specifying Textflow options according to Table 5.8. All of these options can
alternatively be provided in the optlist parameter of create_textflow( ) and add_
textflow( ). The same option can be specified multiply in a single option list; in this case
only the last occurrence of an option will be taken into account.
Inline option lists must be enclosed with the characters specified in the begoptlistchar and endoptlistchar options (by default: < and >). Obviously, conflicts could arise if
the character used for starting inline option lists must also be used in the actual text.
There are several methods to resolve this conflict, depending on whether or not the text
contains any inline option lists. Remember that add_textflow( ) completely separates
text and options, so the conflict doesn’t arise there.
If the text does not contain any inline options lists you can completely disable the
search for inline option lists by one of the following methods:
> Set begoptlistchar=none in the optlist parameter of create_textflow( ).
> Set the textlen option in the optlist parameter of create_textflow( ) to the length of the
full text.
If the text actually contains inline option lists you can avoid the conflict between text
contents and the begoptlistchar for starting an inline option list by using one of the following methods:
> Replace all occurrences of the < character in the text with the corresponding numeric
or character entity reference (&#x3C; or &lt;) and start inline option lists with the literal < character:
A&lt;B<fontname=Helvetica encoding=winansi>
Note that this method does not work for fonts with encoding=builtin.
> Set the begoptlistchar option in the optlist parameter of create_textflow( ) or an inline
option list to a character which is not used in the text (e.g. $), and use this character
to start inline option lists:
<begoptlistchar=$>A<B$fontname=Helvetica encoding=winansi>
> Specify the length of the next text fragment (until the start of the next inline option
list) in the preceding inline option list using the textlen option:
<textlen=3>A<B<fontname=Helvetica encoding=winansi>
Note If an inline option list is provided immediately after another option list, they are assumed to
enclose a text fragment of zero length. This is important when supplying the textlen option in
the first option list.
VB RB Function fit_textflow(textflow As Long,
llx As Double, lly As Double, urx As Double, ury As Double, optlist As String) As String
C# String fit_textflow(int textflow, double llx, double lly, double urx, double ury, String optlist)
Format the next portion of a Textflow.
textflow
A Textflow handle returned by a call to create_textflow( ) or add_textflow( ).
llx, lly, urx, ury x and y coordinates of the lower left and upper right corners of the target rectangle (the fitbox) in user coordinates. The corners can also be specified in reverse
order. Shapes other than a rectangle can be filled with the wrap option.
82
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
optlist An option list specifying processing options according to Table 5.14. The following options can be used:
blind, createfittext, createlastindent, exchangefillcolors, exchangestrokecolors, firstlinedist,
fitmethod, fontscale, lastlinedist1, linespreadlimit, maxlines, minfontsize, orientate,
returnatmark, rewind, rotate, showborder, showtabs, stamp, verticalalign1, wrap
Returns A string which specifies the reason for returning from the function:
> _stop: all text in the Textflow has been processed. If the text was empty, _stop will always be returned, even if the return or mark/returnatmark option was supplied.
> _nextpage: Waiting for the next page (caused by a form feed character U+000C). Another call to fit_textflow( ) is required for processing the remaining text.
> _boxfull: Some text was placed in the fitbox, but no more space is available, or the
maximum number of lines (as specified via the maxlines option) has been placed in
the fitbox, or fitmethod=auto and minfontsize has been specified but the text didn’t fit
into the fitbox. Another call to fit_textflow( ) is required for processing the remaining
text.
> _boxempty: The box doesn’t contain any text at all after processing. This may happen
if the size of the fitbox is too small to hold any text, or a wrapbox was larger than the
fitbox. No more calls to fit_textflow( ) with the same fitbox should be issued in order
to avoid infinite loops.
> _mark#: The option returnatmark has been specified with the number #, and the
mark with the number specified in this option has been placed.
> Any other string: The string supplied to the return command in an inline option list.
If there are multiple simultaneous reasons for returning, the first in the list (from top to
bottom) will be reported. The returned string is valid until the next call to this function.
Details The current text and graphics states do not influence the text output created by this
function (this is different from fit_textline( )). Use fillcolor, strokecolor and other text appearance options (see Table 5.2) in create_textflow( ) or add_textflow( ) to control the appearance of the text. After returning from this function the text state will be unchanged. However, the textx/texty parameters will be adjusted to point to the end of the
generated text output (unless the blind option has been set to true).
Scope page, pattern, template, glyph
Table 5.14 Options for fit_textflow( )
option
explanation
blind
(Boolean) If true, no output will be generated, but all calculations will be performed and the formatting
results can be checked with info_textflow( ). Default: false
createfittext
(Boolean) If true the text placed in the current fitbox will be saved in memory so that it can later be retrieved with a call to info_textflow( ) and the keyword fittext. Default: true
createlastindent
(Option list) Reserve some space at the end of the last line in the fitbox and optionally create a matchbox
which can be used to fill the reserved space. The reserved space may be useful to add continuation dots,
an image, a link to the continuation of the text, etc. at the end of the text. Supported suboptions:
rightindent (Float or percentage) Additional right indent of the last text line in the fitbox in user coordinates or as percentage of the width of the fitbox. The value will be added to the value of the
rightindent option of add/create_textflow( ) . Default: 0
matchbox (Option list according to Table 6.3) Create a matchbox at the end of the last line. If the
matchbox option boxwidth is not specified, the value of rightindent will be used as
boxwidth. If boxwidth=0 no box will be created.
5.3 Multi-Line Text with Textflows
83
Table 5.14 Options for fit_textflow( )
option
explanation
exchangefillcolors
(List with an even number of colors) Each pair in the list specifies an original fill color and a replacement
color. Whenever the Textflow specifies the original fill color within the fitbox it will be replaced with the
specified replacement color. This may be useful to adjust the colors to the background. Example:
exchangefillcolors={{gray 0} white Orchid DeepPink {rgb 1 0 1} MediumBlue}
exchangestrokecolors
(List with an even number of colors) Each pair in the list specifies an original stroke color and a replacement color. Whenever the Textflow specifies the original stroke color within the fitbox it will be replaced
with the specified replacement color. This may be useful to adjust the colors to the background.
firstlinedist1
(Float, percentage, or keyword) Distance between the top of the fitbox and the baseline for the first line
of text, specified in user coordinates, as a percentage of the relevant font size (the first font size in the
line if fixedleading=true, and the maximum of all font sizes in the line otherwise), or as a keyword. Default: leading.
leading
The leading value determined for the first line; typical diacritical characters such as À will
touch the top of the fitbox.
ascender
The ascender value determined for the first line; typical characters with larger ascenders, such
as d and h will touch the top of the fitbox.
capheight The capheight value determined for the first line; typical capital uppercase characters such as
H will touch the top of the fitbox.
xheight
The xheight value determined for the first line; typical lowercase characters such as x will
touch the top of the fitbox.
If fixedleading=false the maximum of all leading, ascender, xheight, or capheight values found in
the first line will be used.
fitmethod
(Keyword) Specifies the method used to fit the text into the fitbox. Default: clip
auto
fit_textflow( ) will repeatedly be called in blind mode with reduced font size and other fontrelated options (see fontscale) until the text fits into the fitbox (but see also option
minfontsize)
clip
The text will be truncated at the bottom of the fitbox.
nofit
The text can extend beyond the bottom of the fitbox.
fontscale
(Float or percentage) Values of fontsize and absolute values (but not percentages) of leading, minspacing, maxspacing, spreadlimit, and space will be multiplied with the supplied scaling factor or percentage. Default: 1 if rewind=0, otherwise the value supplied with the corresponding call to fit_
textflow( ).
gstate
(Gstate handle) Handle for a graphics state retrieved with create_gstate( ). The graphics state affects all
text placed with this function. If another graphics state has already been supplied to add/create_
textflow( ) both graphics states will be merged. Default: no graphics state (i.e. current settings will be
used)
lastlinedist1
(Float, percentage, or keyword; will be ignored for fitmethod=nofit) Minimum distance between the
baseline for the last line of text and the bottom of the fitbox, specified in user coordinates, as a percentage of the font size (the first font size in the line if fixedleading=true, and the maximum of all font sizes
in the line otherwise), or as a keyword. Default: 0, i.e. the bottom of the fitbox will be used as baseline,
and typical descenders will extend below the fitbox. The following keyword can be used:
descender The descender value determined for the last line; typical characters with descenders, such as g
and j will touch the bottom of the fitbox.
If fixedleading=false the maximum of all descender values found in the last line will be used.
linespreadlimit
(Float or percentage; only for verticalalign=justify) Maximum amount in user coordinates or as percentage of the leading for increasing the leading for vertical justification. Default: 200%
maxlines
(Integer or keyword) Maximum number of lines in the fitbox, or the keyword auto which means that as
many lines as possible will be placed in the fitbox. When the maximum number of lines has been placed
fit_textflow( ) will return the string _boxfull. Default: auto
84
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.14 Options for fit_textflow( )
option
explanation
minfontsize
(Float or percentage) Minimum font size allowed when text is scaled down to fit into the fitbox, especially for fitmethod=auto. The limit is specified in user coordinates or as a percentage of the height of the
fitbox. If the limit is reached and the text still does not fit the string _boxfull will be returned. Default:
0.1%
mingapwidth
(Float or percentage) Minimal horizontal width for fitting text between shapes (e.g. between wrap contours) in user coordinates or as a percentage of the fontsize. This may be useful to avoid ugly formatting
results in cases where only small gaps are left between wrap contours. Default: 10%
orientate
(Keyword) Specifies the desired orientation of the text when it is placed. Default: north.
north
upright
east
pointing to the right
south
upside down
west
pointing to the left
returnatmark
(Integer) fit_textflow( ) will return prematurely at the text position where the Textflow option mark is
defined with the specified number. The return reason string will be _mark#, where # is the number specified in this option.
rewind
(Integer: -2, -1, 0, or 1) State of the supplied Textflow is reset to the state before some other call to fit_
textflow( ) with the same Textflow handle. Default: 0.
1
Rewind to the state before the first call to fit_textflow( ).
0
Don’t reset the Textflow.
-1
Rewind to the state before the last call to fit_textflow( ).
-2
Rewind to the state before the second last call to fit_textflow( ).
rotate
(Float) Rotate the coordinate system, using the lower left corner of the fitbox as center and the specified
value as rotation angle in degrees. This results in the fitbox and the text being rotated. The rotation will
be reset when the text has been placed. Default: 0
showborder
(Boolean) If true, the border of the fitbox and all wrap boxes will be stroked (using the current graphics
state). This may be useful for development and debugging. Default: false
showtabs
(Keyword) Tab stops and left indents will be visualized with vertical lines as a debugging aid. The lines
will be drawn according to the graphics state which was active before calling fit_textflow( ) (default:
none):
stamp
none
no lines will be drawn
fitbox
lines will be drawn over the full height of the fitbox
validarea
lines will be drawn only in vertical area where they are valid
(Keyword) This option can be used to create a diagonal stamp within the fitbox. Line breaks for the
stamp text should be specified explicitly (i.e. with newline characters or the newline option). If the text
does not contain any explicit line breaks a single-line stamp will be created. The generated stamp text
will be as large as possible, but not larger than the specified fontsize. Supported keywords (default:
none):
ll2ur
The stamp will run diagonally from the lower left corner to the upper right corner.
ul2lr
The stamp will run diagonally from the upper left corner to the lower right corner.
none
No stamp will be created.
5.3 Multi-Line Text with Textflows
85
Table 5.14 Options for fit_textflow( )
option
explanation
verticalalign
wrap
1
(Keyword) Vertical alignment of the text in the fitbox; the firstlinedist and lastlinedist options
will be taken into account as appropriate (default: top):
top
Formatting will start at the first line, and continue downwards. If the text doesn’t fill the
fitbox there may be whitespace below the text.
center
The text will be vertically centered in the fitbox. If the text doesn’t fill the fitbox there may be
whitespace both above and below the text.
bottom
Formatting will start at the last line, and continue upwards. If the text doesn’t fill the fitbox
there may be whitespace above the text.
justify
The text will be aligned with top and bottom of the fitbox. In order to achieve this the leading
will be increased up to the limit specified by linespreadlimit. If this limit is exceeded no
justification will be performed. The height of the first line will only be increased if
firstlinedist=leading.
(Option list according to Table 5.15) The text will run around the areas specified with the suboptions listed in Table 5.15. This can be used to place images or paths within the Textflow and wrap the text around
it, or to fill arbitrary shapes with text. The fitbox will be filled according to the fillrule option, starting
at the border of the fitbox.
By default, the specified areas will not contain any text (except where they overlap), i.e. the text is
wrapped around the shapes. Using the addfitbox and inversefill options the opposite effect can be
achieved: the specified areas will be filled with text, and the rest of the fitbox remains empty. This can be
used to fill arbitrary shapes (and not only the rectangle supplied in the llx/lly/urx/ury parameters)
with text.
Absolute and relative coordinate values will be interpreted in the user coordinate system. A relative coordinate will be added to the previous absolute coordinate. Up to 256 values can be supplied as relative values. Percentages will be interpreted in the fitbox coordinate system, i.e. the lower left corner of the fitbox
is (0, 0) and the upper right corner is (100, 100) (even in a topdown system). Up to 256 values can be supplied as percentage. Examples:
Exclude a box with relative coordinates: wrap={ boxes={{120r 340r 50r 60r}} }
(equivalent to wrap={ boxes={{120 340 170 400}} }
Exclude the upper right quarter of the fitbox: wrap={ boxes={{50% 50% 100% 100%}} }
Fill a triangular shape: wrap={ addfitbox polygons={{50% 80% 30% 40% 70% 40% 50% 80%}} }
Exclude the area of an image with a matchbox called image1: wrap={ usematchboxes={{ image1 }}}
1. The firstlinedist, lastlinedist and verticalalign options always refer to the fitbox, even in the presence of wrap elements.
This means – especially in the case of inverse filling, i.e. the wrap elements are filled with text – that Textflow will not use the bounding
box of the wrap elements to determine the distance between text and fitbox borders and the position of the text box according to the
verticalalign option. This may lead to unexpected results, especially if the outer edges of the wrap elements don’t touch the fitbox.
This effect can almost completely be avoided by supplying wrap elements which touch the fitbox.
VB RB Function info_textflow(textflow As Long, keyword As String) As Double
C# double info_textflow(int textflow, String keyword)
Query the current state of a Textflow after a call to fit_textflow( ).
textflow A Textflow handle returned by a call to add/create_textflow( ) or fill_
textblock( ) with the textflowhandle option.
keyword
A keyword specifying the requested information according to Table 5.16.
Returns The value of some Textflow parameter as requested by keyword. This function returns
correct geometry information even in blind mode (unlike the textx/texty parameters).
Scope any except object
86
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.15 Suboptions for the wrap option of fit_textflow( )
option
explanation
addfitbox
(Boolean) If true, the fitbox will be added to the wrap area. As a result, the shapes specified with other
wrapping options will be filled with text instead of wrapping the text around the shapes. Default:
false
beziers
(List of two or more Bézier curves) Two or more Bézier curves which will be added to the wrap area.
boxes
(List of rectangles) One or more rectangles which will be added to the wrap area.
circles
(List of circles) One or more circles which will be added to the wrap area.
creatematchboxes
(List of option lists) Create matchboxes from one or more rectangles in the boxes option. Each option
list corresponds to one entry in the boxes option (ordering is relevant), and controls the creation of a
matchbox. All relevant matchbox options in Table 6.3 can be used. A suboption list can be empty; in this
case no matchbox will be created for the corresponding wrap box.
fillrule
(Keyword) Specifies the method for determining the interior of overlapping wrap shapes (default: evenodd). See Table 7.2 for details:
evenodd
Use the even-odd rule.
winding
Use the non-zero winding number rule. Use this rule to process the interior of overlapping
circles (i.e. to avoid »doughnut holes«) , or to process the union of overlapping shapes
(instead of the intersection).
inversefill
(Boolean) If true, wrap shape processing starts at the first intersection of the text line with the border of
a wrap element inside the fitbox. If false, processing starts at the fitbox border. If fillrule=evenodd,
the option inversefill=true has the same effect as addfitbox=true. If fillrule=winding, the option
addfitbox=true leads to an empty or a full fitbox (for inversefill=false or true, respectively).
lineheight
(List with two elements, each being a positive float or a keyword) Defines the vertical extent of the text
line to be used for calculating the intersection with wrap areas. Two keywords/floats specify the extent
above and below the text baseline. Supported keywords:
none (no extent), xheight, descender, capheight, ascender, fontsize, leading, textrise
Default: {ascender descender}
usematchboxes
(List of string lists) The first element in each list is a name string which specifies a matchbox. The second
element is either an integer specifying the number of the desired rectangle, or the keyword all to specify all rectangles referring to the selected matchbox. If the second element is missing, it defaults to all.
The bounding box of each rectangle will be added to the wrap area.
offset
(Float or percentage) Horizontal distance between the text and the contour of the wrap area, supplied
in user coordinates or as a percentage of the width of the fitbox. This can be used to horizontally extend
the wrap area. Default: 0
paths
(List of option lists) One or more path objects which will be added to the wrap area. Supported suboptions:
path
(Path handle; required) Handle for the path to be added to the wrap area.
refpoint
(List of two floats or percentages) Coordinates of the reference point for the path in user
coordinates or as percentages of the width and height of the fitbox. Default: {0 0}
The following options of draw_path( ) can also be used (see Table 6.1 and Table 7.8):
align, attachmentpoint, boxsize, close, fitmethod, orientate, position, round, scale, subpaths
polygons
(List of polylines) One or more polylines (not necessarily closed) which will be added to the wrap area.
5.3 Multi-Line Text with Textflows
87
Table 5.16 Keywords for info_textflow( )
keyword
explanation
boundingbox
Handle of the path containing the Textflow’s bounding box in user coordinates or -1
boxlinecount
Number of lines in the last fitbox
firstparalinecount
Number of lines in the first paragraph of the fitbox
firstlinedist
Distance between the first text baseline and the fictitious baseline above (if verticalalign=top
this will be the upper border of the fitbox)
fittext
String index for a text string which corresponds to the text placed in the previous call to fit_
textflow( ). This can be used to determine the amount of text which could be placed in the fitbox.
The string will be normalized as follows: encoding is UTF-16 in Unicode-capable languages or
(EBCDIC-)UTF-8 otherwise, line breaks will be marked with U+000A, and horizontal tabs will be
replaced with a space character U+0020.
fontscale
The value of fontscale after the most recent call to fit_textflow( ) with fitmethod=auto.
lastfont
Handle of the font used in the last text line in the fitbox
lastfontsize
Font size used in the last text line in the fitbox
lastmark
Number of the last mark found in the processed part of the Textflow in the last fitbox (marks can
be set with the mark option)
lastlinedist
Distance between the last text baseline and the fictitious baseline below, assuming unmodified
leading (if verticalalign=bottom this will be the lower border of the fitbox)
lastparalinecount
Number of lines in the last paragraph of the fitbox
leading
The current value of the leading option, as determined by the text and options within the Textflow
leftlinex1, leftliney1
The x and y coordinates of the line with the leftmost start in the most recently filled fitbox, in
current user coordinates
maxlinelength
Length of the longest text line in the most recently filled fitbox
maxliney
1
minlinelength
minliney
1
The y coordinate of the baseline of the longest text line in the most recently filled fitbox, in current user coordinates
Length of the shortest text line in the most recently filled fitbox
The y coordinate of the baseline of the shortest text line in the most recently filled fitbox, in current user coordinates
returnreason
String index which can be used with the string parameter in get_parameter( ) (see Table 2.3) to
retrieve the return reason of the most recent direct or indirect call to fit_textflow( ). The retrieved
return reason will be one of the return strings of fit_textflow( ). This is useful for querying the result of indirect Textflow calls issued internally by fill_textblock( ).
rightlinex1, rightliney1
The x and y coordinates of the line with the rightmost end in the most recently filled fitbox, in
current user coordinates
split
Specifies whether word splitting occurred in the last fitbox:
0
No word had to be split.
1
At least one word had to be split.
textendx, textendy
The x or y coordinate of the current text position after the most recently filled fitbox in current
user coordinates
textheight
Height of the bounding box of the whole text (taking firstlinedist and lastlinedist into account) in current user coordinates
88
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.16 Keywords for info_textflow( )
keyword
explanation
textwidth
Width of the bounding box of the whole text in current user coordinates
used
Percentage of text (0...100) which has been placed so far
x1, y1, ... , x4, y4
Coordinates of the bounding box of the whole text (taking firstlinedist and lastlinedist
into account) in current user coordinates
1. If rotate is different from 0 this value refers to the rotated system.
VB RB Sub delete_textflow(textflow As Long)
C# void delete_textflow(int textflow)
Delete a Textflow and all associated data structures.
textflow
A Textflow handle returned by a call to create_textflow( ) or add_textflow( ).
Details Textflows which have not been deleted with this function will be deleted automatically
at the end of the enclosing document scope. However, failing to call delete_textflow( )
may significantly slow down the application if many Textflows are generated.
Scope any
5.3 Multi-Line Text with Textflows
89
5.4 Table Formatting
Cookbook A full code sample can be found in the Cookbook topic tables/starter_table.
VB RB Function add_table_cell(
table As Long, column As Long, row as Long, text As String, optlist As String) As Long
C# int add_table_cell(int table, int column, int row, String text, String optlist)
Add a cell to a new or existing table.
table A valid table handle retrieved with another call to add_table_cell( ), or -1 to start a
new table. The table handle must not yet have been used in a call to fit_table( ), i.e. all table contents must be defined before placing the table on the page.
column, row Number of the column and row containing the cell. If the cell spans multiple columns and/or rows the numbers of the leftmost column and the topmost row
must be supplied. The first column/row has number 1.
text (Content string) Text for filling the cell. If text is not empty it will be used for filling the cell with fit_textline( ).
optlist An option list specifying table cell formatting details according to Table 5.17.
The following options can be used:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Column and row definition: colwidth, colscalegroup, minrowheight, return, rowheight,
rowjoingroup, rowscalegroup
> Cell properties: checkwordsplitting, colspan, margin, marginleft, marginbottom,
marginright, margintop, matchbox, rowspan
> Cell contents: annotationtype, continuetextflow, fieldname, fieldtype, fitannotation,
fitfield, fitimage, fitpdipage, fittextline, fittextflow, fitpath, image, path, pdipage, repeatcontent, textflow
Returns A table handle which can be used in subsequent table-related calls. If errorpolicy=return
the caller must check for a return value of -1 since it signals an error. In case of an error
only the last cell definition will be discarded; no contents will be added to the table, but
the table handle is still valid. The returned table handle can not be reused across multiple PDF output documents.
Details A table cell can be filled with images, imported PDF pages, path objects, form fields, annotations, Textflows, or Textlines. Multiple content types can be specified for a particular cell in a single function call.
See the PDFlib Tutorial for a description of the table formatting algorithm and width
and height calculations.
Scope any except object
90
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.17 Options for add_table_cell( )
key
explanation
annotationtype
(String) Specifies the type of an annotation to be inserted in the table cell according to Table 12.6.
checkwordsplitting
(Boolean; only relevant for Textflow cells) If true, the table formatter will check whether the Textflow
requires at least one forced word splitting when fitting the text into the table cell. If so, the cell width will
be increased in an attempt to avoid word splittings. Default: true
colscalegroup1
(String) Name of a column group to which the column will be added. All columns in a group will be scaled
uniformly if one of the columns in the group must be enlarged to completely hold long text. If a cell
spans multiple columns the affected columns form a scale group automatically.
colspan
(Integer) Number of columns spanned by the cell. Default: 1
1
(Float or percentage) Width of the column specified in the column parameter. The width can be specified
in user coordinates2, or as a percentage of the width of the table’s first fitbox (see fit_table( )). User coordinates and percentages must not be mixed, i.e. either user coordinates or percentages must be used in
all column width definitions of a table. The column width may be increased automatically if the column
traverses cells containing text. Images and PDF pages in table cells don’t have any influence on column
widths. Default: see option colwidthdefault of fit_table( )
continuetextflow
(Boolean; only relevant for Textflows) If true the contents of the Textflow specified in the textflow option can be continued in another cell provided that the other cell is filled with the same Textflow handle
and continuetextflow=true as well. The parts of the Textflow will be placed in the order in which the
cells are added. PDFlib will not adjust the cell size to the whole Textflow, and the checkwordsplitting
option will be ignored. Therefore, a suitable cell size should be defined.
colwidth
If false the Textflow will be started from the beginning. Default: false
fieldname
(Hypertext string) Form field name for fieldtype.
fieldtype
(String) Specifies the type of a form field to be inserted in the table cell according to Table 12.9. Form field
groups should be defined outside of tables.
fitannotation
(Option list) Annotation options for annotationtype according to Table 12.7.
fitfield
(Option list) Form field options for fieldtype according to Table 12.10.
fitimage
(Option list; only relevant for images and templates) Option list for fit_image( ). This option list will be
applied to place the supplied image or template in the cell. The lower left corner of the inner cell box will
be used as the reference point.
Default: boxsize={<width> <height>} fitmethod=meet position=center, where <width> and
<height> are the calculated width and height of the inner cell box. This calculated option list will be
prepended to the user-specified option list.3
fitpath
(Option list; only relevant for path objects) Option list for draw_path( ). This option list will be applied to
place the path object specified in the path option within its bounding box in the cell. The lower left corner of the inner cell box will be used as reference point.
Default: boxsize={<width> <height>} fitmethod=meet position=center, where <width> and
<height> are the calculated width and height of the inner cell box. This calculated option list will be
prepended to the user-specified option list.3
fitpdipage
(Option list; only relevant for PDI pages; only if PDI is available) Option list for fit_pdi_page( ). This option
list will applied to place the supplied page in the cell. The lower left corner of the inner cell box will be
used as the reference point.
Default: boxsize={<width> <height>} fitmethod=meet position=center, where <width> and
<height> are the calculated width and height of the inner cell box. This calculated option list will be
prepended to the user-specified option list.3
5.4 Table Formatting
91
Table 5.17 Options for add_table_cell( )
key
explanation
fittextflow
(Option list; only relevant for Textflows) Option list for fit_textflow( ). This option list will be applied to
place the Textflow supplied in the textflow option in the cell. The inner cell box will be used as fitbox.
Default: verticalalign=center lastlinedist=descender. This option list will be prepended to the
user-specified option list.
fittextline
(Option list; only relevant for textlines) Option list for fit_textline( ). This option list will be applied to fit
the supplied text into the cell. The lower left corner of the inner cell box will be used as the reference
point. Options which have not been specified will be replaced with the respective defaults; the current
text state is not taken into account.
Default: boxsize={<width> <height>} fitmethod=nofit position=center, where <width> and
<height> are the calculated width and height of the inner cell box. This calculated option list will be
prepended to the supplied option list.3
image
(Image handle) The image associated with the handle will be placed in the inner cell box.
margin
marginleft
marginbottom
marginright
margintop
(Float or percentage) Left/bottom/right/top cell margins in user coordinates (must be greater than or
equal to 0) or as a percentage of the cell width or height (must be less than 100%). The specified margins
define the inner cell box which serves as the fitbox for the cell contents. Default for margin: 0; Default
for all others: margin
matchbox
(Option list) Option list with matchbox details according to Table 6.3.
minrowheight1
(Float or percentage) If a row cannot completely be placed in a table instance, this option specifies
whether the row can be split and how small the fragments can get. The minimum fragment height can
be specified in user coordinates or as a percentage of the row height. Default: 100%, i.e. no splitting
path
(Path handle) The path object within its bounding box will be placed in the inner cell box according to
the fitpath option.
pdipage
(Page handle) The imported PDF page associated with the handle will be placed in the inner cell box. Default: none
repeatcontent
(Boolean) Specify whether the contents of a table cell will be displayed repeatedly if a cell or row is split
between several table instances. Default: true
Splitting a cell: If the last rows spanned by a cell don’t fit into the fitbox, the cell will be split. Except for
Textflows (which will not be repeated), the cell contents will be repeated in the next table instance if
repeatcontent=true. Otherwise it will not be repeated.
Splitting a row: If the last body row doesn’t fit into the fitbox, it will usually not be split but will completely be placed in the next table instance. You can decrease the minrowheight value to split the last
body row with the given percentage of contents in the first instance, and place the remaining parts of
that row in the next instance. Except for Textflows (which will not be repeated), the cell contents will be
repeated in the next table instance if repeatcontent=true. Otherwise it will not be repeated.
return1
(String) fit_table( ) will stop after placing the specified row, and will return the specified string. The string
must not start with an underscore character ’_’ . If the specified row is part of a join group it must be the
last row of the group; otherwise an error will occur.
rowheight1
(Float or percentage) Height of the row specified in the row parameter. The height can be specified in user
coordinates2, or as a percentage of the height of the table’s first fitbox (see fit_table( )). User coordinates
and percentages must not be mixed, i.e. either user coordinates or percentages must be used in all row
height definitions of a table. The row height may be increased automatically if the row traverses cells
containing text. Images and PDF pages in table cells don’t have any influence on row heights. Default:
see option rowheightdefault of fit_table( )
rowscalegroup1
(String) Name of a row group to which the row will be added. All rows in a group will be scaled uniformly
if one of the rows in the group must be enlarged to completely hold long text. If a cell spans multiple
rows the affected rows form a scale group automatically.
92
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.17 Options for add_table_cell( )
key
explanation
rowjoingroup1
(String) Name of a row group to which the row will be added. All rows in the group will be kept together
in a table instance. The rows in a group must be numbered consecutively. If a cell spans multiple rows the
affected rows do not automatically form a join group.
rowspan
(Integer) Number of rows spanned by the cell. Default: 1
textflow
(Textflow handle) The Textflow associated with the handle will be placed in the inner cell box. The
continue option controls the behavior for a Textflow handle which is used in multiple cells. The Textflow
handle must not be used outside the table. Default: no Textflow
1. The last specification of this option is dominant; earlier specifications for the same row or column will be ignored.
2. More precisely, the coordinate system which is in effect when fit_table( ) is called for placing the first table instance.
3. The box size will be calculated automatically; the boxsize option in the supplied option list will be ignored.
VB RB Function fit_table(table As Long,
llx As Double, lly As Double, urx As Double, ury As Double, optlist As String) As String
C# String fit_table(int table, double llx, double lly, double urx, double ury, String optlist)
Fully or partially place a table on the page.
table
A valid table handle retrieved with a call to add_table_cell( ).
llx, lly, urx, ury Coordinates of the lower left and upper right corners of the target rectangle for the table instance (the fitbox) in user coordinates. The corners can also be
specified in reverse order.
optlist An option list specifying filling details according to Table 5.18. The following
options can be used:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Fitting options according to Table 6.1: fitmethod, position, showborder
> General table options: blind, colwidthdefault, horshrinklimit, rewind, rowheightdefault,
vertshrinklimit
> Table contents: header, footer
> Table decoration: fill, firstdraw, gstate, stroke
> Visualization aids for development and debugging: debugshow, showcells, showgrid
Returns A string which specifies the reason for returning from the function:
> _stop: all rows in the table have been processed.
> _boxfull: there are still rows to be placed, but not enough space is available in the table’s fitbox; another call to fit_table( ) is required for processing the remaining rows.
> _error: an error occurred; call get_errmsg( ) to obtain details about the problem.
> Any other string: the string supplied to the return option in a call to add_table_cell( ).
The error behavior can be changed with the errorpolicy parameter or option.
Details Place the table on the page. The table cells must have been filled with prior calls to add_
table_cell( ). If the full table doesn’t fit in the fitbox, the first table instance will be placed;
more table instances can be placed with subsequent calls to this function depending on
the return value. The contents of a table cell will be placed in the following order:
> Filling: the areas specified with the fill option will be filled in the following order:
table, colother, colodd, coleven, col#, collast, rowother, rowodd, roweven, row#, rowlast,
header, footer.
5.4 Table Formatting
93
> Matchbox filling: single cell areas which are defined by a matchbox definition.
> Contents: the specified cell contents will be placed in the following order: image, imported PDF page, Textflow, Textline, path objects, annotations, form fields.
> Matchbox ruling: single cell areas which are defined by a matchbox definition.
> Ruling: the lines specified with the stroke option will be stroked according to the
linecap and linejoin suboptions of the stroke option in the following order: other,
horother, hor#, horlast, vertother, vert#, vertlast, frame (the order of horizontal and vertical lines can be changed with the firstdraw option). Cells which span multiple rows
or columns will not be intersected by strokes. Similarly, lines will not be stroked
around cells with a matchbox which specifies border decoration (unless the matchbox uses the inner cell box). The table border lines vert0, hor0, vertN, and horN will be
suppressed if frame is specified.
> Named matchboxes: these can be filled with other elements like annotations, form
fields, images etc. outside of the table functions.
Scope page, pattern, template, glyph
Table 5.18 Options for fit_table( )
key
explanation
blind
(Boolean) If true, all calculations will be performed, but no output will be created. The formatting results
can be checked with info_table( ). Default: false
colwidthdefault
(Float or keyword; only relevant in the first call to fit_table( ) for a particular table) Default width for columns for which the colwidth option of add_table_cell( ) was not specified. The default width can be
specified as an absolute value or as a keyword (default: auto):
auto
The width of the fitbox will be distributed equally to all columns for which no width was
specified. As a result, the table covers the full width of the fitbox.
In order to create columns with minimal width you can supply a small value (e.g. 0.1). The width of all
columns which contain Textline or Textflow cells will be adjusted automatically (see PDFlib Tutorial).
debugshow
94
(Boolean) If true, all errors for tables which are too high, too wide, or where the cells get too small will be
suppressed and logged instead. The resulting table instance will be created as a debugging aid although
the table is damaged. Default: false
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.18 Options for fit_table( )
key
explanation
fill
(List of option lists) This option can be used to fill rows or columns with color (the matchbox option can be
used to fill single cells with color, see Section 6.2, »Matchboxes«, page 105):
area
(Keyword) Table area(s) to be filled:
col#
column number # in the table
collast
last column
coleven
all columns with even numbers (according to col in add_table_cell( ))
colodd
all columns with odd numbers
colother all unspecified columns
row#
row number # in the table
rowlast
last body row in the table instance
roweven all rows with even numbers (according to row in add_table_cell( ))
rowodd all rows with odd numbers
header
all rows in the header group
footer
all rows in the footer group
rowother all unspecified body rows
table
complete table area (i.e. all rows in the table)
The following graphics appearance options according to Table 7.2 can also be used:
fillcolor, shading
Examples:
fill all rows in the table with red: fill = { {area=table fillcolor={rgb 1 0 0}} }
fill odd-numbered rows with green and even-numbered rows with red:
fill = { {area=rowodd fillcolor={rgb 0 1 0}} {area=roweven fillcolor={rgb 1 0 0}} }
firstdraw
(Keyword) Specifies the order in which horizontal and vertical lines will be created (default: vertlines):
horlines
Horizontal lines will be created first.
vertlines
Vertical lines will be created first.
footer
(Integer) Number of final (footer) rows in the table definition which will be repeated at the bottom of the
table instance. Default: 0 (no footer rows)
gstate
(Gstate handle) Handle for a graphics state retrieved with create_gstate( ). All table decorations will be
subject to the supplied graphics state. The cell contents will not be affected. Default: no gstate (i.e. current settings will be used).
header
(Integer) Number of initial (header) rows in the table definition which will be repeated at the top of the
table instance. Default: 0 (no header rows)
horshrinklimit
(Float or percentage) Lower limit for the horizontal shrinking factor which will be used when the table is
shrunk to fit in the table’s fitbox (if a percentage is supplied) or the absolute difference between the table
width and the width of the fitbox (if a float is supplied). Default: 50%
rewind
(Integer: -1, 0, or 1) State of the table is reset to the state before some other call to fit_table( ). Currently
the following values are supported (default: 0):
rowheightdefault
1
Rewind to the state before the first call to fit_table( ).
0
Don’t reset the table.
-1
Rewind to the state before the last call to fit_table( ) (the one before the current call)
(Float or keyword; only relevant in the first call to fit_table( ) for a particular table) Default height for
rows for which the rowheight option of add_table_cell( ) was not specified. The default height can be
specified as an absolute value or as a keyword (default: auto):
auto
The height of the fitbox will be distributed equally to all rows for which no height was
specified. As a result, the table covers the full height of the fitbox.
In order to create rows with minimal height you can supply a small value (e.g. 0.1). The height of all rows
which contain Textline or Textflow cells will be adjusted automatically (see PDFlib Tutorial).
5.4 Table Formatting
95
Table 5.18 Options for fit_table( )
key
explanation
showcells
(Boolean) If true, the border of each inner cell box will be stroked using the current graphics state. Default: false
showgrid
(Boolean) If true, the vertical and horizontal boundary of all columns and rows will be stroked. Default:
false
stroke
(List of option lists) This option can be used to create stroked lines at the cell borders:
line
(Keyword) Table line(s) to be stroked:
vert#
vertical line at the right border of column number #; vert0 is the left table border
vertfirst first vertical line (equivalent to vert0)
vertlast
last vertical line
vertother all unspecified vertical lines
hor#
horizontal line at the bottom of row number # in the table; row0 is the top border
horfirst
first horizontal line in the table instance
horother all unspecified horizontal lines
horlast
last horizontal line in the table instance
frame
outer border of the table
other
all unspecified lines
The following graphics appearance options according to Table 7.2 can also be used:
dasharray, dashphase, linecap, linejoin, linewidth, strokecolor
Examples:
stroke all lines with black and linewidth 1: stroke = {line=other}
stroke the outer border lines with linewidth 0.5: stroke = { {line=frame linewidth=0.5} }
stroke the outer border lines with linewidth 0.5, and all other lines with linewidth 0.1:
stroke = { {line=frame linewidth=0.5} {line=other linewidth=0.1} }
vertshrinklimit
(Float or percentage) The lower limit for the vertical shrinking factor which will be used when the table is
shrunk to fit the table’s fitbox (if a percentage is supplied) or the absolute difference between the height
of the table instance and the height of the fitbox (if a float is supplied). Default: 90%
VB RB Function info_table(table As Long, keyword As String) As Double
C# double info_table(int table, String keyword)
Retrieve table information related to the most recently placed table instance.
table A valid table handle retrieved with a call to add_table_cell( ). The table handle
must already have been used in at least one call to fit_table( ) since the returned values
are meaningful only after placing a table instance on the page.
keyword
A keyword specifying the requested information according to Table 5.19.
Returns The value of some table parameter as requested by keyword. This function returns correct geometry information even in blind mode.
Scope any except object
Table 5.19 Keywords for info_table( )
keyword
explanation
boundingbox
Handle of the path containing the table instance’s bounding box in user coordinates or -1
firstbodyrow Number of the first body row in the most recently placed table instance
height
96
Height of the table instance
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
Table 5.19 Keywords for info_table( )
keyword
explanation
horboxgap
Difference between the width of the table instance and the width of the fitbox. If the table had to be
shrunk the value will specify the deviation from the width of the fitbox (i.e. a negative value).
horshrinking Horizontal shrinking factor as a percentage of the calculated table width. If the table had to be shrunk
horizontally the value will specify the shrinking percentage, otherwise it will be 100.
lastbodyrow
Number of the last body row in the most recently placed table instance
returnreason String index of the return reason
rowcount
Number of rows in the most recently placed table instance (including headers and footers)
rowsplit
1 if the last row had to be split, 0 otherwise
vertboxgap
Difference between the height of the most recently generated table instance and the height of the fitbox. If the table had to be shrunk, the value will specify the deviation from the height of the fitbox (i.e. a
negative value).
vertshrinking
Vertical shrinking factor as a percentage of the calculated table height. If the table had to be shrunk vertically the value will specify the shrinking percentage, otherwise it will be 100.
width
Width of the table instance
x1, y1, ... ,
x4, y4
Coordinates of the corners of the table instance in user coordinates, counterclockwise starting at the
lower left corner
xvertline#
x coordinate of the vertical line with number #. xvertline0 is the left table border.
yhorline#
x coordinate of the horizontal line with number #. yhorline0 is the top table border.
VB RB Sub delete_table(table As Long, optlist As String)
C# void delete_table(int table, String optlist)
Delete a table and all associated data structures.
table
optlist
A valid table handle retrieved with a call to add_table_cell( ).
An option list specifying cleanup options according to Table 5.20.
Details Tables which have not been deleted with this function will be deleted automatically at
the end of the enclosing document scope.
Scope any
Table 5.20 Options for delete_table( )
key
explanation
keephandles
(Boolean) If false, all handles supplied to the textflow, image, and pdipage options of add_table_cell( )
will automatically be deleted. Default: false
5.4 Table Formatting
97
98
Chapter 5: Text and Table Formatting (Edition for COM, .NET, and REALbasic)
6 Object Fitting and Matchboxes
6.1 Object Fitting
PDFlib’s fitting algorithm places a rectangular graphical object relative to a point, a horizontal or vertical line, or a rectangle. The fitting algorithm is implemented in several
functions:
> fit_textline( ), info_textline( )
> fit_image( ), info_image( )
> fit_pdi_page( ), info_pdi_page( )
> draw_path( ), info_path( )
> add_table_cell( ) (via option lists for the fittextline, fitimage, fitpdipage, fitpath options)
> fit_table( )
> fill_*block( )
Note Since the fitting options for Textflow are slightly different they are not described here, but in
Section 5.3, »Multi-Line Text with Textflows«, page 75.
Table 6.1 lists fitting options which can be supplied to the fitting functions. Not all options are available for all functions, and the behavior of some options may slightly
change depending on the function; see Table 6.1 for details. The following options form
the group of fitting options:
alignchar, boxsize, dpi, fitmethod, margin, matchbox, minfontsize, orientate, position,
refpoint, rotate, scale, showborder, shrinklimit
Object box. In all cases the fitting algorithm calculates the smallest enclosing rectangle of the placed object. This rectangle is called the object box. It can be modified according to the type of object:
> Textlines (fit/info_textline( ), single-line text Blocks, table cells): the default width of
the object box is the width of the text, and the default height of the text box is the
capheight of the selected font. This can be changed with the boxheight suboption of
the matchbox option.
> Images and templates (fit/info_image( ), image Blocks, table cells): the suboption
clipping of the matchbox option can be used to define some part of the object as object box. For TIFF and JPEG images with a clipping path the smallest enclosing rectangle with edges parallel to the coordinate axes will be used as object box if the suboption innerbox of the matchbox option is set.
> Imported PDF pages (fit/info_pdi_page( ), PDF Blocks, table cells): the suboption
clipping of the matchbox option can be used to define some part of the object as object box.
> Path objects (draw/info_path( ), table cells): the smallest rectangle with edges parallel
to the coordinate axes which encloses the path will be used as object box. The object
box will only be calculated if the boxsize and position options have values different
from zero.
> Table instances (fit_table( )): the smallest rectangle with edges parallel to the coordinate axes which encloses the table instance will be used as object box.
6.1 Object Fitting
99
Reference point. The reference point is used as an anchor for placing the object box. It is
defined as follows:
> In fit_*( ) and draw_path( ): the x and y function parameters;
> In info_*( ): the point (0, 0); info_path( ) additionally supports the refpoint option for
specifying the reference point.
> add_table_cell( )fit_table( ), and fill_*block( ): the lower left corner of the table cell, table
instance, or PDFlib Block; fill_*block( ) additionally supports the refpoint option for
specifying the reference point.
Fitbox and reference line segment. The rectangle in which the object box will be
placed is called the fitbox. It has the reference point (x, y) as its lower left corner and its
size is specified by the two values of the boxsize option:
lower left corner = (x, y)
upper right corner = x + boxsize[0], y + boxsize[1]
upper right corner = x + boxsize[0], y - boxsize[1]
(if topdown=false)
(if topdown=true)
In addition to the definition above the fitbox can be modified as follows:
> Textlines: the fitbox can be reduced with the margin option;
> table cells: the fitbox is defined by the inner cell box, i.e. the cell box as modified by
the margin* options;
> table instances: the fitbox is defined by the llx/lly/ury/ury parameters;
> PDFlib Blocks: the fitbox is by default defined by the Block’s Rect property, but it can
be modified with the refpoint and/or boxsize options.
In the last three cases above the fitbox is always available; otherwise it is only available
if the boxsize option was specified with two values different from zero.
If boxsize[0]=0 the box degenerates to a vertical line. The fitting algorithm will place
the object box relative to this line segment. Similarly, if boxsize[1]=0 the box will be
placed relative to the resulting horizontal line segment. The vertical or horizontal line
segment is called the reference line segment.
Placing the object box. The object box can be placed in different ways:
> If no fitbox is available the object will be placed relative to the reference point (not
for table cells, table instances, and PDFlib Blocks): the lower left corner of the object
box will coincide with the reference point. Using the position option other points
within the object box can be selected. For example, position=center places the object
box’s center point at the reference point.
The option scale will be honored for images, templates, path objects, and imported
PDF pages; the option dpi will be honored for images. The fitmethod option will be ignored in this case.
Path objects: if position={0 0} the bounding box will not be calculated and the origin
of the path object will coincide with the reference point.
> Relative to a reference line segment (not for table cells, table instances, and PDFlib
Blocks): this works similarly to placing an object relative to the reference point as described above. In addition, the position option also defines a point on the line segment which will serve as reference point.
> Relative to the fitbox: The fitmethod option specifies whether and how the object box
will be forced to fit into the fit box. If fitmethod=nofit nothing will be done to restrict
the result to the fitbox. Other values of fitmethod define details of the fitting algo-
100
Chapter 6: Object Fitting and Matchboxes (Edition for COM, .NET, and REALbasic)
rithm according to Table 6.2.
In this case the options scale and dpi will be ignored, and the options margin,
shrinklimit, and showborder will be honored.
The lower left corner of the object box will coincide with the lower left corner of the
fitbox. Using the position option other points within the object box and simultaneously the corresponding point within the fitbox can be selected. For example,
position=center places the object box’s center point at the center point of the fitbox.
Table 6.1 Fitting options for various functions
option
explanation
align
(List of two floats; only for path objects) The coordinates of a direction vector in user coordinates which
defines the rotation of the path object. The x direction of the path object’s coordinate system will be
aligned with the specified vector. The coordinates must not both be 0. The calculated rotation will be
added to the rotation defined by the orientate option. Default: {1 0}, i.e. no additional rotation
alignchar
(Unichar or keyword; only for Textlines) If the specified character is found in the text, its lower left corner
will be aligned at the reference point. For horizontal text with orientate=north or south the first value
supplied in the position option defines the position. For horizontal text with orientate=west or east
the second value supplied in the position option defines the position.
If this option is present the formatted text may exceed beyond the fitbox. This option will be ignored if
the specified alignment character is not present in the text. If the specified character cannot be found in
the font or encoding, an exception will be thrown if glyphcheck=error. For other values of glyphcheck
the alignchar option will silently be ignored if the character is not available.
The value 0 and the keyword none suppress alignment characters. The specified fitmethod will be applied, although the text cannot be placed within the fitbox because of the forced positioning of
alignchar. Default: none
attachmentpoint
(String; only for path objects) Name of the attachment point: If fitmethod=nofit the path object will be
placed so that the specified attachment point coincides with the reference point. Default: origin of the
path object
blind
(Boolean) If true, no output will be generated, but all calculations will be performed and the formatting
results can be checked with the appropriate info function info_*( ). Default: false
boxsize
(List of floats; not for tables) Width and height of the fitbox, relative to which the object (possibly rotated
according to the rotate option) will be placed. The lower left corner of the fitbox coincides with the reference point (x, y). Placing the object is controlled by the position and fitmethod options. If width=0,
only the height is considered; If height=0, only the width is considered. In these cases the fitmethod option will be ignored and the object will be placed relative to the vertical line from (x, y) to (x,
y+height) (or (x, y-height) for topdown systems), or the horizontal line from (x, y) to (x+width, y),
according to the position option.
Default for Blocks: width and height of the Block’s Rect property
Default for all other fitting functions: {0 0}
dpi
(List of floats; only for images) One or two values specifying the desired image resolution in pixels per
inch in horizontal and vertical direction. This option does not change the number of pixels in the image
(downsampling). If a single value is supplied it will be used for both dimensions. With the value zero the
image’s internal resolution will be used if available, or 72 dpi otherwise. The keyword internal is equivalent to zero. The scaling resulting from this option is relative to the current user coordinate system; if the
coordinate system has been scaled the resulting physical resolution will be different from the supplied
values. The scale option will be applied in addition to the dpi values.
This option will be ignored if the fitmethod option has been supplied with one of the keywords auto,
meet, slice, or entire. Default: internal
fitmethod
(Keyword) Method used to fit the object into the specified fitbox. See Table 6.2 for supported keywords.
Keywords other than nofit will be ignored if no fitbox has been specified.
Default: clip for Textflow, meet for tables and path objects, and nofit otherwise
6.1 Object Fitting
101
Table 6.1 Fitting options for various functions
option
explanation
margin
(List of floats; only for Textlines) One or two float values describing additional horizontal and vertical reductions of the fitbox. Default: 0
matchbox
(Option list; not for path objects) Option list for creating a matchbox according to Table 6.3
minfontsize
(Float or percentage; only for Textlines) Minimum allowed font size when text is scaled down to fit into
the fitbox with fitmethod=auto when shrinklimit is exceeded. The limit is specified in user coordinates
or as a percentage of the height of the fitbox. If the limit is reached the text will be created with the specified minfontsize as fontsize. Default: 0.1%
orientate
(Keyword or float; not for tables) Specifies the desired orientation of the object relative to the current coordinate system. Default: north.
Arbitrary rotation angles (in degrees) can be specified for path objects, but not other object types. The
bounding box of the path object will be calculated after rotating the path object. All functions support
the following keywords (corresponding equivalent angles are shown in parentheses):
position
north
upright (0)
east
pointing to the right (270)
south
upside down (180)
west
pointing to the left (90)
(List of floats or keywords) One or two values specifying the position of the object box relative to the reference point, the reference line segment, or the fitbox. The values specify a position within the object
box. This position is defined horizontally as percentage of the box width (first value) and vertically as percentage of the box height (second value). This specified position coincides with the reference point, a
point on the reference line segment or a point within the fitbox. Although the values designate percentages, they must be specified without any percent sign. Negative values are allowed. If both values are
equal, it is sufficient to specify a single value. Default: generally {0 0}, but {0 100} for tables
Examples:
{0 0}
The lower left corner of the object box coincides with the reference point, the start of the
reference line segment, or the lower left corner of the fitbox.
{100 100} The upper right corner of the object box coincides with the reference point, the end of the
reference line segment, or the upper right corner of the fitbox.
The keywords left, center, right (in x direction) or bottom, center, top (in y direction) can be used as
equivalents for the values 0, 50, and 100. If only one keyword has been specified, the corresponding keyword for the other direction will be added. Examples:
{left center}
or {0 50}
left-aligned
{center}
or {50 50}
centered
{right center}
or {100 50}
right-aligned
Only for Textlines: the keyword auto can be used for the first value in the list. It indicates right if the
writing direction of the text is from right to left (e.g. for Arabic and Hebrew text), and left otherwise
(e.g. for Latin text).
refpoint
(List of floats; only for fill_*block( ) and info_path( )) Specifies the reference point in user coordinates for
fitting the block contents or path.
Default for fill_*block( ): lower left corner of the rectangle defined by the Block’s Rect property
Default for info_path( ): {0 0}
rotate
102
(Float; not for tables, table cells, path objects) Rotate the coordinate system, using the reference point as
center and the specified value as rotation angle in degrees. This results in the fitbox and the object being
rotated. The rotation will be reset when the object has been placed. Default: 0
Chapter 6: Object Fitting and Matchboxes (Edition for COM, .NET, and REALbasic)
Table 6.1 Fitting options for various functions
option
explanation
scale
(List of floats; only for images, templates, imported PDF pages, path objects) Scales the object in horizontal and vertical direction by the specified scaling factors (not percentages), using the reference point as
center. If both factors are equal it is sufficient to specify a single value. This option will be ignored if the
fitmethod option has been supplied with one of the keywords auto, meet, slice, or entire. Default:
{1 1}
showborder
(Boolean) If true, the border of the fitbox will be stroked using the current graphics state. If a stamp is
created, the bounding box of the stamp will also be stroked. This may be useful for development and debugging. Default: false
shrinklimit
(Float or percentage; only for Textlines) The lower limit of the shrinkage factor which will be applied to fit
text with fitmethod=auto. Default: 0.75
6.1 Object Fitting
103
Table 6.2 Keywords for the fitmethod option of various functions; the illustrations demonstrate the typical effect of each
keyword on a Textline, using the same value for the fontsize option in all examples.
keyword
explanation
auto
(Only for Textlines; other object types: same behavior as meet) This method tries to fit the text box into the fitbox automatically.
Kraxi Systems
In detail: Same as nofit if the text fits into the fitbox. Otherwise a scaling
factor is calculated such that the text will be shrunk horizontally (distorted) to fit into the fitbox. If the calculated factor is smaller than the
shrinklimit option, the meet method is applied by reducing the fontsize
until the text can be fit or the value of minfontsize is reached.
Kraxi Systems
Kraxi Systems
clip
Position the object and graphically clip it at the edges of the fitbox.
fit_table( ): the calculated table box will be logically clipped at the bottom edge of the fitbox and can be continued in the next fitbox. Logical
clipping is similar to fit_textflow( ), but not graphical clipping as in fit_
image( ) etc. The table box will be placed inside the fitbox according to
the position option.
entire
Kraxi Sys
Scale the object box such that it entirely covers the fitbox. Generally this
method will distort the object. The position option doesn’t have any effect.
Kraxi Systems
fit_table( ): similar to clip. If the table box is smaller than the fitbox, the cells of the table box (but not
their contents) will be enlarged uniformly until the table box entirely covers the fitbox.
meet
Position the object according to the position option, and scale it such
that it entirely fits into the fitbox while preserving its aspect ratio. Generally at least two edges of the object box will meet the corresponding
edges of the fitbox.
Kraxi Systems
fit_table( ): similar to clip. If the table box is smaller than the fitbox, the
cells of the table box (but not their contents) will be enlarged uniformly until the horizontal or vertical
table edge meets the fitbox.
nofit
Position the object only. The scale and dpi will be applied to images.
fit_table( ): The table will be calculated for a virtual fitbox with infinite
height. The table box will be placed inside the fitbox according to the
position option. The default sizes of columns and rows relate to the
specified fitbox height. fitmethod=nofit is recommended to format the
table in blind mode.
slice
Position the object according to the position option, and scale it such
that it entirely covers the fitbox, while preserving the aspect ratio and
making sure that at least one dimension of the object is fully contained in
the fitbox. Generally parts of the object’s other dimension will extend beyond the fitbox, and will therefore be clipped.
Kraxi Systems
Kraxi S
fit_table( ): similar to clip. If the table box is smaller than the fitbox the cells of the table box (but not
their contents) will be enlarged uniformly until the fitbox is entirely covered by the table box while preserving its aspect ratio. The table box will be placed inside the fitbox according to the position option. The parts of the table box which exceed
beyond the fitbox will be clipped graphically at the edges of the fitbox.
104
Chapter 6: Object Fitting and Matchboxes (Edition for COM, .NET, and REALbasic)
6.2 Matchboxes
Matchboxes are not defined with a dedicated function, but with the matchbox option in
the function call which creates the actual element:
> Textlines: fit_textline( ), fill_textblock( ) with textflow=false
> Textflows: add/create_textflow( ), fill_textblock( ) with textflow=true
> imported PDF pages: fit_pdi_page( ), fill_pdf_block( )
> images and templates: fit_image( ), fill_image_block( )
> table cells: add_table_cell( )
Matchboxes are defined with the matchbox option of these functions. It expects an option list which supports the following suboptions:
> Graphics appearance options according to Table 7.2:
borderwidth, dasharray, dashphase, fillcolor, gstate, linecap, linejoin, shading, strokecolor
> Matchbox controlling options according to Table 6.3
Details of the rectangle(s) corresponding to a matchbox can be queried with info_
matchbox( ).
Table 6.3 Suboptions for the matchbox option of various functions
option
explanation
boxheight
(List with two elements, each being a positive float or a keyword; only for Textline and Textflow) Vertical
extent of the text box. Two values can be specified numerically or via keywords for the extent above and
below the baseline:
none (no extent), xheight, descender, capheight, ascender, fontsize, leading, textrise
With Textflows the values corresponding to the text at the beginning of the matchbox will be used.
Default: {capheight none}
boxwidth
(Float or percentage; only for Textflow) Width of the matchbox specified in user coordinates or as a percentage of the box height. If this option is supplied, horizontal space of the specified width will be inserted between the matchbox option and the next text fragment or the matchbox end specification. This may
be useful to reserve space for inserting an image, template, or PDF page in the Textflow. Default: 0
clipping
(Rectangle or 4 percentages; only for images and imported PDF pages; will be ignored if the innerbox option has been specified) Coordinates of the lower left and upper right corner of a rectangle within the image or page specifying which part should be displayed. With images, the clipping rectangle can be specified in pixels or as a percentage of the width/height. With PDF pages, the clipping rectangle can be
specified in default units or as a percentage of the width/height of the page’s crop box. Default: {0% 0%
100% 100%}
createwrapbox
(Boolean; only for Textflow) If true, the rectangle(s) comprising the matchbox will be inserted as wrap
areas in the Textflow after they have been calculated. The subsequent lines after the lines containing the
matchbox will be wrapped around the rectangle(s). Default: false
doubleadapt If true the start and end point of the second line will be adapted to the first line. Otherwise the second
line will be shorter or longer by the amount of doubleoffset. Default: true
doubleoffset
(Float) If different from 0 the lines around the border of the inner matchbox rectangle will be doubled.
The second line has the specified offset from the original line. If the offset is positive the line will be
drawn outside the matchbox rectangle, and inside if the offset is negative. Default: 0 (i.e. single line)
(Boolean) If true, the corresponding border of the rectangle will be drawn provided that the
drawleft
drawbottom borderwidth is set to a value greater than 0. Default: true
drawright
drawtop
6.2 Matchboxes
105
Table 6.3 Suboptions for the matchbox option of various functions
option
explanation
end
(Boolean; only for Textflow) Specifies the end of the matchbox. If true, all other suboptions for the current matchbox definition will be ignored. Matchboxes in Textflows cannot be nested. The width of a Textflow matchbox is defined by the option boxwidth (if specified) and the extent of the text enclosed in the
options matchbox and matchbox= end. If the end option has not been specified, the matchbox will end after the last character in the Textflow.
exceedlimit
(Float or percentage; only for Textflow) Upper limit for the part of the matchbox which is allowed to exceed beyond the bottom or right edge of the fitbox, specified in user coordinates or as a percentage of
the matchbox height. If the specified limit would be exceeded fit_textflow( ) will return _boxfull; the
remaining text and the matchbox can be continued in the next fitbox. Default: 0, i.e. the matchbox must
completely fit into the box.
innerbox
(Boolean; only for table cells, and TIFF and JPEG images) Table cells: If true, the cell box will be reduced by
the margins defined for the cell; otherwise the full cell box will be used.
TIFF and JPEG images: If true and the image contains a clipping path the bounding box of the clipping
path will be used instead of the full image.
Default: false
margin
(Float or percentage) Additional margin for the matchbox rectangle, specified in user coordinates (must
be greater than or equal to 0) or as a percentage of the rectangle width or height (must be less than
100%). This option will be ignored for an edge for which offset* has been supplied. Default: 0
name
(Name string) Name of the matchbox. If the name has already been assigned to a matchbox, another
rectangle for this name will be created. This means that a matchbox may consist of more than one rectangle. The name can be used in info_matchbox( ). Various functions support the option usematchbox to
reference one or more rectangles of a matchbox, e.g. to add an annotation with create_annotation( ).
Matchbox names can be used until the end of the current page. Default: no name
offsetleft
offsetbottom
offsetright
offsettop
(Float or percentage) User-defined offset from the left/right/bottom/top edge of the calculated rectangle and the desired box. The values are specified in user coordinates or as a percentage of the rectangle’s
width (for offsetleft/offsetright) or height (for offsetbottom/offsettop). Negative values are allowed, and can be used to extend the matchbox. Default of offsetleft/offsetbottom: margin; Default of offsetright/offsettop: -margin
openrect
(Boolean; only for Textflow and table cells) Textflow: If true and a matchbox rectangle is split to the next
line, the right border of the first rectangle and the left border of the second rectangle will not be drawn.
Table cells: If true and a table row is split to the next table instance the bottom border of the first part
and the top border of the second part will not be drawn. Default: false
round
(Float) Adjacent lines of a matchbox rectangle will be joined with a circular arc with the specified radius
and the line segments as tangents. If the specified radius is negative the arc segments will be swept inwards, and the tangents will be perpendicular to the line segments of the box. Default: 0 (no rounding)
VB RB Function info_matchbox(boxname As String, num As Long, keyword As String) As Double
C# double info_matchbox(String boxname, int num, String keyword)
Query information about a matchbox on the current page.
boxname (Name string) Name of the matchbox. The name must have been defined
with the name suboption of the matchbox option when the matchbox was defined.
Alternatively, the name ’*’ (single asterisk character) can be used to enumerate all
matchboxes on the page.
106
Chapter 6: Object Fitting and Matchboxes (Edition for COM, .NET, and REALbasic)
num Number of the requested matchbox rectangle (the first has number 1). See Table
6.4 for the special case num=0.
keyword
A keyword specifying the requested information according to Table 6.4.
Returns The value of some matchbox parameter as requested by keyword. If a matchbox with the
specified name or a matchbox rectangle with the specified number does not exist on
the current page, all keywords will return the value 0.
Details Named matchboxes within a Textflow can only be queried after calling fit_textflow( ).
Scope page, pattern, template, glyph, path, font
Table 6.4 Keywords for info_matchbox( )
keyword
explanation
count
(The num parameter will be ignored)
If boxname contains the name of a matchbox: Number of rectangles for this matchbox on the page
If boxname=*: number of matchboxes with at least one rectangle on the page
exists
If boxname contains the name of a matchbox: 1 if the rectangle exists, 0 otherwise.
With boxname=* this keyword can be used to enumerate all matchboxes on the page:
if num=0: 1 if a matchbox exists at all, 0 otherwise
otherwise: 1 if a matchbox with number num exists
height
1
name
String index for the name of the matchbox with number num. The corresponding string can be retrieved
via get_parameter( ) and the string parameter (see Table 2.3).
rectangle
width
Height of the rectangle in user coordinates
1
x1, y1, ... ,
x4, y41
Handle of the path containing the num-th rectangle in user coordinates or -1
Width of the rectangle in user coordinates
Position of the i-th rectangle corner (i=1, 2, 3, 4) in user coordinates. In the coordinate system of the respective fit element (image, text, etc.), x1, y1 correspond to the lower left, x2, y2 to the lower right, x3,
y3 to the upper right and x4, y4 to the upper left corner.
1. This keyword will be ignored if boxname=*
6.2 Matchboxes
107
108
Chapter 6: Object Fitting and Matchboxes (Edition for COM, .NET, and REALbasic)
7 Graphics Functions
Cookbook A full code sample can be found in the Cookbook topic graphics/starter_graphics.
7.1 Graphics Appearance Parameters and Options
Table 7.1 lists relevant parameter key names for this section (see Section 2.2, »Parameter
and Option Handling«, page 18).
Table 7.1 Path-related keys for get/set_parameter( )
key
explanation
fillrule
Set the current fill rule to winding or evenodd (see Table 7.2). Scope: page, pattern, template, glyph
Table 7.2 lists graphics appearance options for create_gstate( ), draw_path( ), shading_
pattern( ), the fill and stroke options of fit_table( ), and the matchbox option of various
functions.
Table 7.2 Graphics appearance options
option
explanation and possible values
borderwidth
(Float; only for matchboxes) Line width for the rectangle’s border. If you set borderwidth to a
value greater than 0 all rectangle borders will be stroked. To prevent the upper, lower, left, or
right border from being stroked, set the corresponding drawtop, drawbottom, drawleft, or
drawright option to false. Default: 0
dasharray
(List of floats) List of 2-8 alternating values for the lengths of dashes and gaps for stroked paths
(measured in the user coordinate system). The array values must be greater than zero. They will
be cyclically reused until the complete path is stroked.
dashphase
(Float) Distance into the dash pattern at which to start the dash. Default: 0
fillcolor
(Color) Fill color of the area. Default: generally {gray 0} (in PDF/A mode: {lab 0 0 0}), but none
for tables and matchboxes
fillrule
(Keyword) Fill rule which determines the interior of areas for filling and clipping (default:
winding):
winding
Use the nonzero winding number rule.
For simple shapes, the result of filling
matches intuitive expectations. For
shapes consisting of multiple paths the
direction of the paths is relevant.
evenodd
Use the even-odd rule, which yields the
same results as winding for simple
shapes, but produces different results
for more complex shapes, especially
self-intersecting paths.
flatness
(Float > 0) A positive number which describes the maximum distance (in device pixels) between a
circular arc or a curve and an approximation constructed from straight line segments. Default: 1
gstate
(Gstate handle) Handle for a graphics state retrieved with create_gstate( ). Default: no graphics
state (i.e. current settings will be used)
7.1 Graphics Appearance Parameters and Options
109
Table 7.2 Graphics appearance options
option
explanation and possible values
linecap
(Integer or keyword) Shape at the end of a path (default: butt):
butt
(Equivalent value: 0) Butt end caps: the stroke is squared off
at the endpoint of the path.
round
(Equivalent value: 1) Round end caps: a semicircular arc
with a diameter equal to the line width is drawn around
the endpoint and filled in.
projecting (Equivalent value: 2) Projecting square end caps: the stroke
extends beyond the end of the line by a distance which is
half the line width and is squared off.
linejoin
(Integer or keyword) Shape at the corners of paths (default: miter):
miter
(Equivalent value: 0) Miter joins: the outer edges of the strokes for the
two segments are continued until they meet. If the extension projects
too far, as determined by the miter limit, a bevel join is used instead.
round
(Equivalent value: 1) Round joins: a circular arc with a diameter equal to
the line width is drawn around the point where the segments meet and
filled in, producing a rounded corner.
bevel
(Equivalent value: 2) Bevel joins: the two path segments are drawn with
butt end caps (see the discussion of the linecap parameter), and the resulting notch beyond the ends of the segments is filled in with a triangle.
linewidth
(Float > 0) Line width. Default: 1
miterlimit
(Float >= 1) Controls the spike produced by miter joins (default: 10;
this corresponds to an angle of roughly 11.5 degrees)
If the linejoin style is set to 0 (miter join), two line segments joining
at a small angle will result in a sharp spike. This spike will be replaced by a straight end (i.e. the miter join will be changed to a bevel join) when the ratio of the miter length and the linewidth exceeds the miter limit.
Miter
length
Line width
shading
(Option list according to Table 7.3; only for matchboxes and tables) Specify a shading for the
matchbox’s rectangle(s) or table area, using the value of the fillcolor option (if specified) or
the current fill color as the starting color.
strokecolor
(Color) Stroke color of the path. Default: generally {gray 0} (in PDF/A mode: {lab 0 0 0}), but
none for tables and matchboxes
110
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
Table 7.3 Suboptions for the shading graphics appearance option
option
explanation
antialias
(Boolean) Specifies whether to activate antialiasing for the shading. Default: false
domain
(List of 2 Floats) Two numbers specifying the limiting values of a parametric variable t. The variable is
considered to vary linearly between these two values as the color gradient varies between the starting
and ending points of the axis. Default: {0 1}
end
(List of 2 floats or percentages) The x and y coordinates of the end point for the shading axis
(type=axial) or a point on the circle to calculate the radius (type=radial), specified as percentages of
the rectangle’s width and height or in user coordinates. Default: {100% 100%}
endcolor
(Color; required) Color for the end point.
N
(Float) Exponent for the color transition function; must be > 0. Default: 1
start
(List of 2 floats or percentages) The x and y coordinates of the starting point for the shading axis
(type=axial) or the center of the shading circle (type=radial), specified as percentages of the rectangle’s width and height or in user coordinates. Default: {0% 0%}
type
(Keyword) Shading type: axial (linear shading) or radial (radial shading). Default: axial
7.1 Graphics Appearance Parameters and Options
111
7.2 Graphics State
All graphics state parameters are restored to their default values at the beginning of a
page. The default values are documented in the respective function descriptions. Functions related to the text state are listed in Chapter 4, »Font and Text Functions«, page 49.
Note None of the graphics state functions must be used in path scope.
VB RB Sub setdash(b As Double, w As Double)
C# void PDF_setdash(double b, double w)
Set the current dash pattern.
b, w The number of alternating black and white units. b and w must be non-negative
numbers.
Details In order to produce a solid line, set b=w=0. The dash parameter is set to solid at the beginning of each page.
Scope page, pattern, template, glyph
VB RB Sub setdashpattern(optlist As String)
C# void setdashpattern(String optlist)
Set a dash pattern defined by an option list.
optlist Graphics appearance options according to Table 7.2 (an empty list will generate
a solid line): dasharray, dashphase
Details The dash parameter is set to a solid line at the beginning of each page.
Scope page, pattern, template, glyph
VB RB Sub setflat(flatness As Double)
C# void setflat(double flatness)
Set the flatness tolerance.
flatness
The flatness tolerance, see Table 7.2.
Details The flatness tolerance is set to the default value of 1 at the beginning of each page.
Scope page, pattern, template, glyph
VB RB Sub setlinejoin(linejoin As Long)
C# void setlinejoin(int linejoin)
Set the linejoin style.
linejoin Specifies the shape at the corners of paths that are stroked, see Table 7.2. The
linejoin style must be specified as one of the numbers 0, 1, or 2.
Details The linejoin style is set to the default value of 0 at the beginning of each page.
112
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
Scope page, pattern, template, glyph
VB RB Sub setlinecap(linecap As Long)
C# void setlinecap(int linecap)
Set the linecap parameter.
linecap Controls the shape at the end of a path with respect to stroking, see Table 7.2.
The linecap parameter must be specified as one of the numbers 0, 1, or 2.
Details The linecap parameter is set to the default value of 0 at the beginning of each page.
Scope page, pattern, template, glyph
VB RB Sub setmiterlimit(miter As Double)
C# void setmiterlimit(double miter)
Set the miter limit.
miter A value greater than or equal to 1 which controls the spike produced by miter
joins, see Table 7.2.
Details The miter limit is set to the default value of 10 at the beginning of each page. This corresponds to an angle of roughly 11.5 degrees.
Scope page, pattern, template, glyph
VB RB Sub setlinewidth(width As Double)
C# void setlinewidth(double width)
Set the current line width.
width
The linewidth in units of the user coordinate system.
Details The width parameter is set to the default value of 1 at the beginning of each page.
Scope page, pattern, template, glyph
VB RB Sub initgraphics
C# void initgraphics( )
Reset all color and graphics state parameters to their default values
Details The fill and stroke colors, line width, line cap style, line join style, miter limit, dash pattern, and flatness tolerance settings, and the coordinate system (but not the text state
parameters) are reset to their respective default values. The current clipping path is not
affected.
This function may be useful in situations where the program flow doesn’t allow for
easy use of save( )/restore( ).
Scope page, pattern, template, glyph
7.2 Graphics State
113
VB RB Sub save( )
C# void save( )
Save the current graphics state to a stack.
Details The graphics state contains parameters that control all types of graphics objects. Saving
the graphics state is not required by PDF; it is only necessary if the application wishes to
return to some specific graphics state later (e.g. a custom coordinate system) without
setting all relevant parameters explicitly again. The following items are subject to save/
restore:
> graphics parameters which have been set with the corresponding functions: clipping
path, coordinate system, current point, flatness tolerance, line cap style, dash pattern, line join style, line width, miter limit;
> color parameters: fill and stroke colors;
> graphics parameters which have been set with explicit graphics states in set_gstate( );
> text position and the following text-related parameters: charspacing,
decorationabove, fakebold, font, fontsize, horizscaling, italicangle, leading, textrendering,
textrise, underlineposition, underlinewidth, wordspacing.
Pairs of save( ) and restore( ) may be nested. Although the PDF specification doesn’t limit
the nesting level of save/restore pairs, applications must keep the nesting level below
26 in order to avoid printing problems caused by restrictions in the PostScript output
produced by PDF viewers, and to allow for additional save levels required by PDFlib internally.
Scope page, pattern, template, glyph; must always be paired with a matching restore( ) call.
save( ) and restore( ) calls must be balanced on each page, pattern, template, and glyph
description.
Params Most text-related parameters are affected by save/restore; see list above. The following
parameters are not subject to save/restore: fillrule, kerning, underline, overline, strikeout.
VB RB Sub restore( )
C# void restore( )
Restore the most recently saved graphics state from the stack.
Details The corresponding graphics state must have been saved on the same page, pattern, or
template.
Scope page, pattern, template, glyph; must always be paired with a matching save( ) call. save( )
and restore( ) calls must be balanced on each page, pattern, template, and glyph
description.
VB RB Function create_gstate(optlist As String) As Long
C# int create_gstate(String optlist)
Create a graphics state object subject to various options.
optlist
114
An options list with graphics state options:
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
> Graphics appearance options according to Table 7.2:
flatness, linecap, linejoin, linewidth, miterlimit
> Graphics state options according to Table 7.4:
alphaisshape, blendmode, opacitystroke, overprintfill, overprintmode, overprintstroke,
renderingintent, smoothness, softmask, strokeadjust, textknockout
Returns A graphics state handle that can be used in subsequent calls to set_gstate( ) during the
enclosing document scope.
Details The option list may contain any number of graphics state parameters. Not all parameters are allowed for all PDF versions. The table lists the minimum required PDF version.
Scope document, page, pattern, template, glyph
Table 7.4 Options for create_gstate( )
key
explanation and possible values
alphaisshape
(Boolean; PDF 1.4) Sources of alpha are treated as shape (true) or opacity (false). Default:
false
blendmode
(Keyword list; PDF 1.4; if used in PDF/A mode it must have the value Normal) Name of the blend
mode. Multiple blend modes can be specified. Possible values: Color, ColorDodge, ColorBurn,
Darken, Difference, Exclusion, HardLight, Hue, Lighten, Luminosity, Multiply, None, Normal,
Overlay, Saturation, Screen, SoftLight. Default: None
opacityfill
(Float; PDF 1.4; if used in PDF/A mode it must have the value 1) Opacity for fill operations in the
range 0..1. The value 0 means fully transparent; 1 means fully opaque.
opacitystroke
(Float; PDF 1.4; if used in PDF/A mode it must have the value 1) Opacity for stroke operations in
the range 0..1. The value 0 means fully transparent; 1 means fully opaque.
overprintfill
(Boolean) Overprint for operations other than stroke. Default: false
overprintmode
(Integer) Overprint mode. 0 means that each color component replaces previously placed marks;
mode 1 (called »overprinting default is nonzero overprinting« in Acrobat) means that a color
component of 0 leaves the corresponding component unchanged. Default: 0
7.2 Graphics State
115
Table 7.4 Options for create_gstate( )
key
explanation and possible values
overprintstroke
(Boolean) Overprint for stroke operations. Default: false
renderingintent
(Keyword) Color rendering intent used for gamut compression; possible keywords: Auto,
AbsoluteColorimetric, RelativeColorimetric, Saturation, Perceptual
smoothness
(Float) Maximum error of a linear interpolation for a shading; must be >= 0 and <= 1
softmask
(Option list or keyword) Current soft mask with mask shape or opacity values for transparent imaging. The keyword none specifies no soft mask at all; this is required to disable soft masks which
may be in effect from a previously set gstate. Supported options (default: none):
backdropcolor
(List with one, three, or four floats; only relevant for type=luminosity) Color to be
used as the backdrop against which to composite the transparency group template.
The number of float values depends on the colorspace suboption of the transparencygroup option used when creating the transparency group template (1 for
DeviceGray, 3 for DeviceRGB, 4 for DeviceCMYK). Default: black in the respective
colorspace
template (Template handle; required) Transparency group template which has been created
with begin_template_ext( ).
type
(Keyword; required) Method for deriving mask values from the transparency group
template:
alpha
Use the transparency group’s alpha value and ignore the color.
luminosity Convert the transparency group’s color to a single-component luminosity
value. In this case the template must have been created with the transparencygroup option.
strokeadjust
(Boolean) Whether or not to apply automatic stroke adjustment. Default: false
textknockout
(Boolean; PDF 1.4) With respect to compositing, glyphs in a text object will be treated as separate
objects (false) or as a single object (true). Default: true
VB RB Sub set_gstate(gstate As Long)
C# void set_gstate(int gstate)
Activate a graphics state object.
gstate
A handle for a graphics state object retrieved with create_gstate( ).
Details All options contained in the graphics state object will be set. Graphics state options accumulate when this function is called multiply. Options which are not explicitly set in
the graphics state object will keep their current values. All graphics state options will be
reset to their default values at the beginning of a page.
Scope page, pattern, template, glyph
116
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
7.3 Coordinate System Transformations
All transformation functions (translate( ), scale( ), rotate( ), align( ), skew( ), concat( ),
setmatrix( ), and initgraphics( )) change the coordinate system used for drawing subsequent objects. They do not affect existing objects on the page.
VB RB Sub translate(tx As Double, ty As Double)
C# void translate(double tx, double ty)
Translate the origin of the coordinate system.
tx, ty The new origin of the coordinate system is the point (tx, ty), measured in the old
coordinate system.
Scope page, pattern, template, glyph
VB RB Sub scale(sx As Double, sy As Double)
C# void scale(double sx, double sy)
Scale the coordinate system.
Scaling factors in x and y direction.
sx, sy
Details This function scales the coordinate system by sx and sy. It may also be used for achieving a reflection (mirroring) by using a negative scaling factor. One unit in the x direction
in the new coordinate system equals sx units in the x direction in the old coordinate system; analogous for y coordinates.
Scope page, pattern, template, glyph
Bindings COM: this function is also available under the name pscale to work around a bug in VB.
VB RB Sub rotate(phi As Double)
C# void rotate(double phi)
Rotate the coordinate system.
phi
The rotation angle in degrees.
Details Angles are measured counterclockwise from the positive x axis of the current coordinate system. The new coordinate axes result from rotating the old coordinate axes by
phi degrees.
Scope page, pattern, template, glyph
VB RB Sub align(dx As Double, dy As Double)
C# void align(double dx, double dy)
Align the coordinate system with a relative vector.
dx, dy
Coordinates of a direction vector dx and dy must not both be 0.
7.3 Coordinate System Transformations
117
Details Rotate the coordinate system such that the x axis of the new coordinate system is
aligned with the vector (dx, dy), and the y axis is aligned with (-dy, dx). This is equivalent
to rotate( ) with phi=180° / pi * atan2(dy/dx).
Scope page, pattern, template, glyph
VB RB Sub skew(alpha As Double, beta As Double)
C# void skew(double alpha, double beta)
Skew the coordinate system.
alpha, beta
Skewing angles in x and y direction in degrees.
Details Skewing (or shearing) distorts the coordinate system by the given angles in x and y direction. alpha is measured counterclockwise from the positive x axis of the current coordinate system, beta is measured clockwise from the positive y axis. Both angles must be
in the range -360˚ < alpha, beta < 360˚, and must be different from -270˚, -90˚, 90˚, and
270˚.
Scope page, pattern, template, glyph
VB RB Sub concat(a As Double, b As Double, c As Double, d As Double, e As Double, f As Double)
C# void concat(double a, double b, double c, double d, double e, double f)
Apply a transformation matrix to the current coordinate system.
a, b, c, d, e, f Elements of a transformation matrix. The six values make up a matrix in
the same way as in PostScript and PDF (see references). In order to avoid degenerate
transformations, a*d must not be equal to b*c.
Details This function applies a matrix to the current coordinate system. It allows for the most
general form of transformations. Unless you are familiar with the use of transformation matrices, the use of translate( ), scale( ), rotate( ), and skew( ) is suggested instead of
this function. The coordinate system is reset to the default coordinate system (i.e. the
current transformation matrix is the identity matrix [1, 0, 0, 1, 0, 0]) at the beginning of
each page.
Scope page, pattern, template, glyph
VB RB Sub setmatrix(a As Double, b As Double, c As Double, d As Double, e As Double, f As Double)
C# void setmatrix(double a, double b, double c, double d, double e, double f)
Explicitly set the current transformation matrix.
a, b, c, d, e, f
See concat( ).
Details This function is similar to concat( ). However, it disposes of the current transformation
matrix, and completely replaces it with the new matrix.
Scope page, pattern, template, glyph
118
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
7.4 Path Construction
Table 7.5 lists relevant value key names for this section (see Section 2.2, »Parameter and
Option Handling«, page 18). The key names cannot be used with set_value( ) since there
are corresponding API functions available for setting these values.
Table 7.5 Keys for get_value( )
key
explanation
currentx
currenty
The x or y coordinate (in units of the current coordinate system), respectively, of the current point. Scope: page, pattern, template, path
ctm_a
ctm_d
ctm_b
ctm_e
ctm_c
ctm_f
The components of the current transformation matrix (CTM) for vector graphics. Scope:
page, pattern, template, path
Note Make sure to call one of the functions in Section 7.5, »Painting and Clipping«, page 123, after
using the functions in this section, or the constructed path will have no effect, and subsequent
operations may raise an exception.
VB RB Sub moveto(x As Double, y As Double)
C# void moveto(double x, double y)
Set the current point for graphics output.
x, y
The coordinates of the new current point.
Details The current point is set to the default value of undefined at the beginning of each page.
The current points for graphics and the current text position are maintained separately.
Scope page, pattern, template, path, glyph; this function starts path scope.
Params currentx, currenty
VB RB Sub lineto(x As Double, y As Double)
C# void lineto(double x, double y)
Draw a line from the current point to another point.
x, y
The coordinates of the second endpoint of the line.
Details This function adds a straight line from the current point to (x, y) to the current path. The
current point must be set before using this function. The point (x, y) becomes the new
current point.
The line will be centered around the »ideal« line, i.e. half of the linewidth (as determined by the value of the linewidth parameter) will be painted on each side of the line
connecting both endpoints. The behavior at the endpoints is determined by the value of
the linecap parameter.
Scope path
Params currentx, currenty
7.4 Path Construction
119
VB RB Sub curveto(x1 As Double, y1 As Double, x2 As Double, y2 As Double, x3 As Double, y3 As Double)
C# void curveto(double x1, double y1, double x2, double y2, double x3, double y3)
Draw a Bézier curve from the current point, using three more control points.
x1, y1, x2, y2, x3, y3
The coordinates of three control points.
Details A Bézier curve is added to the current path from the current point to (x3, y3), using (x1, y1)
and (x2, y2) as control points. The current point must be set before using this function.
The endpoint of the curve becomes the new current point.
Scope path
Params currentx, currenty
VB RB Sub circle(x As Double, y As Double, r As Double)
C# void circle(double x, double y, double r)
Draw a circle.
x, y
r
The coordinates of the center of the circle.
The radius of the circle.
Details This function adds a circle to the current path as a complete subpath. The point (x + r, y)
becomes the new current point. The resulting shape will be circular in user coordinates.
If the coordinate system has been scaled differently in x and y directions, the resulting
curve will be elliptical.
Scope page, pattern, template, path, glyph; this function starts path scope.
Params currentx, currenty
Bindings COM: this function is also available under the name pcircle to work around a bug in VB 6.
VB RB Sub arc(x As Double, y As Double, r As Double, alpha As Double, beta As Double)
C# void arc(double x, double y, double r, double alpha, double beta)
Draw a counterclockwise circular arc segment.
x, y
r
The coordinates of the center of the circular arc segment.
The radius of the circular arc segment. r must be nonnegative.
alpha, beta
The start and end angles of the circular arc segment in degrees.
Details This function adds a counterclockwise circular arc segment to the current path, extending from alpha to beta degrees. For both arc( ) and arcn( ), angles are measured counterclockwise from the positive x axis of the current coordinate system. If there is a current
point an additional straight line is drawn from the current point to the starting point of
the arc. The endpoint of the arc becomes the new current point.
The arc segment will be circular in user coordinates. If the coordinate system has
been scaled differently in x and y directions the resulting curve will be elliptical.
Scope page, pattern, template, path, glyph; this function starts path scope.
120
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
Params currentx, currenty
VB RB Sub arcn(x As Double, y As Double, r As Double, alpha As Double, beta As Double)
C# void arcn(double x, double y, double r, double alpha, double beta)
Draw a clockwise circular arc segment.
Details Except for the drawing direction, this function behave exactly like arc( ). In particular,
the angles are still measured counterclockwise from the positive x axis.
VB RB Sub circular_arc(x1 As Double, y1 As Double, x2 As Double, y2 As Double)
C# void circular_arc(double x1, double y1, double x2, double y2)
Draw a circular arc segment defined by three points.
x1, y1
The coordinates of an arbitrary point on the circular arc segment.
x2, y2
The coordinates of the end point of the circular arc segment.
Details This function adds a circular arc segment to the current path. The arc segment will start
at the current point, pass through (x1, y1), and end at (x2, y2). The current point must be
set before using this function. The endpoint of the curve becomes the new current
point.
The arc segment will be circular in user coordinates. If the coordinate system has
been scaled differently in x and y directions the resulting curve will be elliptical.
Scope path
Params currentx, currenty
VB RB Sub ellipse(x As Double, y As Double, rx As Double, ry as Double)
C# void ellipse(double x, double y, double rx, double ry)
Draw an ellipse.
x, y
rx, ry
The coordinates of the center of the ellipse.
The x and y radii of the ellipse.
Details This function adds an ellipse to the current path as a complete subpath. The point
(x + rx, y) becomes the new current point.
Scope page, pattern, template, path, glyph; this function starts path scope.
Params currentx, currenty
VB RB Sub rect(x As Double, y As Double, width As Double, height As Double)
C# void rect(double x, double y, double width, double height)
Draw a rectangle.
x, y
The coordinates of the lower left corner of the rectangle.
width, height
The size of the rectangle.
7.4 Path Construction
121
Details This function adds a rectangle to the current path as a complete subpath. Setting the
current point is not required before using this function. The point (x, y) becomes the
new current point. The lines will be centered around the »ideal« line, i.e. half of the linewidth (as determined by the value of the linewidth parameter) will be painted on each
side of the line connecting the respective endpoints.
Scope page, pattern, template, path, glyph; this function starts path scope.
Params currentx, currenty
VB RB Sub closepath( )
C# void closepath( )
Close the current path.
Details This function closes the current subpath, i.e. adds a line from the current point to the
starting point of the subpath.
Scope path
Params currentx, currenty
122
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
7.5 Painting and Clipping
Note Most functions in this section clear the path, and leave the current point undefined. Subsequent drawing operations must therefore explicitly set the current point (e.g. using moveto( ))
after one of these functions has been called.
VB RB Sub stroke( )
C# void stroke( )
Stroke the path with the current line width and current stroke color, and clear it.
Scope path; this function terminates path scope.
VB RB Sub closepath_stroke( )
C# void closepath_stroke( )
Close the path, and stroke it.
Details This function closes the current subpath (adds a straight line segment from the current
point to the starting point of the path), and strokes the complete current path with the
current line width and the current stroke color.
Scope path; this function terminates path scope.
VB RB Sub fill( )
C# void fill( )
Fill the interior of the path with the current fill color.
Details This function fills the interior of the current path with the current fill color. The interior
of the path is determined by one of two algorithms (see the fillrule parameter). Open
paths are implicitly closed before being filled.
Scope path; this function terminates path scope.
Params fillrule
VB RB Sub fill_stroke( )
C# void fill_stroke( )
Fill and stroke the path with the current fill and stroke color.
Scope path; this function terminates path scope.
Params fillrule
7.5 Painting and Clipping
123
VB RB Sub closepath_fill_stroke( )
C# void closepath_fill_stroke( )
Close the path, fill, and stroke it.
Details This function closes the current subpath (adds a straight line segment from the current
point to the starting point of the path), and fills and strokes the complete current path.
Scope path; this function terminates path scope.
Params fillrule
VB RB Sub clip( )
C# void clip( )
Use the current path as clipping path, and terminate the path.
Details This function uses the intersection of the current path and the current clipping path as
the clipping path for subsequent operations. The clipping path is set to the default value of the page size at the beginning of each page. The clipping path is subject to save( )/
restore( ). It can only be enlarged by means of save( )/restore( ).
Scope path; this function terminates path scope.
VB RB Sub endpath( )
C# void endpath( )
End the current path without filling or stroking it.
Details This function doesn’t have any visible effect on the page. It generates an invisible path
on the page.
Scope path; this function terminates path scope.
124
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
7.6 Path Objects
VB RB Function add_path_point(path As Long, x As Double, y As Double, type As String, optlist As String)
As Long
C# int add_path_point(int path, double x, double y, String type, String optlist)
Add a point to a new or existing path object.
path A valid path handle returned by another call to add_path_point( ) or -1 to create a
new path.
x, y Coordinates of the new current point. If polar=false the two numbers designate
the cartesian coordinates (x, y) of the point. If polar=true the two numbers designate the
radius r and angle phi (in degrees or radians depending on the option radians) of the
point.
This point will become the new current point for type=move, line, curve, circular.
type
Specifies the type of the point according to Table 7.6.
Table 7.6 Types of points for add_path_point( )
keyword
explanation
circular
Add a circular arc from the current point to the new point with the previously defined control point as
third circular arc point which is required. If the new point is identical with the current point a circle with
diameter between the current point and the control point will be created.
control
Control point for a Bézier curve or a circular arc.
curve
Add a Bézier curve from the current point to the new point with the previously defined control points. At
least one control point must be provided. If only one control point is available, it will be used as the second control point for the curve, and the first control point will be constructed as the reflection of the second control point at the endpoint of the previous Bézier curve.
line
Add a line segment from the current point to the new point.
move
Start a new subpath or (if the appearance changes or a different path operation is used) a new path. Subpaths will be numbered consecutively (1, 2, ...). The first subpath starts at the origin.
origin
New origin for absolute coordinates. If relative=true the coordinates refer to the last origin. Origins
can be set arbitrarily often and will not be inserted in the path object. Default: (0, 0)
optlist An option list specifying path construction options:
> Path calculation and naming options for a point according to Table 7.7: name, polar,
radians, relative
> Options for assigning attributes to a single subpath (only for type=move) according
to Table 7.7: close, fill, round, stroke
> Graphics appearance options (only for type=move) according to Table 7.2:
dasharray, dashphase, fillcolor, fillrule, flatness, gstate, linecap, linejoin, linewidth,
miterlimit, strokecolor
Returns A path handle which can be used until it is deleted with delete_path( ).
Details A path object serves as a container for vector graphics. The path object can be populated
with paths and subpaths incrementally. The generated path can later be used with
draw_path( ) and other functions.
7.6 Path Objects
125
A path object can hold any number of paths: whenever the appearance changes (e.g.
a new color) or a different path operation option is used (e.g. stroke vs. fill) a new path is
started automatically.
Each path in turn can contain one or more subpaths. A subpath starts at a point with
type=move and ends before the next point with type=move, or before the end of the
chain of points.
All subpaths will be closed, filled, stroked, and rounded separately according to the
specified options. All paths will be filled separately.
Scope any
Table 7.7 Options for add_path_point( )
option
explanation
close
(Boolean; only for type=move) If true, the subpath will be closed with a straight line. Default: see footnote1
fill
(Boolean; only for type=move) If true the subpath will be closed and filled. Default: see footnote1
name
(String) Name of the point. Default: p<i> (e.g. p1) where i is the consecutive number of supplied points.
polar
(Boolean) If true, the (x, y) parameters are polar coordinates specifying radius r and angle phi, otherwise cartesian coordinates specifying x and y values. Default:false
radians
(Boolean) If true, angles for polar coordinates are specified in radians, otherwise in degrees. Default:
false
relative
(Boolean) If true, (x, y) are relative to the current point, otherwise to the current origin. Default: see
footnote1
round
(Float; only for type=move) Adjacent line vertices in the subpath will be rounded in their joining point
by a circular arc with the line segments as its tangents and with the specified radius. If the radius is negative the arc will be grooved so that the corners are circularly grooved. If close=true and no line from
the last to the first point was explicitly specified, the first line and the closing line will also be rounded. If
round=0 no rounding will be done. Default: see footnote1
stroke
(Boolean; only for type=move) If true the subpath will be stroked. Default: see footnote1
1. The default is specified in draw_path( ), info_path( ), the textpath option of fit_textline( ), the wrap option of fit_textflow( ), or the
fitpath option of add_table_cell( ).
VB RB Sub draw_path(path As Long, x As Double, y As Double, optlist As String)
C# void draw_path(int path, double x, double y, String optlist)
Draw a path object.
path A valid path handle returned by a call to add_path_point( ) or another function
which returns a path handle (e.g. info_image( ) with the boundingbox keyword).
x, y Coordinates of the reference point in user coordinates. The reference point is used
by various options, and specifies the position of the origin of the path object in the current user system. This implies a translation of the path object.
If the boxsize option is specified, (x, y) is the lower left corner of the fitbox (see Table 6.1)
into which the path object will be fit.
optlist An option list specifying path drawing options:
> Fitting options according to Table 6.1:
align, attachmentpoint, boxsize, fitmethod, orientate, position, scale
126
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
> Path operation and subpath selection options according to Table 7.8:
clip, close, fill, round, stroke, subpaths
> Graphics appearance options according to Table 7.2; these are relevant only for the
fill and stroke options:
dasharray, dashphase, fillcolor, fillrule, flatness, gstate, linecap, linejoin, linewidth,
miterlimit, strokecolor
Details The path(s) will be placed at the reference point (x, y) and then be stroked, filled, or used
as a clipping path according to the specified options. This function does not modify the
current graphics state unless the clip option is used. The appearance and operation options override the default settings, but they do not override any appearance option
which may have been specified for a subpath in add_path_point( ).
Scope page, pattern, template, glyph
Table 7.8 Path operation options for add_path_point( ) for controlling all subpaths in a path object
option
explanation
clip
(Boolean) If true the path will be closed and used as clipping path. All graphics appearance options will
be ignored. Default: false
close
(Boolean) If true, each subpath will be closed with a straight line. Default: the value specified when the
path was constructed, or false if no value was specified
fill
(Boolean) If true each path will be filled. Default: the value specified when the path was constructed, or
false if no value was specified
round
(Float) For each subpath, adjacent line vertices will be rounded in their joining point by a circular arc
with the line segments as its tangents and with the specified radius. If the radius is negative the arc will
be grooved so that the corners are circular grooved. If close=true and no line from the last to the first
point was explicitly specified, the first line and the closing line will also be rounded. If round=0 no rounding will be done. Default: the value specified when the path was constructed, or 0 if no value was specified
stroke
(Boolean) If true the path will be stroked. Default: false
subpaths
(List of integers or single keyword) List with the numbers of subpaths to be drawn. The keyword all specifies all subpaths. Default: all
VB RB Function info_path(path As Long, keyword As String, optlist As String) As Double
C# double info_path(int path, String keyword, String optlist)
Query the results of drawing a path object without actually drawing it.
path A valid path handle returned by a call to add_path_point( ) or another function
which returns a path handle (e.g. info_image( ) with the boundingbox keyword).
keyword
A keyword specifying the requested information according to Table 7.9.
optlist An option list specifying path drawing options:
> All options of draw_path( ) according to Table 7.8
> Additional fitting option according to Table 6.1: refpoint
> Additional option according to Table 7.10:name
Returns The value of some path properties as requested by keyword.
7.6 Path Objects
127
Table 7.9 Keywords for info_path( )
keyword
explanation
boundingbox
A handle to a path containing the bounding box in user coordinates (relative to the reference point)
numpoints
Number of supplied points. The option subpaths will be ignored.
px, py
The x or y coordinate (in the user coordinate system) of the path point specified in the name option. The
option subpaths will be ignored.
width,
height
Width and height of the bounding box of the path in user coordinates; linewidth and miterlimit will be
ignored.
x1, y1, x2, y2, Position of the i-th rectangle corner (i=1, 2, 3, 4) of the bounding box in user coordinates relative to the
x3, y3, x4, y4 reference point
Details This function will perform the same calculations as add_path_point( ), but will not create
any visible output on the page.
Scope any
Table 7.10 Options for info_path( )
option
explanation
name
Name of a path point for the keys px or py. A default name (e.g. p1) can be used even if an explicit name
has been specified in add_path_point( ).
VB RB Sub delete_path(path As Long)
C# void delete_path(int path)
Delete a path object.
path A valid path handle returned by a call to add_path_point( ) or another function
which returns a path handle (e.g. info_image( ) with the boundingbox keyword).
Details Delete the path object and all associated internal data structures. Note that path objects
will not automatically be deleted in end_document( ).
Scope any
128
Chapter 7: Graphics Functions (Edition for COM, .NET, and REALbasic)
8 Color Functions
8.1 Setting Color and Color Space
Cookbook A full code sample can be found in the Cookbook topic color/starter_color.
Table 8.1 lists relevant parameter key names for this section (see Section 2.2, »Parameter
and Option Handling«, page 18).
Table 8.1 Color-related keys for get/set_parameter( )
key
explanation
preserveoldpantonenames
If false, old-style Pantone spot color names will be converted to the corresponding new color
names, otherwise they will be preserved. Default: false. Scope: any
spotcolorlookup
If false, PDFlib will not use its internal database of spot color names. This can be used to provide
custom definitions of known spot colors, which may be required as a workaround to match the
definitions used by other applications. This feature should be used with care, and is not recommended. Default: true. Scope: any
Color spaces. PDFlib clients may specify the colors used for filling and stroking the interior of paths and text characters. Colors may be specified in several color spaces (each
list item starts with the corresponding color space keyword for setcolor( ) and color options):
> gray: Gray values between 0=black and 1=white;
> rgb: RGB triples, i.e. three values between 0 and 1 specifying the percentage of red,
green, and blue; (0, 0, 0)=black, (1, 1, 1)=white. The commonly used RGB color values in
the range 0–255 must be divided by 255 in order to scale them to the range 0–1 as required by PDFlib.
As an alternative to numerical RGB values you can specify RGB colors via their HTML
name or hexadecimal values (see »Color«, page 12).
Cookbook A full code sample for using RGB color values can be found in the Cookbook topic
color/web_colornames.
> cmyk: Four CMYK values between 0 = no color and 1 = full color, representing cyan,
magenta, yellow, and black values; (0, 0, 0, 0)=white, (0, 0, 0, 1)=black. Note that this is
different from the RGB specification.
> iccbasedgray/rgb/cmyk: ICC-based colors are specified with the help of an ICC profile.
> spot: Spot color (separation color space): a predefined or arbitrarily named custom
color with an alternate representation in one of the other color spaces above; this is
generally used for preparing documents which are intended to be printed on an offset printing machine with one or more custom colors. The tint value (percentage)
ranges from 0 = no color to 1 = maximum intensity of the spot color.
> lab: Device-independent colors in the CIE L*a*b* color space are specified by a luminance value in the range 0-100 and two color values a and b in the range -127 to 128.
The a component contains the green-red axis, while the b component contains the
blue-yellow axis.
8.1 Setting Color and Color Space
129
> pattern: tiling pattern with an object composed of arbitrary text, vector, or image
graphics.
> Shadings (smooth blends) provide a gradual transition between two colors, and are
based on another color space. Shadings can be created with shading( ).
> The indexed color space is a not really a color space on its own, but rather an efficient
coding of another color space. It will automatically be generated when an indexed
(palette-based) image is imported, but cannot be specified directly.
The default color for stroke and fill operations is black.
Color specification in option lists. See »Color«, page 12, for a description and examples
of the color data type in option lists.
VB RB Sub setcolor(fstype As String, colorspace as String,
c1 As Double, c2 As Double, c3 As Double, c4 As Double)
C# void setcolor(String fstype, String colorspace, double c1, double c2, double c3, double c4)
Set the current color space and color.
fstype One of fill, stroke, or fillstroke to specify that the color is set for filling, stroking,
or both.
colorspace Specifies the colorspace to be used for the supplied color values, or an RGB
color value which is specified by name or hexadecimal values.
First form: one of gray, rgb, cmyk, spot, pattern, iccbasedgray, iccbasedrgb, iccbasedcmyk,
or lab to specify the color space.
Second form: an RGB color name (e.g. pink) or a hash character followed by six hexadecimal digits (e.g. #FFC0CB). See »Color«, page 12, for more details.
c1, c2, c3, c4 Color components for the chosen color space. The interpretation of these
values depends on the colorspace parameter:
> gray: c1 specifies a gray value;
> rgb: c1, c2, c3 specify red, green, and blue values.
> cmyk: c1, c2, c3, c4 specify cyan, magenta, yellow, and black values;
> iccbasedgray: c1 specifies a gray value;
> iccbasedrgb: c1, c2, c3 specify red, green, and blue values;
> iccbasedcmyk: c1, c2, c3, c4 specify cyan, magenta, yellow, and black values;
> spot: c1 specifies a spot color handle returned by makespotcolor( ), and c2 specifies a
tint value between 0 and 1;
> lab: c1, c2, and c3 specify color values in the CIE L*a*b* color space, interpreted with
the D50 illuminant. c1 specifies the L* (luminance) in the range 0 to 100, and c2, c3
specify the a*, b* (chrominance) values in the range -127 to 128.
> pattern: c1 specifies a pattern handle returned by begin_pattern( ) or shading_
pattern( ). The current fill or stroke color will be applied when the pattern is used for
filling or stroking. The current color space must not be another pattern color space.
Details All color values for the gray, rgb, and cmyk color spaces and the tint value for the spot color space must be numbers in the inclusive range 0–1. Unused parameters should be set
to 0.
130
Chapter 8: Color Functions (Edition for COM, .NET, and REALbasic)
The fill and stroke color values for the gray, rgb, and cmyk color spaces are set to a default value of black at the beginning of each page. There are no defaults for spot and pattern colors.
If the iccbasedgray/rgb/cmyk color spaces are used, a suitable ICC profile must have
been set before using the setcolor:iccprofilegray/rgb/cmyk parameters (see Table 8.3).
PDF/X-1a: colorspace=rgb, iccbasedgray/rgb/cmyk, and lab are not allowed.
PDF/X-3: Using iccbasedgray/rgb/cmyk and lab color requires an ICC profile in the
output intent (a standard name is not sufficient in this case).
PDF/X-3/4/5: colorspace=gray requires that the defaultgray option in begin_page_ext( )
has been set unless the PDF/X output intent is a grayscale or CMYK device.
colorspace=rgb requires that the defaultrgb option in begin_page_ext( ) has been set
unless the output intent is an RGB device.
colorspace=cmyk requires that the defaultcmyk option in begin_page_ext( ) has been
set unless the output intent is a CMYK device.
PDF/A: colorspace=gray requires that the defaultgray option in begin_page_ext( ) has
been set unless an output intent (any type) has been specified.
colorspace=rgb requires that the defaultrgb option in begin_page_ext( ) has been set
unless the output intent is an RGB device.
colorspace=cmyk requires that the defaultcmyk option in begin_page_ext( ) has been
set unless the output intent is a CMYK device.
Scope page, pattern (only if the pattern’s paint type is 1), template, glyph (only if the Type 3
font’s colorized option is true), document; a pattern color can not be used within its own
definition. Setting the color in document scope may be useful for defining spot colors
with makespotcolor( ).
Params setcolor:iccprofilegray/rgb/cmyk
VB RB Function makespotcolor(spotname As String) As Long
C# int makespotcolor(String spotname)
Find a built-in spot color name, or make a named spot color from the current fill color.
spotname The name of a built-in spot color, or an arbitrary name for the spot color to
be defined. This name is restricted to a maximum length of 126 bytes. Only 8-bit characters are supported in the spot color name; Unicode or embedded null characters are not
supported. PANTONE® colors are not supported in PDF/X-1a mode.
The special spot color name All can be used to apply color to all color separations,
which is useful for painting registration marks. A spot color name of None will produce
no visible output on any color separation.
Returns A color handle which can be used in subsequent calls to setcolor( ) throughout the document. Spot color handles can be reused across all pages, but not across documents.
There is no limit for the number of spot colors in a document.
Details If spotname is known in the internal color tables and the spotcolorlookup parameter is
true (which is default), the supplied spot color name will be used. Otherwise the (CMYK
or other) color values of the current fill color will be used to define the appearance of a
new spot color. These alternate values will only be used for screen preview and low-end
printing. The supplied spot color name will be used for producing color separations instead of the alternate values.
8.1 Setting Color and Color Space
131
If spotname has already been used in a previous call to makespotcolor( ), the return
value will be the same as in the earlier call, and will not reflect the current color.
Scope page, pattern, template, glyph (only if the Type 3 font’s colorized option is true), document;
the current fill color must not be a spot color or pattern if a custom color is to be defined.
Params spotcolorlookup, preserveoldpantonenames
132
Chapter 8: Color Functions (Edition for COM, .NET, and REALbasic)
8.2 ICC Profiles
VB RB Function load_iccprofile(profilename As String, optlist As String) As Long
C# int load_iccprofile(String profilename, String optlist)
Search for an ICC profile and prepare it for later use.
profilename (Name string) The name of an ICCProfile resource, or a disk-based or virtual file name. If PDF/X-1 or PDF/X-3 is generated and usage=outputintent, one of the standard output condition names listed in Table 8.5 (or a name defined with the StandardOutputIntent resource category) can also be used without embedding the corresponding
ICC profile. If one of the standard output intents is to be used with PDF/X-4 or PDF/X5pg, the corresponding ICC profile must be configured as with the ICCProfile resource,
using the reference name in Table 8.5 as the resource name.
optlist An option list describing aspects of profile handling:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Profile handling options according to Table 8.2: description, embedprofile, metadata, urls,
usage
Table 8.2 Options for load_iccprofile( )
key
explanation and possible values
description
(String; only for usage=outputintent and non-standard output conditions) Human-readable description
of the ICC profile which will be used along with the output intent.
embedprofile
(Boolean; only for PDF/X-1 or PDF/X-3 and usage=outputintent; will be forced to true for PDF/X-4 and
PDF/X-5g) Force an embedded ICC profile even if a standard output intent for PDF/X has been supplied as
profilename. Default: false
metadata
(Option list; will be ignored for standard output intents and referenced output intents, i.e. usage=
outputintent in PDF/X-4p and PDF/X-5pg mode; PDF 1.4) Supply metadata for the profile (see Section
14.2, »XMP Metadata«, page 209)
urls
(List of one or more strings; only for PDF/X-4p and PDF/X-5pg, and required in this case) A list of URLs
which indicate where a referenced output intent ICC profile can be obtained. Sender and receiver should
arrange reasonable URL entries. The strings can freely be chosen, but must contain valid URL syntax.
usage
(Keyword) Intended use of the ICC profile. Supported keywords (default: iccbased):
iccbased
The ICC profile will be used to define an ICC-based color space for text or graphics, or will be
applied to an image. Input, display and output device (scanner, monitor, and printer) profiles
as well as color space conversion profiles can be used.
outputintent
The ICC profile will be used to define an output intent for PDF/X or PDF/A. In PDF/X-4p and
PDF/X-5pg mode the specified output intent ICC profile will not be embedded, but a reference
to an external profile will be created. The profile must be available locally when generating
the PDF, and must be available to the PDF consumer when viewing or printing the document.
In PDF/X mode only output device (printer) profiles can be used for usage=outputintent.
Returns A profile handle which can be used in subsequent calls to load_image( ) or for setting
profile-related parameters. If errorpolicy=return the caller must check for a return value
of -1 since it signals an error. The returned profile handle can not be reused across multiple PDF documents. Also, the returned handle can not be applied to an image if
8.2 ICC Profiles
133
usage=outputintent. There is no limit to the number of ICC profiles in a document. If the
function call fails you can request the reason of the failure with get_errmsg( ).
Details If usage=iccbased the named profile will be searched according to the profile search
strategy. If the profile is found, it will be checked whether it is suitable (e.g. number of
color components). The sRGB profile is always available internally, and must not be configured. Loaded ICC profiles must conform to ICC versions up to 2.x for PDF 1.4, and to
ICC versions up to 4.x for PDF 1.5 and above. Profiles can be specified in the gray, RGB,
CMYK, or Lab color spaces.
PDF/X: the output intent must be set either using this function or by copying an imported document’s output intent using process_pdi( ).
PDF/X-1 and PDF/X-3: If usage=outputintent the named profile is first searched in the
internal list of standard output intents and then in the list of user-configured output
intents. If the supplied profilename was found to be a standard output intent, no ICC
profile is required and only the name will be written to the PDF output as output intent.
If the name was not found to be a standard output intent identifier, it is treated as a profile name and the corresponding ICC profile (possibly mapped via the ICCProfile resource
category) will be embedded in the PDF as output intent.
PDF/A: the output intent can be set using this function or by copying an imported
document’s output intent using process_pdi( ). However, if only device-independent colors are used in the document no output intent is required.
Scope document; the output intent should be set immediately after begin_document( ). If
usage=iccbased the following scopes are also allowed: page, pattern, template, glyph.
Params See Table 8.3 and Table 8.4
Table 8.3 Keys for get/set_parameter( ) (see Section 2.2, »Parameter and Option Handling«, page 18)
key
explanation
ICCProfile
StandardOutputIntent
The corresponding resource file line as it would appear for the respective category in a UPR file.
Multiple calls add new entries to the internal list (see also resourcefile in Table 2.3). Scope: any
Table 8.4 Keys for get/set_value( ) (see Section 2.2, »Parameter and Option Handling«, page 18)
key
explanation
icccomponents Number of color components in the ICC profile referenced by the handle provided in the modifier
setcolor:iccprofilegray
ICC profile which specifies a Gray color space for use with setcolor( ). Scope: document, page, pattern,
template, glyph
setcolor:iccprofilergb
ICC profile which specifies an RGB color space for use with setcolor( ). Scope: document, page, pattern,
template, glyph
setcolor:iccprofilecmyk
ICC profile which specifies a CMYK color space for use with setcolor( ). Scope: document, page, pattern,
template, glyph
134
Chapter 8: Color Functions (Edition for COM, .NET, and REALbasic)
Table 8.5 Standard CMYK output intents for PDF/X-1 and PDF/X-3 (see also www.color.org)
reference
name
description
CGATS standards for the US (www.npes.org/standards/tools.html)
CGATS TR 001
SWOP (Publication) printing in USA: ANSI CGATS.6
CGATS TR 002
SNAP printing in USA
CGATS TR 003
SWOP proofing and printing on U.S. Grade 3 coated publication paper
CGATS TR 005
SWOP proofing and printing on U.S. Grade 5 coated publication paper
CGATS TR 006
GRACoL proofing and printing on U.S. Grade 1 coated paper
GRACoL and SWOP standards for the US (www.gracol.org) (also available in the CGATS group)
GRACoL2006_ GRACoL Grade 1 coated paper, ISO 12647-2 Paper type 1. Data conforming to ISO 12647-2 parameters,
Coated1
smoothed and tuned to G7 NPDC 2006 (K50 slightly lighter than CMY50,40,40)
SWOP2006_
Coated3
SWOP Grade 3 coated paper, ISO 2846-1 inks. Characterization conforming to SWOP, tuned to the G7
Neutral Print Density Curve
SWOP2006_
Coated5
SWOP Grade 5 coated paper, ISO 2846-1 inks. Characterization conforming to SWOP, tuned to the G7
Neutral Print Density Curve
FOGRA standards (www.fogra.org)
FOGRA27
ISO/DIS 12647-2:2004, Offset commercial and specialty printing according to ISO 12647-2, positive plates,
paper type 1 or 2 (gloss or matte coated offset, 115 g/m2), screen frequency 60/cm.
FOGRA28
ISO/DIS 12647-2:2004, Offset commercial and specialty printing according to ISO 12647-2, positive plates,
paper type 3 (coated web, 60 g/m2), screen frequency 60/cm.
FOGRA29
ISO/DIS 12647-2:2004, Offset commercial and specialty printing according to ISO 12647-2, positive plates,
paper type 4 (uncoated white offset, 120 g/m2), screen frequency 60/cm.
FOGRA30
ISO/DIS 12647-2:2004, Offset commercial and specialty printing according to ISO 12647-2, positive plates,
paper type 5 (uncoated, slightly yellowish, offset, 115 g/m2), screen frequency 60/cm.
FOGRA31
ISO/DIS 12647-2:2003, Continuous forms printing according to ISO 12647-2, positive plates, paper type 2
(matt coated offset, 115 g/m2), screen frequency 60/cm.
FOGRA32
ISO/DIS 12647-2:2004, Continuous forms printing according to ISO 12647-2, positive plates, paper type 4
(white uncoated offset, 80 g/m2), screen frequency 60/cm.
FOGRA33
ISO/DIS 12647-2:2004, Continuous forms printing according to ISO 12647-2, positive plates, paper type 2
(matte coated offset, 115 g/m2), screen frequency 54/cm.
FOGRA34
ISO/DIS 12647-2:2004, Continuous forms printing according to ISO 12647-2, positive plates, paper type 4
(white uncoated offset, 120 g/m2), screen frequency 60/cm.
FOGRA35
ISO/DIS 12647-2:2004, Continuous forms printing according to ISO 12647-2, negative plates, paper type 2
(matte coated offset, 115 g/m2), screen frequency 54/cm.
FOGRA36
ISO/DIS 12647-2:2004, Continuous forms printing according to ISO 12647-2, negative plates, paper type 4
(white uncoated offset, 120 g/m2), screen frequency 54/cm.
FOGRA37
ISO/DIS 12647-2:2004, Continuous forms printing according to ISO 12647-2, negative plates, paper type 2
(matte coated offset, 115 g/m2), screen frequency 60/cm.
FOGRA38
ISO/DIS 12647-2:2004, Continuous forms printing according to ISO 12647-2, negative plates, paper type 4
(white uncoated offset, 120 g/m2), screen frequency 60/cm.
FOGRA39
ISO 12647-2:2004 / Amd 1, Offset commercial and specialty printing according to ISO 12647-2, paper type
1 or 2 (gloss or matte coated offset, 115 g/m2), screen frequency 60/cm.
8.2 ICC Profiles
135
Table 8.5 Standard CMYK output intents for PDF/X-1 and PDF/X-3 (see also www.color.org)
reference
name
description
FOGRA40
ISO 12647-2:2004, Offset commercial and specialty printing according to ISO 12647-2, super calendered
(SC) paper, 60 g/m2, screen frequency 60/cm.
FOGRA41
ISO 12647-2:2004, Offset printing according to ISO 12647-2, paper type MFC (machine finished coated),
tone value increase curves B (CMY) and C (K).
FOGRA42
ISO 12647-2:2004, Offset printing according to ISO 12647-2, paper type SNP (Standard Newsprint), tone
value increase curves C (CMY) and D (K).
FOGRA43
ISO 12647-2:2004/Amd1, Offset printing according to ISO 12647-2, paper type 1 or 2 (coated art) 115 g/m2
non-periodic screening, tone value increase curves F (CMYK).
FOGRA44
ISO 12647-2:2004/Amd1, Offset printing according to ISO 12647-2, paper type 4 (uncoated white) 115 g/m2
non-periodic screening, tone value increase curves F (CMYK).
IFRA standards for newsprint (www.ifra.com)
IFRA26
ISO/DIS 12647-3:2004, Coldset offset printing, contact exposed negative acting plates or computer to
plate (tone value increase of 26%), newsprint, screen ruling 40 lines per cm.
IFRA30
ISO/DIS 12647-3:2004, Coldset offset printing, contact exposed negative acting plates or computer to
plate (tone value increase of 30%), newsprint, screen ruling 40 lines per cm. (Principally applicable to the
USA).
Eurostandard System Brunner (www.systembrunner.com)
EUROSB104
Offset printing, according to Eurostandard System Brunner specification, within ISO 12647-2:2004 tolerances, paper type coated/semi-matte, 115 g/m2, TVI 15%, screen ruling 60 L/cm, for further information
see documentation.
EUROSB204
Offset printing, according to Eurostandard System Brunner specification, within ISO 12647-2:2004 tolerances, LWC woodpulp paper, 80 g/m2, TVI 15%, screen ruling 60 L/cm, for further information see documentation.
Japanese standards
JC200103
Japan Color 2001 Coated: ISO 12647-2:2004, sheet-fed offset printing, positive plates, paper type 3, (coated, 105 g/m2), screen frequency 69/cm.
JC200104
Japan Color 2001 Uncoated: ISO 12647-2:2004, sheet-fed offset printing, positive plates, paper type 4,
(uncoated, 105 g/m2), screen frequency 69/cm.
JCN2002
Japan Color 2002 for Newspaper Printing: ISO/DIS 12647-3:2004, coldset offset printing, negative plates,
newsprint, screen frequency 39/cm.
JCW2003
Japan Color 2003 for Web Offset: ISO 12647-2:2004, heat-set web offset printing, positive plates, paper
type 3, (coated, 70 g/m2), screen frequency 69/cm.
136
Chapter 8: Color Functions (Edition for COM, .NET, and REALbasic)
8.3 Patterns and Shadings
VB RB Function begin_pattern(width As Double, height As Double,
xstep As Double, ystep As Double, painttype As Long) As Long
C# int begin_pattern(double width, double height, double xstep, double ystep, int painttype)
Start a pattern definition.
width, height
The dimensions of the pattern’s bounding box in points.
xstep, ystep The offsets when repeatedly placing the pattern to stroke or fill some object. Most applications will set these to the pattern width and height, respectively.
painttype This parameter indicates whether the pattern contains color specifications
on its own, or is used as a stencil which will be colorized with the current fill or stroke
color when the pattern is used for filling or stroking:
> painttype=1 must be used if the pattern is colorized with one or more calls to
setcolor( ), or places images or imported PDF pages.
> painttype=2 must be used if the pattern does not contain any color specification. Instead, the current fill or stroke color will be applied when the pattern is used for filling or stroking. Image masks may be used for painttype=2. Before using the pattern,
setcolor( ) must be called to set the current color with a color space which is not itself
based on another pattern.
Undesired behavior may result if the wrong value of painttype is supplied.
Returns A pattern handle that can be used in subsequent calls to setcolor( ) during the enclosing
document scope.
Details This function will reset all text, graphics, and color state parameters to their defaults,
and establish a coordinate system according to the global topdown parameter. Hypertext functions and functions for opening images must not be used during a pattern definition, but all text, graphics, and color functions (with the exception of the pattern
which is in the process of being defined) can be used.
Scope document, page; this function starts pattern scope, and must always be paired with a
matching end_pattern( ) call.
Params topdown
VB RB Sub end_pattern( )
C# void end_pattern( )
Finish a pattern definition.
Scope pattern; this function terminates pattern scope, and must always be paired with a
matching begin_pattern( ) call.
8.3 Patterns and Shadings
137
VB RB Function shading_pattern(shading As Long, optlist As String) As Long
C# int shading_pattern(int shading, String optlist)
Define a shading pattern using a shading object (requires PDF 1.4).
shading
A shading handle returned by shading( ).
optlist An option list describing the graphics appearance of the shading pattern according to Table 7.2: gstate
Returns A pattern handle that can be used in subsequent calls to setcolor( ) during the enclosing
document scope.
Details This function can be used to fill arbitrary objects with a shading. To do so, a shading
handle must be retrieved using shading( ), then a pattern must be defined based on this
shading using shading_pattern( ). Finally, the pattern handle can be supplied to setcolor( )
to set the current color to the shading pattern.
Scope document, page, font
VB RB Sub shfill(shading As Long)
C# void shfill(int shading)
Fill an area with a shading, based on a shading object (requires PDF 1.4).
shading
A shading handle returned by shading( ).
Details This function allows shadings to be used without involving shading_pattern( ) and
setcolor( ). However, it works only for simple shapes where the geometry of the object to
be filled is the same as that of the shading itself. Since the current clip area will be shaded (subject to the extend0 and extend1 options of the shading) this function will generally be used in combination with clip( ).
Scope page, pattern (only if the pattern’s paint type is 1), template, glyph (only if the Type 3
font’s colorized option is true), document
VB RB Function shading(shtype As String, x0 As Double, y0 As Double, x1 As Double, y1 As Double,
c1 As Double, c2 As Double, c3 As Double, c4 As Double, optlist As String) As Long
C# int shading(String shtype, double x0, double y0, double x1, double y1,
double c1, double c2, double c3, double c4, String optlist)
Define a blend from the current fill color to another color (requires PDF 1.4).
shtype The type of the shading; must be axial for linear shadings or radial for circle-like
shadings.
x0, y0, x1, y1 For axial shadings, (x0, y0) and (x1, y1) are the coordinates of the starting
and ending points of the shading. For radial shadings these points specify the centers of
the starting and ending circles.
c1, c2, c3, c4 Color values of the shading’s endpoint, interpreted in the current fill color
space in the same way as the color parameters in setcolor( ). If the current fill color space
is a spot color space c1 will be ignored, and c2 contains the tint value.
138
Chapter 8: Color Functions (Edition for COM, .NET, and REALbasic)
optlist An option list describing aspects of the shading according to Table 8.6. The following options can be used: antialias, boundingbox, domain, extend0, extend1, N, r0, r1,
startcolor
Returns A shading handle that can be used in subsequent calls to shading_pattern( ) and shfill( )
during the enclosing document scope.
Details The current fill color will be used as the starting color; it must not be based on a pattern.
Scope document, page, font
Table 8.6 Options for shading( )
Option
explanation
antialias
(Boolean) Specifies whether to activate antialiasing for the shading. Default: false
boundingbox
(Rectangle) A rectangle defining the shading’s bounding box in user coordinates. The bounding box will
be applied as a temporary clipping path when the shading is painted (in addition to the current clipping
path which may be in effect). This option may be useful to clip the shading without applying clip( ).
domain
(List of 2 Floats) Two numbers specifying the limiting values of a parametric variable t. The variable is
considered to vary linearly between these two values as the color gradient varies between the starting
and ending points of the axis. Default: {0 1}
extend0
(Boolean) Specifies whether to extend the shading beyond the starting point. Default: false
extend1
(Boolean) Specifies whether to extend the shading beyond the endpoint. Default: false
N
(Float) Exponent for the color transition function; must be > 0. Default: 1
r0
(Float; only for radial shadings, and required in this case) Radius of the starting circle
r1
(Float; only for radial shadings, and required in this case) Radius of the ending circle
startcolor
(Color) The color of the starting point. This option may be useful to make the function independent of
the current color. Default: the current fill color
8.3 Patterns and Shadings
139
140
Chapter 8: Color Functions (Edition for COM, .NET, and REALbasic)
9 Image and Template Functions
Table 9.1 and Table 9.2 list relevant parameter and value key names for this section (see
Section 2.2, »Parameter and Option Handling«, page 18).
Table 9.1 Image-related keys for get/set_parameter( )
key
explanation
honoriccprofile
Read ICC color profiles embedded in images, and apply them to the image data. Default: true
renderingintent
The rendering intent for images. Default: Auto.
Auto
Do not specify any rendering intent in the PDF file, but use the device’s default intent
instead. Typical use: unknown cases
AbsoluteColorimetric
No correction for the device’s white point (such as paper white) is made. Colors which
are out of gamut are mapped to nearest value within the device’s gamut. Typical use:
exact reproduction of solid colors; not recommended for other uses
RelativeColorimetric
The color data is scaled into the device’s gamut, mapping the white points onto one
another while slightly shifting colors. Typical use: vector graphics
Saturation Saturation of the colors will be preserved while the color values may be shifted.
Typical use: business graphics
Perceptual Color relationships are preserved by modifying both in-gamut and out-of-gamut
colors in order to provide a pleasing appearance. Typical use: scanned images
Table 9.2 Image-related keys for get_value( )
key
explanation
imagewidth
imageheight
Deprecated, use info_image( ) with the imagewidth and imageheight keys.
image:iccprofile
Deprecated, use info_image( ) with the iccprofile key.
orientation
Deprecated, use info_image( ) with the orientation key.
resx, resy
Deprecated, use info_image( ) with the resx and resy keys.
141
9.1 Images
Cookbook A full code sample can be found in the Cookbook topic images/starter_image.
VB RB Function load_image(imagetype As String, filename As String, optlist As String) As Long
C# int load_image(String imagetype, String filename, String optlist)
Open a disk-based or virtual image file subject to various options.
imagetype The string auto instructs PDFlib to automatically detect the image file type
(this is not possible for CCITT and raw images). Explicitly specifying the image format
with one of the strings bmp, ccitt, gif, jbig2 (PDF 1.4 and above), jpeg, jpeg2000 (PDF 1.5 and
above), png, raw, or tiff offers slight performance advantages. Type ccitt is different from
a TIFF file which contains CCITT-compressed image data.
filename (Name string; will be interpreted according to the global filenamehandling option or parameter, see Table 2.2) Generally the name of the image file to be opened. This
must be the name of a disk-based or virtual file; PDFlib will not pull image data from
URLs.
If a file with the specified file name cannot be found and imagetype=auto PDFlib will
try to determine the appropriate file name suffix automatically; it will append all suffixes from the following list (in both lowercase and uppercase) to the specified filename
and try to locate a file with that name in the directories specified in the searchpath:
.bmp, .ccitt, .g3, .g4, .fax, .gif, .jbig2, .jb2, .jpg .jpeg, .jpx, .jp2, .jpf, .jpm,
.j2k, .png, .raw, .tif, .tiff
optlist An option list specifying image-related properties according to Table 9.3. The
following options can be used:
> General option: errorpolicy (see Table 2.6)
> Color-related options: colorize, honoriccprofile, iccprofile, invert, renderingintent
> Clipping, masking, and transparency options: alphachannelname, clippingpathname,
honorclippingpath, ignoremask, mask, masked
> Special PDF features for using the image: georeference, iconname, template
> Options for raw and CCITT images: bitreverse, bpc, components, height, K, width
> Options for JBIG2 images: copyglobals, imagehandle
> Options for processing the image data: cascadedflate, ignoreorientation, inline, page,
passthrough
> Other options: interpolate, layer, metadata, OPI-1.3, OPI-2.0
Returns An image handle which can be used in subsequent image-related calls. If
errorpolicy=return the caller must check for a return value of -1 since it signals an error.
The returned image handle can not be reused across multiple PDF documents. If the
function call fails you can request the reason of the failure with get_errmsg( ).
Details This function opens and analyzes a raster graphics file in one of the supported formats
as determined by the imagetype parameter, and copies the relevant image data to the
output document. This function will not have any visible effect on the output. In order
to actually place the imported image somewhere in the generated output document,
fit_image( ) must be used. Opening the same image more than once per generated docu-
142
Chapter 9: Image and Template Functions (Edition for COM, .NET, and REALbasic)
ment is not recommended because the actual image data will be copied to the output
document more than once.
PDFlib will open the image file with the provided filename, process the contents, and
close the file before returning from this call. Although images can be placed multiply
within a document (see fit_image( )), the actual image file will not be kept open after this
call.
If imagetype=raw or ccitt, the width, height, components, and bpc options must be supplied since PDFlib cannot deduce those from the image data. The user is responsible for
supplying option values which actually match the image. Otherwise corrupt PDF output may be generated, and Acrobat may respond with the message Insufficient data for
an Image.
If imagetype=raw, the length of the supplied image data must be equal to [width x
components x bpc / 8] x height bytes, with the bracketed term adjusted upwards to the
next integer. The image samples are expected in the standard PostScript/PDF ordering,
i.e. top to bottom and left to right (assuming no coordinate transformations have been
applied). 16-bit samples must be provided with the most significant byte first (big-endian or »Mac« byte order). The polarity of the pixel values is as discussed in Section , »Color spaces«, page 129. If bpc is smaller than 8, each pixel row begins on a byte boundary,
and color values must be packed from left to right within a byte. Image samples are always interleaved, i.e. all color values for the first pixel are supplied first, followed by all
color values for the second pixel, and so on.
PDF/X-1a: RGB images are not allowed.
PDF/X-3/4/5: Grayscale images require that the defaultgray option in begin_page_
ext( ) must have been set unless the output intent is a grayscale or CMYK device. RGB
images require that the defaultrgb option in begin_page_ext( ) must have been set unless
the output intent is an RGB device. CMYK images require that the defaultcmyk option in
begin_page_ext( ) must have been set unless the output intent is a CMYK device. JBIG2
images are not allowed.
PDF/A: Grayscale images require that the defaultgray option in begin_page_ext( ) has
been set unless an output intent (any type) has been specified.
RGB images require that the defaultrgb option in begin_page_ext( ) has been set
unless the output intent is an RGB device.
CMYK images require that the defaultcmyk option in begin_page_ext( ) has been set
unless the output intent is a CMYK device.
Scope If the inline option is not provided, the scope is document, page, font, and this function
must always be paired with a matching close_image( ) call. Loading images in document
or font scope instead of page scope offers slight output size advantages.
If the inline option is provided, the scope is page, pattern, template, glyph, and close_
image( ) must not be called.
Params See Table 9.1 and Table 9.2
9.1 Images
143
Table 9.3 Options for load_image( )
key
explanation
alphachannel- (Name string; only for TIFF images; will be ignored if ignoremask=true) Read the alpha channel with the
name
specified name from the image file and apply it as a soft mask to the image. The named channel must be
present in the image file. Default: the first alpha channel in the image
bitreverse
(Boolean; only for imagetype=ccitt) If true, do a bitwise reversal of all bytes in the compressed data.
Default: false
bpc
(Integer; only for imagetype=raw; required in this case) Number of bits per component; must be 1, 2, 4, or
8. In PDF 1.5, bpc=16 is also allowed.
cascadedflate
(Boolean; only for imagetype=jpeg) If true, an additional layer of Flate compression will be applied to
the JPEG-compressed image data. This can reduce output file size in certain cases, e.g. for images with
large areas of the same color. Note that for most types of image content this option will not decrease file
size, and may even result in larger output. Default: false
clippingpathname
(String; only for imagetype=tiff and jpeg; will be ignored if honorclippingpath=false) Read the path
with the specified name from the image file and use it as clipping path. The named path must be present
in the image file. The special name Work Path can be used to address a temporary path created in Photoshop. Default: name of the path which is provided as clipping path in the image file
colorize
(Spot color handle; will be ignored if the iccprofile option is provided) Colorize the image with a spot
color handle, which must have been retrieved with makespotcolor( ). The image must be a black and
white or grayscale image.
components
(Integer; only for imagetype=raw; required in this case) Number of image components (channels); must
be 1, 3, or 4.
copyglobals
(Keyword; only for imagetype=jbig2) Specify which global segments in a JBIG2 stream will be copied to
the PDF. If the JBIG2 stream doesn’t contain any global segments this option will not have any effect (default: current):
all
Copy the global segments for all pages in the JBIG2 stream to the PDF. This should be used if
more than one page from the same JBIG2 stream will be imported. The imagehandle option
should be used if more pages from the same JBIG2 stream will be imported later.
current
Copy only the global segments required for the current page (i.e. the page specified in the
page option) in the JBIG2 stream to the PDF. This should be used if no more pages from the
same JBIG2 stream will be imported.
georeference (Option list; PDF 1.7ext3) Specifies the description of an earth-based coordinate system associated with
the image to use for geospatial measuring; see Section 13.2, »Geospatial Features«, page 205, for details.
height
(Integer; only for imagetype=raw and ccitt; required in this case) Image height in pixels.
honorclippingpath
(Boolean; only for imagetype=tiff and jpeg) Read the clipping path from the image file if available,
and apply it to the image. Default: true
honoriccprofile
(Boolean; only for imagetype=jpeg, png, and tiff; will be set to false if the colorize option is provided)
Read an embedded ICC profile (if any) and apply it to the image. Default: the value of the honoriccprofile parameter.
iccprofile
(ICC handle; only for imagetype=jpeg, jbig2, png, and tiff) Handle of an ICC profile which will be applied to the image. Default: an embedded profile if one is present in the image and
honoriccprofile=true.
iconname
(Hypertext string; will be ignored if inline=true; forces template=true) Attaches a name to the image
so that it can be referenced via JavaScript, e.g. to use the image as an icon for form fields.
ignoremask
(Boolean; must be set to true in PDF/X-1, PDF/X-3, and PDF/A modes for images with an alpha channel)
Ignore transparency information and alpha channels in the image. Default: false
144
Chapter 9: Image and Template Functions (Edition for COM, .NET, and REALbasic)
Table 9.3 Options for load_image( )
key
explanation
ignoreorientation
(Boolean; only for imagetype=tiff) Ignores any orientation tag in the image. This may be useful for
compensating wrong orientation information. Default: false
imagehandle (Image handle; only for imagetype=jbig2) Add a reference to an existing global segment attached to
another image created from the same JBIG2 stream which must have been loaded earlier with the copyglobals=all option. It is an error to refer to an image which has been created from a different file than
the current JBIG2 stream. The specified image handle must not have been closed. Default: no image handle, i.e. a new PDF object will be created with all required global segments for the current page only
inline
(Boolean; only for imagetype=ccitt, jpeg, and raw) If true, the image will be written directly into the
content stream of the page, pattern, template, or glyph description. This option will implicitly call fit_
image( ) and close _image( ) (see PDFlib Tutorial). Using this option is only recommended for bitmap
glyphs of Type 3 fonts. Default: false
interpolate
(Boolean; must be false for PDF/A) Enables image interpolation to improve the appearance on screen
and paper. This is useful for bitmap images for glyph descriptions in Type 3 fonts. Default: false
invert
(Boolean; not for imagetype=jpeg2000 unless mask=true) Inverts the image (swap light and dark colors).
This can be used as a workaround for images which are interpreted differently by applications. Default:
false
K
(Integer; only for imagetype=ccitt) CCITT parameter for compression scheme selection. Default: 0
-1
G4 compression
0
One-dimensional G3 compression (G3-1D)
1
Mixed one- and two-dimensional compression (G3, 2-D)
layer
(Layer handle; PDF 1.5) Layer to which the image will belong unless another layer has been activated with
begin_layer( ) prior to placing the image. Calling begin_layer( ) to activate a layer before placing the
image overrides the image’s layer option. Call end_layer( ) before placing the image to make sure that
the image’s layer option will not be overridden.
mask
(Boolean; only for images with one color component, including indexed color). The image is going to be
used as a mask. This is required for 1-bit masks, but optional for masks with more than 1 bit per pixel.
However, masks with more than 1 bit require PDF 1.4. Default: false. There are two uses for masks:
> Masking another image: The returned image handle may be used in subsequent calls for opening another image and can be supplied for the masked option.
> Placing a colorized transparent image: Treat the 0-bit pixels in the image as transparent, and colorize
the 1-bit pixels with the current fill color.
This option forces ignoremask=true since an image which is used as mask cannot itself have an internal
mask.
masked
(Image handle) Image handle for an image which will be applied as a mask to the current image. The image handle has been returned by a previous call to load_image( ) and has not yet been closed. In PDF 1.3
compatibility mode the mask handle must refer to a 1-bit image and must have been loaded with the
mask option. In PDF/A and PDF/X-1/3 mode this option is only allowed with 1-bit masks.
metadata
(Option list; PDF 1.4) Supply metadata for the image (see Section 14.2, »XMP Metadata«, page 209).
9.1 Images
145
Table 9.3 Options for load_image( )
key
explanation
OPI-1.3
(Option list; not for PDF/A and PDF/X) An option list containing OPI 1.3 PostScript comments as option
names; the following entries are required: ALDImageFilename (string1), ALDImageDimensions (list of integers), ALDImageCropRect (rectangle with integers), ALDImagePosition (list of floats)
The following entries are optional:
ALDImageID (string), ALDObjectComments (string), ALDImageCropFixed (rectangle), ALDImageResolution
(list of floats), ALDImageColorType (keyword; one of Process, Spot, Separation; default: Spot),
ALDImageColor (list of four color values in the range 0...1 and a color name), ALDImageTint (float),
ALDImageOverprint (boolean), ALDImageType (list of integers), ALDImageGrayMap (list of integers),
ALDImageTransparency (boolean), ALDImageAsciiTag (list of integer/string pairs)
The suboption normalizefilename controls the handling of file names: if true, file names will be normalized as mandated by the PDF reference. If false they will be copied to the output without any modification. The latter can be useful to deal with some OPI servers which do not properly process normalized
file names. Default: false
OPI-2.0
(Option list; not for PDF/A and PDF/X) An option list containing OPI 2.0 PostScript comments as option
names; the following entry is required: ImageFilename (string1)
The following entries should either both be present or absent:
ImageCropRect (rectangle), ImageDimensions (list of floats)
The following entries are optional:
MainImage (string), TIFFASCIITag (list of integer/string pairs), ImageOverprint (boolean), ImageInks
(the string full_color, the string registration, or a list containing the string monochrome and string/
float pairs for each colorant name and tint), IncludedImageDimensions (list of integers), IncludedImageQuality (integer with one of the values 1, 2, or 3)
The option normalizefilename is also supported (see OPI-1.3).
page
(Integer; only for imagetype=gif, jbig2, and tiff; must be 1 if used with other formats) Extract the image with the given number from a multi-page image file. The first image has the number 1. The call will
fail if the requested page cannot be found in the image file. Default: 1
passthrough
(Boolean; only for imagetype=tiff or jpeg) Controls handling of TIFF and JPEG image data.
tiff
(Default: true) If true, compressed TIFF image data will be directly passed through to the PDF
output if possible. Setting this option to false may help in cases where a TIFF image contains
damaged or incomplete data.
jpeg
(Default: false) If false, PDFlib will transcode JPEG image data in order to clean up the data
for compatibility with Acrobat. If true, JPEG image data will be directly copied to the PDF
output. This option will be ignored for multiscan and certain CMYK JPEG images. Setting this
option to true may speed up processing, but certain rare JPEG flavors won’t display correctly
in Acrobat.
renderingintent
(Keyword) Rendering intent for the image. See Table 9.1 for a list of possible keywords and their meaning.
Default: the value of the global renderingintent parameter
template
(Boolean) If true, generate a PDF Image XObject embedded in a Form XObject (called template in PDFlib)
instead of a plain Image XObject. This can be useful for creating templates for form field icons which consist of an image only. It is also required for compatibility with certain OPI servers when using one of the
OPI-1.3 or OPI-2.0 options. Default: false. Scope: document
width
(Integer; only for imagetype=raw and ccitt; required in this case) Image width in pixels
1. Windows users keep in mind that a sequence of two backslash characters is required in the option list to create a single backslash in
the resulting path (see »Common traps and pitfalls«, page 9).
146
Chapter 9: Image and Template Functions (Edition for COM, .NET, and REALbasic)
VB RB Sub close_image(image As Long)
C# void close_image(int image)
Close an image.
image
A valid image handle retrieved with load_image( ).
Details This function only affects PDFlib’s associated internal image structure. If the image has
been opened from file, the actual image file is not affected by this call since it has already been closed at the end of the corresponding load_image( ) call. An image handle
cannot be used any more after it has been closed with this function, since it breaks
PDFlib’s internal association with the image.
Scope document, page, font; must always be paired with a matching call to load_image( ) unless
the inline option has been used.
VB RB Sub fit_image(image As Long, x As Double, y As Double, optlist As String)
C# void fit_image(int image, double x, double y, String optlist)
Place an image or template on the page, subject to various options.
image A valid image or template handle retrieved with one of the load_image( ) or
begin_template_ext( ) functions.
x, y The coordinates of the reference point in the user coordinate system where the
image or template will be located, subject to various options.
optlist An option list specifying image fitting and processing options. The following
options are supported:
> Fitting options according to Table 6.1:
boxsize, blind, dpi, fitmethod, matchbox, orientate, position, rotate, scale, showborder
> Options for image processing according to Table 9.4:
adjustpage, gstate, ignoreclippingpath, ignoreorientation
Details The image or template (collectively referred to as an object below) will be placed relative
to the reference point (x, y). By default, the lower left corner of the object will be placed
at the reference point. However, the orientate, boxsize, position, and fitmethod options
can modify this behavior. By default, an image will be scaled according to its resolution
value(s). This behavior can be modified with the dpi, scale, and fitmethod options.
Scope page, pattern (only if the pattern's painttype is 1, or if the image is a mask), template, glyph
(only if the Type 3 font’s colorized option is true, or if the image is a mask); this function
can be called an arbitrary number of times on arbitrary pages, as long as the image
handle has not been closed with close_image( ).
9.1 Images
147
Table 9.4 Options for fit_image( ), fit_pdi_page( ), and fill_*block( )
key
explanation
adjustpage
(Boolean; only effective in page scope; not allowed if the topdown option has been supplied in begin_
page_ext( )) Adjust the dimensions of the current page to the object such that the upper right corner of
the page coincides with the upper right corner of the object plus (x, y) with the function parameters x
and y. The MediaBox will be adjusted, and all other box entries will be reset to their defaults. With the
value 0 for the position option the following useful cases shall be noted:
x >= 0 and y >= 0
The object is surrounded by a white margin. This margin has thickness y in horizontal
direction and thickness x in vertical direction.
x < 0 and y < 0
Horizontal and vertical strips will be cropped from the image.
Default: false
gstate
(Gstate handle) Handle for a graphics state retrieved with create_gstate( ). The graphics state affects all
graphical elements created with this function. Default: no gstate (i.e. current settings will be used)
ignoreclippingpath
(Boolean; only for TIFF and JPEG images) A clipping path which may be present in the image file will be
ignored. Default: false, i.e. the clipping path will be applied
ignoreorientation
(Boolean; only for TIFF images) Ignore any orientation tag in the image. This may be useful for compensating wrong orientation information. Default: the value of the ignoreorientation option in load_
image( )
VB RB Function info_image(image As Long, keyword as String, optlist As String) As Double
C# double info_image(int image, String keyword, String optlist)
Format an image and query metrics and other image properties.
image A valid image or template handle retrieved with one of the load_image( ) or
begin_template_ext( ) functions.
keyword
A keyword specifying the requested information according to Table 9.5.
optlist An option list specifying options for fit_image( ). Options which are not relevant for determining the value of the requested keyword will be ignored.
Returns The value of some image property as requested by keyword. If the requested property is
not available in the image file, the function returns 0. If an object handle is requested
(e.g. clippingpath) this function will return a handle to the object, or -1 if the object is not
available.
Details This function performs all calculations required for placing the image according to the
supplied options, but will not actually create any output on the page. The image reference point is assumed to be {0 0}.
Scope page, pattern, template, glyph, document, path
148
Chapter 9: Image and Template Functions (Edition for COM, .NET, and REALbasic)
Table 9.5 Keywords for info_image( )
keyword
explanation
boundingbox
Path handle of the image’s bounding box
clippingpath
Path handle of the image’s clipping path, or -1 if no clipping path is present
filename
The name of the image file (including a searchpath directory if applicable)
fitscalex, fitscaley
Scaling factors which resulted from fitting the image to a box according to the supplied options
height
Image height in user coordinates according to the supplied options
iccprofile
Handle for the ICC profile embedded in the image or -1 if no profile is present
imageheight
Image height in pixels
imagemask
Image handle of the mask associated with the image, or -1 if no mask is attached
imagetype
String index for the type (format) of the image:
bmp, ccitt, gif, jbig2, jpeg, jpeg2000, png, raw, tiff
imagewidth
Image width in pixels
mirroringx,
mirroringy
Horizontal or vertical mirroring of the image (expressed as 1 or -1) according to the supplied options
orientation
Orientation value of the image. For TIFF images containing an orientation tag the value of this
tag will be returned; in all other cases 1 will be returned. PDFlib will automatically compensate
orientation values different from 1.
resx, resy
Horizontal or vertical resolution of the image. Positive values represent the image resolution in
pixels per inch (dpi). The value zero means that the resolution is unknown. Negative values can be
used together to determine the aspect ratio of non-square pixels, but don’t have any absolute
meaning.
strips
Number of image strips (will be different from 1 only for certain multi-strip TIFF images)
targetbox
(Only if the reference option has been supplied to open_pdi_page( )) Path handle for the target
page’s bounding box (see targetx1 etc.)
targetx1, targety1,
targetx2, targety2,
targetx3, targety3,
targetx4, targety4
(Only if the reference option has been supplied to begin_template_ext( )) Position of the i-th
rectangle corner (i=1, 2, 3, 4) of the bounding box of the target page in user coordinates. These
values will be calculated according to the page box selected with the pdiusebox option of the
reference option.
width
Image width in user coordinates according to the supplied options
x1, y1, x2, y2,
x3, y3, x4, y4
Position of the i-th rectangle corner (i=1, 2, 3, 4) of the image bounding box in user coordinates according to the supplied options
9.1 Images
149
9.2 Templates
Note The template functions described in this section are unrelated to variable data processing with
PDFlib blocks. Use fill_textblock( ), fill_imageblock( ), and fill_pdfblock( ) to fill blocks prepared
with the PDFlib Block plugin (see Chapter 11, »Block Filling Functions (PPS)«, page 167).
VB RB Function begin_template_ext(width As Double, height As Double, optlist As String) As Long
C# int begin_template_ext(double width, double height, String optlist)
Start a template definition.
width, height The dimensions of the template’s bounding box in points. The width
and height parameters can be 0. In this case they must be supplied in end_template_
ext( ). If the topdown option is set to true, height must be different from 0.
optlist Option list specifying template-related properties.
> The following options of load_image( ) can be used (see Table 9.3):
iconname, layer, metadata, OPI-1.3, OPI-2.0
> The following options of begin_page_ext( ) can be used (see Table 3.7):
topdown, transparencygroup
> The reference option (see Table 9.6).
Returns A template handle which can be used in subsequent image-related calls (especially fit_
image( )), or -1 in case of an error.
Details This function will reset all text, graphics, and color state parameters to their defaults,
and establish a coordinate system according to the global topdown parameter.
Hypertext functions and functions for opening images must not be used during a
template definition, but all text, graphics, and color functions can be used.
Scope document, page; this function starts template scope, and must always be paired with a
matching end_template_ext( ) call.
Table 9.6 Options for begin_template_ext( )
key
explanation
reference
(Option list; not available in PDFlib source code packages; PDF 1.4, but requires Acrobat 9 or above for
proper page rendering; not allowed in PDF/X-1/2/3/4, and PDF/A-1 modes) Specify a reference to a page
in an external PDF (the »target« document). The page or template will be used as a proxy for this reference. Depending on viewer configuration and availability of the target PDF either the internal proxy or
the external target will be displayed and printed. See Table 9.7 for available suboptions.
The target must be available locally and must contain the page addressed with the pagelabel or
pagenumber suboption. The target must not require a user or master password. The size of the reference
page will be determined according to the pdiusebox suboption of the reference option. It can be retrieved with the targetx1, targety1 etc. keywords of info_image( )and info_pdi_page( ), and must be
honored when constructing the proxy template or placing the proxy PDI page.
In PDF/X-5g or PDF/X-5pg mode the target must conform to one of the following standards: PDF/X1a:2003, PDF/X-3:2002, PDF/X-4, PDF/X-4p, PDF/X-5g, or PDF/X-5pg, and must have been prepared for
the same output intent.
150
Chapter 9: Image and Template Functions (Edition for COM, .NET, and REALbasic)
Table 9.7 Suboptions for the reference option in begin_template_ext( ) and open_pdi_page( )
key
explanation
filename
(Name string; required) Name of the file containing the target PDF. This name will be stored in the PDF
and used by the viewer. It will also be used to locate the target PDF locally (i.e. the PDF must exist) unless
the target option has been supplied. It is recommended to use plain base names without any directories.
pagelabel
(Hypertext string; must not be combined with pagenumber) Page label of the page to be referenced
pagenumber (Integer) The number of the page to be referenced. The first page has page number 1. Default: 1 (this may
be overwritten by pagelabel, however).
pdiusebox
(Keyword; will be forced to media in PDF/X-5g and PDF/X-5pg mode) Specifies which box dimensions will
be used for determining the size of the target page. Default: media in PDF/X-5g and PDF/X-5pg mode, else
crop.
media
Use the MediaBox (which is always present)
crop
Use the CropBox if present, else the MediaBox
bleed
Use the BleedBox if present, else the CropBox
trim
Use the TrimBox if present, else the CropBox
art
Use the ArtBox if present, else the CropBox
strongref
(Boolean; will be forced to true in PDF/X-5g and PDF/X-5pg mode) If true, PDFlib will use the target’s ID
entry to create a strong reference to the target. The reference will break (i.e. the viewer will use the proxy)
if the target is replaced with another document. If the flexibility of swapping targets is desired, this option must be set to false, and the local target and the target which is ultimately used for rendering the
document must have identical page boxes and rotation entries. Default: true
target
(PDF document handle) A handle to the target document retrieved with open_pdi_document( ). The target PDF must have been opened with the repair=none option and without the password option. Supplying a document handle in addition to the filename may be useful in two situations:
> If many generated documents reference the same target PDF, the target must be opened only once
and the results can be cached internally.
> The filename of the local target is different from the target filename to be stored in the PDF.
VB RB Sub end_template_ext(width As Double, height As Double)
C# void end_template_ext(double width, double height)
Finish a template definition.
width, height The dimensions of the template’s bounding box in points. If width or
height is 0, the value supplied in begin_template_ext( ) will be used. Otherwise the value
supplied in begin_template_ext( ) will be overwritten.
Scope template; this function terminates template scope, and must always be paired with a
matching begin_template_ext( ) call.
9.2 Templates
151
VB RB Sub end_template( )
C# void end_template( )
Deprecated, use end_template_ext( ).
VB RB Function begin_template(width As Double, height As Double) As Long
C# int begin_template(double width, double height)
Deprecated, use begin_template_ext( ).
152
Chapter 9: Image and Template Functions (Edition for COM, .NET, and REALbasic)
9.3 Thumbnails
VB RB Sub add_thumbnail(image As Long)
C# void add_thumbnail(int image)
Add an image as thumbnail for the current page.
image
A valid image handle retrieved with load_image( ).
Details This function adds the supplied image as thumbnail image for the current page. A
thumbnail image must adhere to the following restrictions:
> The image must be no larger than 106 x 106 pixels.
> The image must use the grayscale, RGB, or indexed RGB color space.
> Multi-strip TIFF images can not be used as thumbnails because thumbnails must be
constructed from a single PDF image object.
This function doesn’t generate thumbnail images for pages, but only offers a hook for
adding existing images as thumbnails. The actual thumbnail images must be generated
by the client. The client must ensure that color, height/width ratio, and actual contents
of a thumbnail match the corresponding page contents.
Since Acrobat and Adobe Reader generate thumbnails on the fly, and thumbnails increase the overall file size of the generated PDF, it is recommended not to add thumbnails, but rely on client-side thumbnail generation instead.
Scope page; must only be called once per page. Not all pages need to have thumbnails attached
to them.
9.3 Thumbnails
153
154
Chapter 9: Image and Template Functions (Edition for COM, .NET, and REALbasic)
10 PDF Import (PDI) and pCOS Functions
Note All functions described in this chapter require the PDF import library (PDI) which is included in
PDFlib+PDI and PDFlib Personalization Server (PPS), but not in the base PDFlib product. Please
visit our Web site for more information on obtaining PDI.
10.1 Document Functions
Cookbook A full code sample can be found in the Cookbook topic pdf_import/starter_pdfmerge.
Table 10.1 lists relevant parameter key names for this section (see Section 2.2, »Parameter and Option Handling«, page 18).
Table 10.1 PDI-related keys for get/set_parameter( )
key
pdi
1
explanation
Returns the string true if PDI has been included when building the underlying library. This is true for all
combined PDFlib, PDFlib+PDI, and PPS binaries distributed by PDFlib GmbH, regardless of the license key.
Otherwise it returns false. Scope: any, null
1. Only for get_parameter( )
VB RB Function open_pdi_document(filename As String, optlist As String) As Long
C# int open_pdi_document(String filename, String optlist)
Open a disk-based or virtual PDF document and prepare it for later use.
filename (Name string; will be interpreted according to the global filenamehandling option or parameter, see Table 2.2) The name of the PDF file.
optlist An option list specifying PDF open options:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> PDF document options according to Table 10.2: infomode, inmemory, password, repair,
requiredmode
Returns A PDI document handle which can be used for processing individual pages of the document or for querying document properties. A return value of -1 indicates that the PDF
document couldn’t be opened. An arbitrary number of PDF documents can be opened
simultaneously. The return value can be used until the end of the enclosing document
scope. If the function call fails you can request the reason of the failure with get_
errmsg( ).
The error behavior can be changed with the errorpolicy parameter or option.
Details By default, the document will be rejected if at least one of the following conditions is
true:
> The document is damaged and couldn’t be repaired (or repair=none was specified).
> The document uses a PDF version which is incompatible to the current PDF document. For PDF versions up to PDF 1.6 all versions up to and including the same version are compatible. For PDF 1.7 and 1.7 extension level 3 all versions up to PDF 1.7,
PDF 1.7 extension level 3 (Acrobat 9), and PDF 1.7 extension level 8 (Acrobat X) are
compatible (note that Acrobat X encryption is not yet supported). However, in PDF/A
10.1 Document Functions
155
mode the input PDF version number will be ignored since PDF version headers must
be ignored in PDF.
> The document is encrypted, but the corresponding password has not been supplied
in the password option.
> The document is not compatible to the current PDF/X or PDF/A output conformance
level, or uses an incompatible output intent.
> The document is Tagged PDF, and the tagged option in begin_document( ) is true.
Except for the first reason, the infomode option can be used to open the document nevertheless. This may be useful to query information about the PDF using the pcos_get_*( )
functions, such as encryption, PDF/A or PDF/X status, document info fields, etc.
In order to get more detailed information about the nature of a PDF import-related
problem (wrong PDF file name, unsupported format, bad PDF data, etc.), use get_
errmsg( ) to receive a more detailed error message.
PDF/A: the imported document must be compatible to the current PDF/A output
conformance level and output intent unless infomode=true.
PDF/X: the imported document must be compatible to the current PDF/X output
conformance level unless infomode=true, and must use the same output intent as the
generated document.
Scope any; in object scope a PDI document handle can only be used in the pcos_get_*( )
functions.
Table 10.2 Options for open_pdi_document( )
key
explanation
infomode
(Boolean) If true, the document will be opened such that information can be queried with the pCOS interface, but the pages can not be imported into the current output document. In particular, the following
kinds of documents can be opened when infomode=true:
> PDFs which are not compatible to the current PDF/X or PDF/A conformance level
> PDFs with a higher PDF version than the current document
> Encrypted PDFs where the password is not known (exception: PDF 1.6 documents created with the Distiller setting »Object Level Compression: Maximum«)
> Tagged PDF when the tagged option in begin_document( ) is true
Default: false if requiredmode=full, otherwise true
inmemory
(Boolean) If true, PDI will load the complete file into memory and process it from there. This can result in
a tremendous performance gain on some systems (especially MVS) at the expense of memory usage. If
false, individual parts of the document will be read from disk as needed. Default: false
password
(String with a maximum length of 32 characters) Master password required to open a protected PDF document for import. If infomode=true the user password (which may even be empty) is sufficient to query
document information. If no password has been supplied at all for an encrypted document the document
handle can only be used to query its encryption status.
repair
(Keyword) Specifies how to treat damaged PDF input documents. Repairing a document takes more time
than normal parsing, but may allow processing of certain damaged PDFs. Note that some documents
may be damaged beyond repair. Supported keywords (default: auto):
156
auto
Repair the document only if problems are detected while opening the PDF.
force
Unconditionally try to repair the document, regardless of whether or not it has problems.
none
No attempt will be made at repairing the document. If there are problems in the PDF the
function call will fail.
Chapter 10: PDF Import (PDI) and pCOS Functions (Edition for COM, .NET, and REALbasic)
Table 10.2 Options for open_pdi_document( )
key
explanation
requiredmode
(Keyword) The minimum pcos mode (minimum/restricted/full) which is acceptable when opening
the document. The call will fail if the resulting pcos mode would be lower than the required mode. If the
call succeeds it is guaranteed that the resulting pcos mode is at least the one specified in this option.
However, it may be higher; e.g. requiredmode=minimum for an unencrypted document will result in full
mode. Default: full
VB RB Sub close_pdi_document(doc As Long)
C# void close_pdi_document(int doc)
Close all open PDI page handles, and close the input PDF document.
doc
A valid PDF document handle retrieved with open_pdi_document( ).
Details This function closes a PDF import document, and releases all resources related to the
document. All document pages which may be open are implicitly closed. The document
handle must not be used after this call. A PDF document should not be closed if more
pages are to be imported. Although you can open and close a PDF import document an
arbitrary number of times, doing so may result in unnecessary large PDF output files.
Scope any
10.1 Document Functions
157
10.2 Page Functions
VB RB Function open_pdi_page(doc As Long, pagenumber As Long, optlist As String) As Long
C# int open_pdi_page(int doc, int pagenumber, String optlist)
Prepare a page for later use with fit_pdi_page( ).
doc
A valid PDF document handle retrieved with open_pdi_document( ).
pagenumber
The number of the page to be opened. The first page has page number 1.
optlist An option list specifying page-specific options:
> General option: errorpolicy (see Table 2.6)
> Page options according to Table 10.3:
clippingarea,cloneboxes, iconname, layer, metadata, pdiusebox, reference
> The following option of begin_page_ext( ) (see Table 3.7): transparencygroup
Returns A page handle which can be used for placing pages with fit_pdi_page( ). A return value of
-1 indicates that the page couldn’t be opened. If the function call fails you can request
the reason of the failure with get_errmsg( ). The returned handle can be used until the
end of the enclosing document scope. If the infomode option was true when the document has been opened with open_pdi_document( ), the handle can not be used with fit_
pdi_page( ).
The error behavior can be changed with the errorpolicy parameter or option.
Details This function will copy all data comprising the imported page to the output document,
but will not have any visible effect on the output. In order to actually place the imported page somewhere in the generated output document, fit_pdi_page( ) must be used.
This function will fail if the PDF version number of the imported document is higher
than the PDF version number of the generated PDF output document. In order to get
more detailed information about a problem related to PDF import (unsupported format, bad PDF data, etc.) you can call get_errmsg( ).
If the imported page contains referenced XObjects, open_pdi_page( ) will copy both
proxy and reference to the target.
An arbitrary number of pages can be opened simultaneously. If the same page is
opened multiply, different handles will be returned, and each handle must be closed exactly once.
PDF/A and PDF/X: this call may fail if the document containing the imported page
uses an output intent which is incompatible to the generated document.
Scope document, page
VB RB Sub close_pdi_page(page As Long)
C# void close_pdi_page(int page)
Close the page handle and free all page-related resources.
page
A valid PDF page handle (not a page number!) retrieved with open_pdi_page( ).
Details This function closes the page associated with the page handle identified by page, and releases all related resources. page must not be used after this call.
158
Chapter 10: PDF Import (PDI) and pCOS Functions (Edition for COM, .NET, and REALbasic)
Table 10.3 Options for open_pdi_page( )
key
explanation
clippingarea
(Keyword) Specify which of the page boxes of the imported page will be used for clipping. Content outside the specified area will not be visible after placing the imported page on a new page. Supported keywords (default: pdiusebox):
art
Use the ArtBox if present, else the CropBox
bleed
Use the BleedBox if present, else the CropBox
crop
Use the CropBox if present, else the MediaBox
media
Use the MediaBox (which is always present)
pdiusebox Use the box specified in the pdiusebox option
trim
Use the TrimBox if present, else the CropBox
cloneboxes
(Boolean; not allowed if pdiusebox is supplied; must match the cloneboxes option in fit_pdi_page( )) If
true, the page will be prepared for box cloning with the cloneboxes option of fit_pdi_page( ). Default:
false
iconname
(Hypertext string) Attach a name to the imported page so that it can be referenced via JavaScript, e.g. to
use the page as an icon for form fields.
layer
(Layer handle; PDF 1.5) Layer to which the page will belong unless another layer has been activated with
begin_layer( ) prior to placing the page. Calling begin_layer( ) to activate a layer before placing the page
overrides the page’s layer option. Call end_layer( ) before placing the page to make sure that the page’s
layer option will not be overridden.
metadata
(Option list; PDF 1.4) Supply metadata for the imported page (see Section 14.2, »XMP Metadata«, page
209)
pdiusebox
(Keyword; not allowed if cloneboxes is supplied) Specifies which box dimensions will be used for determining an imported page’s size. The box size will be used for scaling operations in fit_pdi_page( ). This
box will also determine the visible contents of the page unless modified with the clippingarea option.
Default: crop.
reference
art
Use the ArtBox if present, else the CropBox
bleed
Use the BleedBox if present, else the CropBox
crop
Use the CropBox if present, else the MediaBox
media
Use the MediaBox (which is always present)
trim
Use the TrimBox if present, else the CropBox
(Option list; PDF 1.4, but requires Acrobat 9 or above for proper page rendering) Define the page as a
proxy which carries a reference to a page in an external PDF document (the target page). The page
opened with the current call will be used as a proxy for the referenced target page (see Table 9.6 for details). The proxy page and the target page must have compatible page geometry, i.e. the page boxes selected with the pdiusebox option must be identical to make sure that both pages will be placed at the
same location on the page.
Scope document, page
VB RB Sub fit_pdi_page(page As Long, x As Double, y As Double, optlist As String)
C# void fit_pdi_page(int page, double x, double y, String optlist)
Place an imported PDF page on the output page subject to various options.
page A valid PDF page handle (not a page number!) retrieved with open_pdi_page( ).
The infomode option must have been false when opening the document. The page handle must not have been closed.
10.2 Page Functions
159
x, y The coordinates of the reference point in the user coordinate system where the
page will be located, subject to various options.
optlist An option list specifying page options:
> Fitting options according to Table 6.1:
blind, boxsize, fitmethod, matchbox, orientate, position, rotate, scale, showborder
> Options for page processing according to Table 9.4: adjustpage, gstate
> The cloneboxes option according to Table 10.4.
Details This function is similar to fit_image( ), but operates on imported PDF pages instead. The
following option for begin/end_page_ext( ) is recommended to improve the output quality if an imported page contains ExtGState objects:
transparencygroup={colorspace=DeviceRGB}.
Scope page, pattern, template, glyph
Table 10.4 Additional option for fit_pdi_page( )
key
explanation
cloneboxes
(Boolean; not allowed if the topdown option has been supplied in begin_page_ext( ); must match the
cloneboxes option in open_pdi_page( ); only in page scope).
Setting this option to true has the following consequences (Default: false):
> All of the Rotate, MediaBox, TrimBox, ArtBox, BleedBox and CropBox entries which are present in the
imported page will be copied to the current output page.
> The page contents will be placed such that the input page is duplicated; the user cannot change position or size of the placed page. The parameters x, y and the following options will therefore be ignored:
adjustpage, boxsize, fitmethod, orientate, position, rotate, scale. Duplication of the input page
is only possible if the default coordinate system is active when calling fit_pdi_page( ).
> Page boxes created by the cloneboxes option overrides the artbox, bleedbox, cropbox, trimbox,
mediabox, and rotate options as well as the width and height parameters of begin_page_ext( ).
VB RB Function info_pdi_page(page As Long, keyword as String, optlist As String) As Double
C# double info_pdi_page(int page, String keyword, String optlist)
Perform formatting calculations for a PDI page and query the resulting metrics.
page
A valid page handle retrieved with open_pdi_page( ).
keyword
A keyword specifying the requested information according to Table 10.5.
optlist An option list specifying scaling and placement details:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Fitting options according to Table 6.1 (if the PDF page has been opened with the
cloneboxes option of open_pdi_page( ) these options will be ignored):
boxsize, fitmethod, matchbox, orientate, position, rotate, scale
> Options for page processing according to Table 9.4 don’t make sense; they will be ignored to facilitate unified option lists for fit_pdi_page( ) and info_pdi_page( ):
adjustpage, gstate
Returns The value of some page metrics as requested by keyword. If errorpolicy=return this function will return 0 in case of an error. If errorpolicy=exception this function will throw an
exception in case of an error.
160
Chapter 10: PDF Import (PDI) and pCOS Functions (Edition for COM, .NET, and REALbasic)
Details This function performs all calculations required for placing the imported page according to the supplied options, but will not actually create any output on the page. The reference point for placing the page is assumed to be {0 0}. If the cloneboxes option of open_
pdi_page( ) has been supplied, the page will be placed on the same location (relative to
the page boxes) as in the original page.
Scope page, pattern, template, glyph, document, path
Table 10.5 Keywords for info_pdi_page( )
keyword
explanation
boundingbox
Path handle for the page’s bounding box
fitscalex, fitscaley
Scaling factors which resulted from fitting the page to a box according to the supplied options
height
Page height in user coordinates according to the supplied options
mirroringx,
mirroringy
Horizontal or vertical mirroring of the page (expressed as 1 or -1) according to the supplied options
pageheight
Original page height in points
pagewidth
Original page width in points
rotate
If cloneboxes=true: the rotation angle of the imported page in degrees, i.e. the value of the
page’s Rotate key. Possible values are 0, 90, 180, and 270).
If cloneboxes=false: always 0
width
Page width in user coordinates according to the supplied options
x1, y1, x2, y2,
x3, y3, x4, y4
Position of the i-th rectangle corner (i=1, 2, 3, 4) of the page bounding box in user coordinates according to the supplied options.
If cloneboxes=true the visible box will be used (i.e. the CropBox if present, else the MediaBox).
10.2 Page Functions
161
10.3 Other PDI Processing
VB RB Function process_pdi(doc As Long, page As Long, optlist As String) As Long
C# int process_pdi(int doc, int page, String optlist)
Process certain elements of an imported PDF document.
doc
A valid PDF document handle retrieved with open_pdi_document( ).
page If optlist requires a page handle (see Table 10.6), page must be a valid PDF page
handle (not a page number!) retrieved with open_pdi_page( ). The page handle must not
have been closed. If optlist does not require any page handle, page must be -1.
optlist An option list specifying PDI processing options:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> PDI processing options according to Table 10.6. The following option can be used:
action
Returns The value 1 if the function succeeded, or an error code of -1 if the function call failed. If
errorpolicy=exception this function will throw an exception in case of an error.
Details PDF/X: the output intent must be set either using this function with the copyoutputintent option, or with load_iccprofile( ).
PDF/A: the output intent can be set using this function with the copyoutputintent
option, or with load_iccprofile( ). However, if only device-independent colors are used in
the document no output intent is required.
Scope document
Table 10.6 Options for process_pdi( )
key
explanation
action
(Keyword; required; this option does not require a page handle) Specifies the kind of PDF processing:
copyoutputintent
Copy the PDF/X or PDF/A output intent ICC profile of the imported document to the output
document. The second and subsequent attempts to copy an output intent will be ignored. If
the document contains more than one output intent the first one will be used. Standard
output intents (without an embedded ICC profile) cannot be copied with this method.
If the input and output documents conform to PDF/X-4p or PDF/X-5pg the reference to the
external output intent ICC profile will be copied. The option action=copyoutputintent is not
allowed if the input conforms to PDF/X-4p or PDF/X-5pg, but not the output.
162
Chapter 10: PDF Import (PDI) and pCOS Functions (Edition for COM, .NET, and REALbasic)
10.4 pCOS Functions
All pCOS functions work with paths designating the target object in the PDF document.
pCOS paths are discussed in detail in the pCOS Path Reference.
Cookbook A full code sample for using pCOS within PDFlib+PDI or PPS can be found in the Cookbook topic
pdf_import/starter_pcos. A large number of pCOS programming samples is available in the
pCOS Cookbook.
Note In evaluation mode pCOS will accept input documents up to a maximum of 1 MB or 10 pages.
However, the following elements can also be queried for larger documents in evaluation
mode: page count, page dimensions, Block details, and all universal pseudo objects.
VB RB Function pcos_get_number(doc as Long, path As String) As Double
C# double pcos_get_number(int doc, String path)
Get the value of a pCOS path with type number or boolean.
doc
path
A valid document handle obtained with open_pdi_document( ).
A full pCOS path for a numerical or boolean object.
Returns The numerical value of the object identified by the pCOS path. For Boolean values 1 will
be returned if they are true, and 0 otherwise.
Scope any
VB RB Function pcos_get_string(doc as Long, path As String) As String
C# String pcos_get_string(int doc, String path)
Get the value of a pCOS path with type name, string, or boolean.
doc
path
A valid document handle obtained with open_pdi_document( ).
A full pCOS path for a name, string, or boolean object.
Returns A string with the value of the object identified by the pCOS path. For Boolean values the
strings true or false will be returned.
Details This function will raise an exception if pCOS does not run in full mode and the type of
the object is string. As an exception, the objects /Info/* (document info keys) can also be
retrieved in restricted pCOS mode if nocopy=false or plainmetadata=true, and
bookmarks[...]/Title and annots[...]/contents can be retrieved in restricted pCOS mode if
nocopy=false.
This function assumes that strings retrieved from the PDF document are text strings.
String objects which contain binary data should be retrieved with pcos_get_stream( ) instead which does not modify the data in any way.
Scope any
Bindings COM: the result will be provided as Unicode string in UTF-16 format. If no more text is
available an empty string will be returned.
.NET: the result will be provided as Unicode string. If no more text is available a null object will be returned.
10.4 pCOS Functions
163
VB RB Function pcos_get_stream(doc as Long, optlist As String, path As String)
C# final byte[ ] pcos_get_stream(int doc, String optlist, String path)
Get the contents of a pCOS path with type stream, fstream, or string.
doc
A valid document handle obtained with open_pdi_document( ).
length (C and C++ language bindings only) A pointer to a variable which will receive
the length of the returned stream data in bytes.
optlist
An option list specifying stream retrieval options according to Table 10.7.
path A full pCOS path for a stream or string object.
Returns The unencrypted data contained in the stream or string. The returned data will be empty if the stream or string is empty.
If the object has type stream, all filters will be removed from the stream contents (i.e.
the actual raw data will be returned) unless keepfilter=true. If the object has type fstream
or string the data will be delivered exactly as found in the PDF file, with the exception of
ASCII85 and ASCIIHex filters which will be removed.
Details This function will throw an exception if pCOS does not run in full mode. As an exception, the object /Root/Metadata can also be retrieved in restricted pCOS mode if nocopy=
false or plainmetadata=true. An exception will also be thrown if path does not point to an
object of type stream, fstream, or string.
Despite its name this function can also be used to retrieve objects of type string. Unlike pcos_get_string( ), which treats the object as a text string, this function will not modify the returned data in any way. Binary string data is rarely used in PDF, and cannot be
reliably detected automatically. The user is therefore responsible for selecting the appropriate function for retrieving string objects as binary data or text.
Scope any
Bindings COM: Most client programs will use the Variant type to hold the stream contents. JavaScript with COM does not allow to retrieve the length of the returned variant array (but
it does work with other languages and COM).
Note This function can be used to retrieve embedded font data from a PDF. Users are reminded that
fonts are subject to the respective font vendor’s license agreement, and must not be reused
without the explicit permission of the respective intellectual property owners. Please contact
your font vendor to discuss the relevant license agreement.
164
Chapter 10: PDF Import (PDI) and pCOS Functions (Edition for COM, .NET, and REALbasic)
Table 10.7 Options for pcos_get_stream( )
option
description
convert
(Keyword; will be ignored for streams which are compressed with unsupported filters) Controls
whether or not the string or stream contents will be converted (default: none):
keepfilter
none
Treat the contents as binary data without any conversion.
unicode
Treat the contents as textual data (i.e. exactly as in pcos_get_string( )), and normalize
it to Unicode. In non-Unicode-aware language bindings this means the data will be
converted to UTF-8 format without BOM.
This option is required for the data type »text stream« in PDF which is rarely used (e.g.
it can be used for JavaScript, although the majority of JavaScripts is contained in
string objects, not stream objects).
(Boolean; recommended only for image data streams; will be ignored for streams which are compressed with unsupported filters) If true, the stream data will be compressed with the filter
which is specified in the image’s filterinfo pseudo object. If false, the stream data will be uncompressed. Default: true for all unsupported filters, false otherwise
10.4 pCOS Functions
165
166
Chapter 10: PDF Import (PDI) and pCOS Functions (Edition for COM, .NET, and REALbasic)
11 Block Filling Functions (PPS)
The PDFlib Personalization Server (PPS) offers dedicated functions for processing variable Blocks of type Text, Image, and PDF. These PDFlib Blocks must be contained in the
imported PDF page, but will not be retained in the generated output. The imported page
must have been placed on the output page with fit_pdi_page( ) before using any of the
Block filling functions. When calculating the Block position on the page, the Block functions will take into account the scaling options which have been in effect when placing
the imported page with fit_pdi_page( ).
Note The Block processing functions discussed in this chapter require the PDFlib Personalization
Server (PPS). The PDFlib Block plugin for Adobe Acrobat is required for creating PDFlib Blocks in
PDF templates.
Cookbook A full code sample can be found in the Cookbook topic blocks/starter_block.
11.1 Rectangle Options for Block Filling Functions
Table 11.1 lists rectangle options for fill_textblock( ), image_block( ), and fill_pdfblock( ). Options which are specific for a particular Block type (i.e. text, image, or PDF Blocks) are
listed in the next sections. Almost all Block properties can be overridden with options
with the same name, except for the following properties which can not be overridden
with options:
Name, Description, Subtype, Type
defaulttext, defaultimage, defaultpdf, defaultpdfpage
Table 11.1 Rectangle options for the fill_*block( ) functions
key
explanation
Rect
(Rectangle) The coordinates of the Block in the coordinate system of the Block PDF. The Block rectangle
can be specified with the refpoint and boxsize options (in user coordinates).
Status
(Keyword) Describes how the Block will be processed (default: active):
active
The Block will be fully processed according to its properties.
ignore
The Block will be ignored.
ignoredefault
Like active, except that the defaulttext/image/pdf properties will be ignored, i.e. the Block
remains empty if no default contents have been provided. This may be useful to make sure
that the Block’s default contents will not be used for filling Blocks on the server side although
the Block may contain default contents for the Preview in the Block Plugin. It can also be used
to disable the default contents for previewing a Block without removing it from the Block
properties.
static
No variable contents will be placed; instead, the Block’s default text, image, or PDF contents
will be used if available.
background- (Color) Fill color for the Block; this color will be applied before filling the Block. This may be useful to cover
color
existing page contents. Default: none
bordercolor
(Color) Border color for the Block; this color will be applied before filling the Block. Default: none
linewidth
(Float; must be greater than 0) Stroke width of the line used to draw the Block rectangle; only used if
bordercolor is set. Default: 1
11.1 Rectangle Options for Block Filling Functions
167
11.2 Textline and Textflow Blocks
VB RB Function fill_textblock(page As Long, blockname As String, text As String, optlist As String) As Long
C# int fill_textblock(int page, String blockname, String text, String optlist)
Fill a Textline or Textflow Block with variable data according to its properties.
page A valid PDF page handle for a page containing PDFlib Blocks. The input PDF page
with Blocks must have been placed on the page earlier, either directly with fit_pdi_
page( ), indirectly in a table cell with fit_table( ), or as contents of a PDF Block with fill_
pdfblock( ).
blockname
(Name string) The name of the Block.
text (Content string) The text to be filled into the Block, or an empty string if the default text (as defined by Block properties) is to be used. If the textflowhandle option is
supplied and contains a valid Textflow handle this parameter will be ignored.
optlist An option list specifying text Block filling options. The following options are
supported:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Rectangle options for Block filling functions according to Table 11.1:
Rect, Status, backgroundcolor, bordercolor, linewidth
> Fitting options (see Section 6.1, »Object Fitting«, page 99)
> Textline Blocks, i.e. the textflow property or option is false:
all Textline options (see Section 5.2, »Single-Line Text with Textlines«, page 71);
> Textflow Blocks, i.e. the textflow property or option is true:
all options for add/create_textflow( ) (see Section 5.3, »Multi-Line Text with Textflows«, page 75)) and all options for fit_textflow( ) (see Table 5.14)
> Text Block options according to Table 11.2: textflow, textflowhandle
Returns -1 if the named Block doesn’t exist on the page, the Block cannot be filled (e.g. due to
font problems), or the Block requires a newer PDFlib version for processing; 1 if the Block
could be processed successfully. If the textflowhandle option is supplied a valid Textflow
handle will be returned which can be used in subsequent calls.
If the PDF document is found to be corrupt, this function will either throw an exception or return -1 subject to the errorpolicy parameter or option.
Details The supplied text will be formatted into the Block, subject to the Block’s properties. If
text is empty the function will use the Block’s default text if available (unless Status=
ignoredefault), and silently return otherwise. This may be useful to take advantage of
other Block properties, such as fill or stroke color.
Font selection: If neither the font option is supplied nor implicit font loading based
on options is used, the font will be implicitly loaded based on the Block properties. Since
the encoding for the font can only be specified as an option, but not as a Block property
it will be set as follows by default:
> builtin if the font is a symbolic font and charref=false.
> unicode otherwise.
It is recommended to avoid the encoding, charref and textformat options if defaulttext is
to be used.
168
Chapter 11: Block Filling Functions (PPS) (Edition for COM, .NET, and REALbasic)
Special care should be taken regarding the embedding option: if the font is implicitly
loaded based on Block properties it will not automatically be embedded. If font embedding is desired the embedding option must be specified.
Linking Textflow Blocks: If a Textflow doesn’t fit into a Block, the textflowhandle option can be used to connect multiple Blocks to a chain so that they hold multiple parts
of the same Textflow:
> In the first call a value of -1 must be supplied. The Textflow handle created internally
will be returned by fill_textblock( ), and must be stored by the user.
> In the next call the Textflow handle returned in the previous step can be supplied to
the textflowhandle option (the text supplied in the text parameter will be ignored in
this case, and should be empty). The Block will be filled with the remainder of the
Textflow.
> This process can be repeated with more Textflow Blocks.
> The returned Textflow handle can be supplied to info_textflow( ) in order to determine the results of Block filling, e.g. the end position of the text.
This process can be repeated an arbitrary number of times. The user is responsible for
deleting the Textflow handle with delete_textflow( ) at the end.
Scope page, template
Table 11.2 Additional options for fill_textblock( )
key
explanation
textflow
(Boolean) Control single- or multiline processing. This property can be used to switch between Textline
and Textflow Blocks:
false
Text can span a single line and will be processed with fit_textline( ).
true
Text can span multiple lines and will be processed with fit_textflow( ).
The default depends on the Block type: true for Textflow Blocks, and false for Textline Blocks
textflowhandle
(Textflow handle; only for fill_textblock( ) with textflow=true) This option can be used for Textflow
Block chaining. For the first Block in a chain of Blocks a value of -1 must be supplied; the value returned by
this function can be supplied as Textflow handle in subsequent calls for other Blocks in the chain. This option will change the default of fitmethod to clip.
11.2 Textline and Textflow Blocks
169
11.3 Image Blocks
VB RB Function fill_imageblock(
page As Long, blockname As String, image As Long, optlist As String) As Long
C# int fill_imageblock(int page, String blockname, int image, String optlist)
Fill an image Block with variable data according to its properties.
page A valid PDF page handle for a page containing PDFlib Blocks. The input PDF page
with Blocks must have been placed on the page earlier, either directly with fit_pdi_
page( ), indirectly in a table cell with fit_table( ), or as contents of a PDF Block with fill_
pdfblock( ).
blockname
(Name string) The name of the Block.
image A valid image handle for the image to be filled into the Block, or -1 if the default
image (as defined by Block properties) is to be used.
optlist An option list specifying text Block filling options. The following options are
supported:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Rectangle options for Block filling functions according to Table 11.1:
Rect, Status, backgroundcolor, bordercolor, linewidth
> Fitting options (see Section 6.1, »Object Fitting«, page 99)
> Options for image processing according to Table 9.4.
Returns -1 if the named Block doesn’t exist on the page, the Block cannot be filled, or the Block
requires a newer PDFlib version for processing; 1 if the Block could be processed successfully. Use get_errmsg( ) to get more information about the nature of the problem.
Details The image referred to by the supplied image handle will be placed in the Block, subject
to the Block’s properties. If image is -1 the function will use the Block’s default image if
available (unless Status=ignoredefault), and silently return otherwise.
If the PDF document is found to be corrupt, this function will either throw an exception or return -1 subject to the errorpolicy parameter or option.
Scope page, template
170
Chapter 11: Block Filling Functions (PPS) (Edition for COM, .NET, and REALbasic)
11.4 PDF Blocks
VB RB Function fill_pdfblock(
page As Long, blockname As String, contents As Long, optlist As String) As Long
C# int fill_pdfblock(int page, String blockname, int contents, String optlist)
Fill a PDF Block with variable data according to its properties.
page A valid PDF page handle for a page containing PDFlib Blocks. The input PDF page
with Blocks must have been placed on the page earlier, either directly with fit_pdi_
page( ), indirectly in a table cell with fit_table( ), or as contents of a PDF Block with fill_
pdfblock( ).
blockname
(Name string) The name of the Block.
contents A valid PDF page handle for the PDF page to be filled into the Block, or -1 if the
default PDF page (as defined by Block properties) is to be used.
optlist An option list specifying PDF Block filling options. The following options are
supported:
> General option: errorpolicy (see Section 2.5, »Exception Handling«, page 25)
> Rectangle options for Block filling functions according to Table 11.1:
Rect, Status, backgroundcolor, bordercolor, linewidth
> Fitting options (see Section 6.1, »Object Fitting«, page 99)
> Options for page processing according to Table 9.4.
Returns -1 if the named Block doesn’t exist on the page, the Block cannot be filled, or the Block
requires a newer PDFlib version for processing; 1 if the Block could be processed successfully. Use get_errmsg( ) to get more information about the nature of the problem.
Details The PDF page referred to by the supplied page handle contents will be placed in the
Block, subject to the Block’s properties. If contents is -1 the function will use the Block’s
default PDF page if available (unless Status=ignoredefault), and silently return otherwise.
If the PDF document is found to be corrupt, this function will either throw an exception or return -1 subject to the errorpolicy parameter or option.
Scope page, template
11.4 PDF Blocks
171
172
Chapter 11: Block Filling Functions (PPS) (Edition for COM, .NET, and REALbasic)
12 Interactive Features
12.1 Parameters for Interactive Elements
Table 12.1 lists relevant parameter key names for interactive elements (see Section 2.2,
»Parameter and Option Handling«, page 18). These parameters are not available in Unicode-aware language bindings.
Table 12.1 String-related keys for get/set_parameter( )
key
explanation
usercoordinates
If false, coordinates for hypertext rectangles will be expected in the default coordinate system;
otherwise the current user coordinate system will be used. Default: false. Scope: any
12.2 Actions
VB RB Function create_action(type As String, optlist As String) As Long
C# int create_action(String type, String optlist)
Create an action which can be applied to various objects and events.
type
The action type according to Table 12.2.
Table 12.2 Annotation types
type
notes; options specific for this type (in addition to general options)
GoTo
Go to a destination in the current document: destination, destname
GoTo3DView
(PDF 1.6) Set the current view of a 3D animation: 3Dview, target
GoToE
(PDF 1.6) Go to a destination in an embedded document: targetpath
GoToR
Go to a destination in another (remote) document: destination, destname, filename, newwindow
Hide
(Not for PDF/A) Hide or show an annotation or form field: hide, namelist
ImportData
(Not for PDF/A) Import form field values from a file.
JavaScript
(Not for PDF/A) Execute a script with JavaScript code: script, scriptname
Launch
(Not for PDF/A) Launch an application or document: defaultdir, filename, newwindow, operation,
parameters
Movie
(Not for PDF/A) Play an external sound or movie file in a floating window or within the rectangle of a
movie annotation: operation, target
Named
Execute an Acrobat menu item identified by its name: menuname
ResetForm
(Not for PDF/A) Set some or all form fields to their default values.
SetOCGState (PDF 1.5) Hide or show layers: layerstate, preserveradio
SubmitForm
Send data to a uniform resource locator, i.e. an Internet address (submits which require basic authentication don’t work in Acrobat): canonicaldate, exclude, exportmethod, submitemptyfields, url
12.1 Parameters for Interactive Elements
173
Table 12.2 Annotation types
type
notes; options specific for this type (in addition to general options)
Trans
(PDF 1.5) Update the display using some visual effect. This can be useful to control the display during a sequence of multiple actions: duration, transition
URI
Resolve a uniform resource identifier, i.e. jump to an Internet address: ismap, url
optlist An option list specifying properties of the action:
> General option: errorpolicy (see Table 2.6)
> Options for properties of the action according to Table 12.3.
Returns An action handle which can be used to attach actions to objects within the document
The action handle can be used until the end of the enclosing document scope.
Details This function creates a single action. Various objects (e.g. pages, form field events, bookmarks) can be provided with one or more actions, but each action must be generated
with a separate call to create_action( ). Using an action multiply for different objects is
allowed. It is recommended to re-use existing handles if an action with the same options has already been created earlier.
PDF/X: Actions are prohibited in PDF/X.
PDF/A: Some actions are prohibited in PDF/A (see Table 12.2).
Scope page, document. The returned handle can be used until the next call to end_document( ).
Table 12.3 Options for action properties with create_action( )
option
explanation
3Dview
(Keyword or 3D view handle; GoTo3DView; required) Selects the view of the target 3D annotation; One of
the keywords first, last, next, previous (referring to the respective entries in the annotation’s views
option), or default (referring to the annotation’s defaultview option), or a 3D view handle created with
create_3dview( ).
canonicaldate
(Boolean; SubmitForm) If true, any submitted field values representing dates are converted to a standard format. The interpretation of a field as a date is not specified explicitly in the field itself, but only in
the JavaScript code that processes it. Default: false
defaultdir
(String; Launch) Set the default directory for the launched application. This is only supported by Acrobat
on Windows. Default: none
destination
(Option list; GoTo, GoToE, GoToR; required unless destname is supplied) Option list according to Table 12.5
defining the destination to jump to.
destname
(Hypertext string)
GoTo (required unless destination is supplied): name of a destination which has been defined with add_
nameddest( ).The destination can be created before or after referring to it.
GoToR, GoToE (required unless destination is supplied): name of a destination in the remote or embedded document.
duration
(Float; Trans) Set the duration of the transition effect in seconds for the current page. Default: 1
exclude
(Boolean; SubmitForm) If true, the namelist option specifies which fields to exclude; all fields in the document are submitted except those listed in the namelist array and those whose exportable option is
false. If false, the namelist option specifies which fields to include in the submission. All members of
specified field groups will be submitted as well. Default: false
(ResetForm) If true, the namelist option specifies which fields to exclude; all fields in the document are
reset except those listed in the namelist array. If false, the namelist option specifies which fields to include in resetting. All members of specified field groups will be reset as well. Default: false
174
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.3 Options for action properties with create_action( )
option
exportmethod
explanation
(Keyword list; SubmitForm) Controls how the field names and values are submitted. Default: fdf.
html, fdf, xfdf, pdf
In HTML, FDF, XFDF, or PDF format, respectively
annotfields (Only for fdf) Include all annotations and fields.
coordinate (Only for html) The coordinates of the mouse click that caused the submitform action will be
transmitted as part of the form data. The coordinate values are relative to the upper-left
corner of the field’s rectangle.
exclurl
(Only for fdf) The submitted FDF will exclude the url string.
getrequest (Only for html and pdf) Submit using HTTP GET; otherwise HTTP POST
onlyuser
(Only for fdf and annotfields) The submit will include only those annotations whose name
matches the name of the current user, as determined by the remote server.
updates
(Only for fdf) Include all incremental updates contained in the underlying PDF document
Example for combined options: exportmethod {fdf updates onlyuser}
filename
(Hypertext string) GoToR, Launch (required): name of an external (PDF or other) file or application which
will be opened when the action is triggered. UNC file names must be written as \\server\volume. Since
fully qualified file names (including paths) for Launch actions do not work in Acrobat 8 it is recommended to supply the directory name in the defaultdir option and only a simple file name (without directory
components) in the filename option.
ImportData (required): name of the external file containing forms data.
GoToE: name of the root document of the target relative to the root document of the source. If this entry
is absent, the source and target share the same root document.
hide
(Boolean; Hide) Indicates whether to hide (true) or show (false) annotations. Default: true
ismap
(Boolean; URI) If true, the coordinates of the mouse position will be added to the target URI when the
url is resolved. Default: false
layerstate
(Option list; SetOCGState; required) List of pairs where each pair consists of a keyword and a layer handle. Supported keywords:
on
Activate the layer
off
Deactivate the layer
toggle
Reverse the state of the layer. If this is used preserveradio should be set to false.
menuname
(String; Named; required) The name of the menu item to be performed. In PDF/A mode only the wellknown names nextpage, prevpage, firstpage, lastpage are allowed. Otherwise more names will be accepted. A full code sample for finding the names of other menu items can be found in the Cookbook topic
interactive/acrobat_menu_items.
namelist
(List of strings; Hide; required) The names (including group names) of the annotations or fields to be hidden or shown.
(SubmitForm) The names (including group names) of form fields to include in the submission or which to
exclude, depending on the setting of the exclude option. Default: all fields are submitted except those
whose exportable option is false.
(ResetForm) The names (including group names) of form fields to include in the resetting or which to exclude, depending on the setting of the exclude option. Default: all fields are reset.
newwindow
(Boolean; GoToE, GoToR) A flag specifying whether to open the destination document in a new window.
If this flag is false, the destination document will replace the current document in the same window.
Launch: This entry is ignored if the file is not a PDF document. Default: Acrobat behaves according to the
current user preference.
12.2 Actions
175
Table 12.3 Options for action properties with create_action( )
option
explanation
operation
This option is used differently for type=Launch and type=Movie:
(Keyword; Launch) A keyword specifying the operation to be applied to the document specified in the
filename option. This is only supported by Acrobat on Windows. If the filename option designates an
application instead of a document, this option will be ignored and the application is launched. Supported keywords (default: open):
open
open a document
print
print a document
(Keyword; Movie) A keyword specifying the operation to be applied to the movie or sound. Supported
keywords (default: play):
play
Start playing the movie, using the mode specified in the movie annotation’s playmode option.
If the movie is currently paused, it is repositioned to the beginning before playing.
stop
Stop playing the movie.
pause
Pause a playing movie.
resume
Resume a paused movie.
parameters
(String; Launch) A parameter string to be passed to the application specified with the filename option.
This is only supported by Acrobat on Windows. Multiple parameters can be separated with a space character, but individual parameters must not contain any space characters. This option should be omitted if
filename designates a document. Default: none
preserveradio
(Boolean; SetOCGState) If true, preserve the radio-button state relationship between layers. Default:
true
script
(Hypertext string; JavaScript; required) A string containing the JavaScript code to be executed.
scriptname
(Hypertext string; JavaScript) If present, the JavaScript supplied in the script option will be inserted as
a document-level JavaScript with the supplied name. If the same scriptname is supplied more than once
in a document only the last script will be used, the others will be ignored. Document-level JavaScript will
be executed after loading the document in Acrobat. This may be useful for scripts which are used in form
fields.
submitemptyfields
(Boolean; SubmitForm; PDF 1.4) If true, all fields characterized by the namelist and exclude options are
submitted, regardless of whether they have a value. For fields without a value, only the field name is
transmitted. If false, fields without a value are not submitted. Default: false
target
(String; GoTo3DView, Movie; required) Name of the target 3D or movie annotation as specified in the name
option of create_annotation( ).
targetpath
(Option list; GoToE; required unless filename is specified) A target option list (see Table 12.4) specifying
path information for the target document. Each target option list specifies one element in the full path
to the target and may have nested target option lists with additional elements.
transition
(Keyword; Trans) Set the transition effect; see Table 3.7 for a list of keywords. Default: replace
url
(String; URI and SubmitForm; required) A Uniform Resource Locator encoded in 7-bit ASCII or EBCDIC (but
only containing ASCII characters) specifying the link target (for type=URI) or the address of the script at
the Web server that will process the submission (for type=SubmitForm). It can point to an arbitrary (Web
or local) resource, and must start with a protocol identifier (such as http://). The textx/texty,
currentx/currenty, and imagewidth/imageheight parameters may be useful for retrieving positioning
information for calculating the dimension of link rectangles.
176
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.4 Suboptions for the targetpath option of create_action( )
option
explanation
annotation
(String; required if relation=child and the target is associated with a file attachment annotation) Specifies the name of the target’s file attachment annotation on the page specified by pagenumber or
destname.
destname
(Hypertext string; required unless pagenumber is supplied and relation=child and the target is associated with a file attachment annotation) Specifies a named destination for a page in the current document
which contains the target’s file attachment annotation. This option will be ignored if pagenumber is specified.
name
(Hypertext string; required if relation=child and the target is located in the attachments list; otherwise it must be absent; will be ignored if annotation is specified) Name of the target in the attachments
list of begin/end_document( ).
pagenumber (Integer; required unless destname is supplied and relation=child and the target is associated with a
file attachment annotation; will be ignored if destname is specified) Specifies the number of a page in the
current document which contains the target’s file attachment annotation.
relation
targetpath
(Keyword; required) Specifies the relationship of the current document and the target (which may be an
intermediate target). Supported keywords:
parent
The target is the parent of the current document.
child
The target is a child of the current document.
(Option list) A target option list according to Table 12.4 specifying additional path information to the target document. If this option is absent the current document is the target file containing the destination.
12.2 Actions
177
12.3 Named Destinations
VB RB Sub add_nameddest(name As String, optlist As String)
C# void add_nameddest(String name, String optlist)
Create a named destination on a page in the document.
name (Hypertext string) The name of the destination, which can be used as a target for
links, bookmarks, or other triggers. Destination names must be unique within a document. If the same name is supplied more than once for a document only the last definition will be used, the others will be silently ignored.
optlist An option list specifying the destination. An empty list is equivalent to
{type=fitwindow page=0}. The following options can be used:
> General option: errorpolicy (see Table 2.6)
> Destination control options according to Table 12.5:
bottom, group, left, page, right, top, type, zoom
Details The destination details must be specified in optlist, and the destination may be located
on any page in the current document. The provided name can be used with the destname
option in create_action( ), create_annotation( ), create_bookmark( ), and begin/end_
document( ). This way defining and using a destination can be split into two separate
steps.
Alternatively, if the destination is known at the time when it is used, defining and
using the named destination can be combined by using the destination option of those
functions, and add_nameddest( ) is not required in this case.
Scope document, page
Table 12.5 Destination options for add_nameddest( ), as well as for the destination option in create_action( ), create_
annotation( ), create_bookmark( ), and begin/end_document( ).
option
explanation
bottom
(Float; only for type=fitrect) The y coordinate of the page which will positioned at the bottom edge of
the window. Default: 0
group
(String; required if the page option has been specified and the document uses page groups; not allowed
otherwise.) Name of the page group that the destination page belongs to.
left
(Float; only for type=fixed, fitheight, fitrect, or fitvisibleheight) The x coordinate of the page
which will positioned at the left edge of the window. Default: 0
page
(Integer) Page number of the destination page (first page is 1). The page must exist in the destination
PDF. Page 0 means the current page if in scope page, and page 1 if in scope document. Default: 0
right
(Float; only for type=fitrect) The x coordinate of the page which will positioned at the right edge of
the window. Default: 1000
top
(Float; only for type=fixed, fitwidth, fitrect, or fitvisiblewidth) The y coordinate of the page
which will positioned at the top edge of the window. Default: 1000
178
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.5 Destination options for add_nameddest( ), as well as for the destination option in create_action( ), create_
annotation( ), create_bookmark( ), and begin/end_document( ).
option
explanation
type
(Keyword) Specifies the location of the window on the target page. Supported keywords (default:
fitwindow):
fitheight
Fit the page height to the window, with the x coordinate left at the left edge of the window.
fitrect
Fit the rectangle specified by left, bottom, right, and top to the window.
fitvisible
Fit the visible contents of the page (the ArtBox) to the window.
fitvisibleheight
Fit the visible contents of the page to the window with the x coordinate left at the left edge
of the window.
fitvisiblewidth
Fit the visible contents of the page to the window with the y coordinate top at the top edge
of the window.
fitwidth
Fit the page width to the window, with the y coordinate top at the top edge of the window.
fitwindow Fit the complete page to the window.
fixed
zoom
Use a fixed destination view specified by the left, top, and zoom options. If any of these is
missing its current value will be retained.
(Float or percentage; only for type=fixed) The zoom factor (1 means 100%) to be used to display the
page contents. If this option is missing or 0 the zoom factor which was in effect when the link was activated will be retained.
12.3 Named Destinations
179
12.4 Annotations
VB RB Sub create_annotation(llx As Double, lly As Double, urx As Double, ury As Double,
type As String, optlist As String)
C# void create_annotation(double llx, double lly, double urx, double ury, String type, String optlist)
Create an annotation on the current page.
llx, lly, urx, ury x and y coordinates of the lower left and upper right corners of the annotation rectangle in default coordinates (if the usercoordinates parameter or option is
false) or user coordinates (if it is true). Acrobat will align the upper left corner of the annotation at the upper left corner of the specified rectangle.
Note that annotation coordinates are different from the parameters of the rect( )
function. While create_annotation( ) expects parameters for two corners directly, rect( )
expects the coordinates of one corner, plus width and height values.
If the usematchbox option has been specified, llx/lly/urx/ury will be ignored.
type The annotation type according to Table 12.6. Markup annotations are marked in
the table since certain options apply only to markup annotations.
Table 12.6 Annotation types
type
notes; options specific for this type (in addition to general options)
3D
(PDF 1.6) animated 3D model: 3Dactivate, 3Ddata, 3Dinteractive, 3Dshared, 3Dinitialview
Circle
1
cloudy, createrichtext, inreplyto, interiorcolor, replyto
FileAttachment1
(Not for PDF/A) calloutline, createrichtext, filename, iconname, inreplyto, mimetype, replyto
FreeText1
alignment, calloutline, cloudy, createrichtext, endingstyles, fillcolor, font, fontsize,
inreplyto, orientate, replyto
Highlight1
createrichtext, inreplyto, polylinelist, replyto
Ink
1
createrichtext, inreplyto, polylinelist, replyto
1
Line
captionoffset, captionposition, createrichtext, endingstyles, interiorcolor, inreplyto,
leaderlength, leaderoffset, line, showcaption, replyto
Link
destination, destname, highlight
Movie
(Movie or sound annotation) filename, movieposter, playmode, showcontrols, soundvolume, windowposition, windowscale
Polygon1
(PDF 1.5; vertices connected by straight lines): cloudy, createrichtext, inreplyto, polylinelist,
replyto
PolyLine1
(PDF 1.5; similar to polygons, except that the first and last vertices are not connected) createrichtext,
endingstyles, inreplyto, interiorcolor, polylinelist, replyto
Popup
open, parentname
Square
1
cloudy, createrichtext, inreplyto, interiorcolor, replyto
Squiggly
1
(PDF 1.4; squiggly-underline annotation) createrichtext, inreplyto, polylinelist, replyto
1
Stamp
createrichtext, iconname, inreplyto, orientate, replyto
StrikeOut
180
1
createrichtext, inreplyto, polylinelist, replyto
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.6 Annotation types
type
Text
notes; options specific for this type (in addition to general options)
1
(In Acrobat this type is called note annotation) createrichtext, iconname, inreplyto, open, replyto,
state, statemodel
Underline1
createrichtext, inreplyto, polylinelist, replyto
1. Markup annotation; this is relevant for the createrichtext option.
optlist An option list specifying annotation properties. The following options can be
used:
> The following common options according to Table 12.7 are supported for all annotation types:
action, annotcolor, borderstyle, cloudy, contents, createdate, custom, dasharray, display,
layer, linewidth, locked, lockedcontents, name, opacity, popup, readonly, rotate, subject,
template, title, usematchbox, usercoordinates, zoom
> The following type-specific options according to Table 12.7 are supported only for
some annotation types according to Table 12.6:
3Dactivate, 3Ddata, 3Dinteractive, 3Dshared, 3Dinitialview, alignment, calloutline, captionoffset, captionposition, createrichtext destname, endingstyles, filename, fillcolor, font,
fontsize, highlight, iconname, interiorcolor, inreplyto, leaderlength, leaderoffset, line,
mimetype, movieposter, open, orientate, parentname, playmode, polylinelist, replyto,
showcaption, showcontrols, soundvolume, windowposition, windowscale
Details PDF/X: Annotations are only allowed if they are positioned completely outside of the
BleedBox (or TrimBox/ArtBox if no BleedBox is present).
PDF/A: some annotation types and options are restricted, see Table 12.6 and Table 12.7.
Tagged PDF: the annotation will be inserted as a child of the current item if an item is
currently active.
Scope page
Table 12.7 Options for create_annotation( )
option
explanation
3Dactivate
(Option list; only for type=3D) Specifies when the 3D annotation should be activated and its state upon
activation/deactivation. Supported options are listed in Table 12.8.
3Ddata
(3D handle; only for type=3D; required) 3D handle created with load_3ddata( ).
3Dinteractive
(Boolean; only for type=3D) If true, the 3D model is intended for interactive use. If false, it is intended to
be manipulated with JavaScript. Default: true
3Dshared
(Boolean; only for type=3D) If true, the 3D data specified in the 3Ddata option will be referenced indirectly. Multiple 3D annotations which indirectly reference the same data share a single run-time instance of
the model. This means that changes will be visible in all such annotations simultaneously. Default: false
3Dinitialview
(Keyword or 3D view handle) Specifies the initial view of the 3D model; One of the keywords first, last,
(referring to the respective entries in the views option of load_3ddata( )), or default (referring to the
model’s defaultview option), or a 3D view handle created with create_3dview( ). Default: default
12.4 Annotations
181
Table 12.7 Options for create_annotation( )
option
explanation
action
(Action list) List of annotation actions for the following events (default: empty list). All types of actions
are permitted:
activate
(Only for type=Link) Actions to be performed when the annotation is activated.
close
(PDF 1.5) Actions to be performed when the page containing the annotation is closed.
open
(PDF 1.5) Actions to be performed when the page containing the annotation is opened.
invisible
(PDF 1.5) Actions to be performed when the page containing the annotation is no longer
visible.
visible
(PDF 1.5) Actions to be performed when the page containing the annotation becomes visible.
alignment
(Keyword; only for type=FreeText) Alignment of text in the annotation: left, center, or right. Default:
left
annotcolor
(Color) The color of the background of the annotation’s icon when closed, the title bar of the annotation’s pop-up window, and the border of a link annotation. Supported color spaces: none (not for
type=Square, Circle), gray, rgb, and (in PDF 1.6) cmyk.
In PDF/A mode this option must only be used if an RGB output intent has been specified, and gray or rgb
color must be used.
Default: white for type=Square, Circle, otherwise none
borderstyle
(Keyword) Style of the annotation border or the line of the annotation types Polygon, PolyLine, Line,
Square, Circle, Ink: solid, beveled, dashed, inset, or underline. Note that the beveled, inset, and
underline styles do not work reliably in Acrobat. Default: solid
calloutline
(List of four or six floats; PDF 1.6; only for type=FreeText) List of 4 or 6 float values specifying a callout
line attached to the FreeText annotation. Six numbers {x1 y1 x2 y2 x3 y3} represent the starting, knee
point, and end coordinates of the line. Four numbers {x1 y1 x2 y2} represent the starting and end coordinates of the line. The coordinates will be interpreted in default coordinates (if the usercoordinates
option is false) or user coordinates (if it is true).
The start point will be decorated with the symbol specified in the first keyword of the endingstyles option.
captionoffset
(2 Floats; only for type=Line; PDF 1.7) The offset of the caption text from its normal position. The first
value specifies the horizontal offset along the annotation line from its midpoint, with a positive value indicating offset to the right and a negative value indicating offset to the left. The second value specifies
the vertical offset perpendicular to the annotation line, with a positive value indicating a shift up and a
negative value indicating a shift down. Default: {0, 0}, i.e. no offset from the normal position
captionposition
(Keyword; only for type=Line; PDF 1.7) The annotation’s caption position. This option will be ignored if
showcaption=false. Supported keywords (default: Inline):
Inline
The caption will be centered inside the line.
Top
The caption will be positioned on top of the line.
cloudy
(Float; only for type=Circle, FreeText, Polygon, and Square; PDF 1.5) Specifies the intensity of the
»cloud« effect used to render the polygon. Possible values are 0 (no effect), 1, and 2. If this option is used
the borderstyle option will be ignored. Default: 0
contents
(String for type=FreeText, otherwise Hypertext string with a maximum length of 65535 bytes) Text to be
displayed for the annotation or (if the annotation does not display text) an alternate description of its
contents in human-readable form. Carriage return or line feed characters can be used to force a new
paragraph.
In PDF/A-1a mode this option is required and must contain a non-empty string.
createdate
182
(Boolean; PDF 1.5) If true, a date/time entry will be created for the annotation. Default: false
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.7 Options for create_annotation( )
option
explanation
createrichtext
(Option list; only for markup annotations; option contents must be empty; PDF 1.5) Create rich text contents from a Textflow. This may be useful to generate formatted text for annotations. Supported suboptions:
textflow
(Textflow handle) A Textflow which will be attached to the annotation as rich text. If the
Textflow handle has been supplied to fit_textflow/table( ) before the call to create_
annotation( ) only the remaining text will be used for the annotation. If no more text is available the Textflow will be restarted from the beginning. Using a Textflow for an annotation
does not affect subsequent calls to fit_textflow/table( ).
userunit
(Keyword) Measurement unit for scalar values (e.g. firstlinedist, fontsize): cm (centimeter), in
(inches), mm (millimeters), or pt (points). Default: pt
The following Textflow options will be honored when creating rich text; all others will be ignored:
nextline, alignment, fillcolor, underline, strikeout, font, fontsize, textrise, text formatting options
Note: setting the font and alignment doesn’t have the expected effect in Acrobat.
custom
(List of option lists; only for advanced users) This option can be used to insert an arbitrary number of private entries in the annotation dictionary, which may be useful for specialized applications such as inserting processing instructions for digital printing machines. Using this option requires knowledge of the PDF
file format and the target application. Corrupt PDF output may be generated if unsuitable values are
supplied. Supported suboptions:
key
(String; required) Name of the dictionary key (excluding the / character). Any non-standard
PDF key can be specified, as well as the following standard keys: Contents, Name (option
iconname), NM (option name), and Open. The corresponding options will be ignored in this case.
type
(Keyword; required) Type of the corresponding value, which must be one of boolean, name, or
string
value
(Hypertext string if type=string, otherwise string; required) Value as it will appear in the PDF
output; PDFlib will automatically apply any decoration required for strings and names.
dasharray
(List of floats; only for borderstyle=dashed). The lengths of dashes and gaps for a dashed border in default units (see setdash( )). Default: 3 3
destination
(Option list; only for type=Link; will be ignored if an activate action has been specified) Option list according to Table 12.5 defining the destination to jump to
destname
(Hypertext string; only for type=Link; will be ignored if the destination option has been specified)
Name of a destination which has been defined with add_nameddest( ). Actions created with the
destination or destname options of create_action( ) are dominant over this option.
display
(Keyword) Visibility on screen and paper: visible, hidden, noview, noprint. Default: visible
endingstyles
(Keyword list; only for type=FreeText, Line, PolyLine) A list with two keywords specifying the line ending styles. The second keyword will be ignored for type=FreeText (default: {none none}):
none, square, circle, diamond, openarrow, closedarrow
Additionally for PDF 1.5: butt, ropenarrow, rclosedarrow
Additionally for PDF 1.6: slash
filename
(String; only for type=FileAttachment and Movie; required) The file name will be interpreted according
to the global filenamehandling option or parameter, see Table 2.2.
For type=FileAttachment:name of the file associated with the annotation.
For type=Movie: name of the media file in one of the following formats: AVI or QuickTime movie, WAV
or AIFF sound
fillcolor
(Color; only for type=FreeText) Fill color of the text. Supported color spaces are gray, rgb, cmyk. In PDF/A
mode this option must only be used if an RGB or CMYK output intent has been specified, and a corresponding rgb or cmyk color space must be used. Default: {gray 0} (=black)
12.4 Annotations
183
Table 12.7 Options for create_annotation( )
option
explanation
font
(Font handle; only for type=FreeText; required) Specifies the font to be used for the annotation.
fontsize
(Fontsize; only for type=FreeText; required) The font size in default or user coordinates depending on
the usercoordinates option or parameter. The value 0 or keyword auto which means that Acrobat will
adjust the fontsize to the rectangle.
highlight
(Keyword; only for type=Link) Highlight mode of the annotation when the user clicks on it: none,
invert, outline, push. Default: invert
iconname
(String; only for type=Text, Stamp, FileAttachment) Name of an icon to be used in displaying the annotation (to create an annotation without any visible icon set opacity=0):
For type=Text (default: note):
comment
, key
, note
, help
, newparagraph
, paragraph
, insert
For type=Stamp, but note that these don’t work reliably in Adobe Reader; the template option is recommended instead (default: draft):
approved, experimental, notapproved, asis, expired, notforpublicrelease, confidential, final,
sold, departmental, forcomment, topsecret, draft, forpublicrelease
For type=FileAttachment (default: pushpin):
graph
, pushpin
, paperclip
, tag
The template option can be used to create custom icons.
interiorcolor
(Color; only for type=Line, PolyLine, Square, Circle) The color for the annotation’s line endings, rectangle, or ellipse, respectively. Supported color spaces are none, gray, rgb, and (in PDF 1.6) cmyk. In PDF/A
mode this option must only be used if an RGB output intent has been specified, and gray or rgb color
must be used. Default: none
inreplyto
(Hypertext string; PDF 1.5; only for markup annotations; required if the replyto option is supplied) The
name of the annotation (see option name) that this annotation is in reply to. Both annotations must be
on the same page of the document. The relationship between the two annotations must be specified by
the replyto option.
layer
(Layer handle; PDF 1.5) Layer to which the annotation will belong. The annotation will only be visible if
the corresponding layer is visible.
leaderlength (List with one or two floats; the second float must not be negative; only for type=Line; PDF 1.6) The
length of leader lines in default coordinates (if the usercoordinates option is false) or user coordinates
(if it is true). The length is specified by two numbers (default: {0 0}):
The first number is the extension from each endpoint of the line perpendicular to the line itself. A positive
value means that the leader lines appear in the direction that is clockwise when traversing the line from
its start point to its end point (as specified by the line option); a negative value indicates the opposite direction.
The second value, which can be omitted, represents the length of leader line extensions that extend from
the line proper 180°
from the leader lines. A positive value will be ignored if the first value is 0.
leaderoffset
(Non-negative float; only for type=Line; PDF 1.7) The length of the leader line offset, which is the
amount of empty space between the endpoints of the annotation and the beginning of the leader lines
in default coordinates (if the usercoordinates option is false) or user coordinates (if it is true). Default: 0
line
(Line; only for type=Line; required) A list of four numbers x1, y1, x2, y2 specifying the start and end coordinates of the line in default coordinates (if the usercoordinates option or parameter is false) or user
coordinates (if it is true).
linewidth
(Integer) Width of the annotation border or the line of the annotation types Line, PolyLine, Polygon,
Square, Circle, Ink in default units (=points). If linewidth=0 the border will be invisible. Default: 1
184
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.7 Options for create_annotation( )
option
explanation
locked
(Boolean) If true, the annotation properties (e.g. position and size) cannot be edited in Acrobat. However, the contents can still be modified. Default: false
lockedcontents
(Boolean; PDF 1.7) If true, the annotation contents cannot be edited in Acrobat. However, the annotation
can still be deleted or properties changed (e.g. position and size) Default: false
mimetype
(String; only for type=FileAttachment) MIME type of the file. Acrobat will use it for launching the appropriate application when the annotation is activated.
movieposter
(Keyword; only for type=Movie) Keyword which specifies a poster image representing the movie on the
page. Supported keywords: auto (the poster image will be retrieved from the movie file), none (no poster
will be displayed). Default: none
name
(Hypertext string) Name uniquely identifying the annotation. The name is necessary for some actions,
and must be unique on the page. Default: none
opacity
(Float or percentage; PDF 1.4) The constant opacity value (0-1 or 0%-100%) to be used in painting the
annotation. Default: 1
open
(Boolean; only for type=Text, Popup) If true, the annotation will initially be open. Default: false
orientate
(Keyword; only for type=FreeText, Stamp) Specifies the desired orientation of the annotation within its
rectangle. Supported keywords: north (upright), east (pointing to the right), south (upside down), west
(pointing to the left). Default: north
parentname
(String; only for type=PopUp) Name of the parent annotation for the annotation
playmode
(Keyword; only for type=Movie) The mode for playing the movie or sound. Supported keywords: once
(play once and stop), open (play and leave the movie controller bar open), repeat (play repeatedly from
beginning to end until stopped), palindrome (play continuously forward and backward until stopped).
Default: once
polylinelist
(List containing one or more polylines or quadrilaterals; only for type=Polygon, PolyLine, Ink,
Highlight, Underline, Squiggly, Strikeout). The coordinates will be interpreted in default coordinates
(if the usercoordinates option is false) or user coordinates (if it is true). Default: a polyline connecting
the vertices of the annotation rectangle.
type=Polygon, PolyLine, Ink
A single list containing a polyline with n segments (minimum: n=2).
others
The list contains n sublists with 8 float values each, specifying n quadrilaterals (minimum:
n=1). Each quadrilateral encompasses a word or group of contiguous words in the text
underlying the annotation. The quadrilaterals must be provided in zigzag order (top right, top
left, lower right, lower left).
popup
(String) Name of a PopUp annotation for entering or editing the text associated with this annotation.
Default: none
readonly
(Boolean) If true, do not allow the annotation to interact with the user. The annotation may be displayed or printed, but should not respond to mouse clicks or change its appearance in response to mouse
motions. Default: false
replyto
(Keyword; PDF 1.6; only for markup annotations) Specifies the relationship (the reply type) between this
annotation and the one specified by the inreplyto option. Supported keywords (default: reply):
rotate
reply
The annotation must be considered a reply to the annotation specified by inreplyto.
group
The annotation must be grouped with the annotation specified by inreplyto.
(Boolean; must not be set to true for text annotations in PDF/A mode) If true, rotate the annotation to
match the rotation of the page. Otherwise the annotation’s rotation will remain fixed. This option will
be ignored for the icons of text annotations. Default: false for text annotations in PDF/A mode, true
otherwise
12.4 Annotations
185
Table 12.7 Options for create_annotation( )
option
explanation
showcaption (Boolean; only for type=Line; PDF 1.6) If true, the text specified in the contents or createrichtext options will be replicated as a caption in the appearance of the line. Default: false
showcontrols
(Boolean; only for type=Movie) If true a controller bar while playing the movie or sound will be displayed. Default: false
soundvolume
(Float; only for type=Movie) The initial sound volume at which to play the movie, in the range -1.0 to 1.0.
Higher values denote greater volume; negative values mute the sound. Default: 1.0
subject
(Hypertext string; PDF 1.5) Text representing a short description of the subject being addressed by the annotation. Default: none
template
(Option list) Visual appearance of the annotation for one or more states. This may be useful e.g. for custom stamps. Supported suboptions:
normal/rollover/down
(Template handle or keyword) Template which will be used for the annotation’s normal,
mouse rollover, or mouse button down appearance, respectively. The keyword viewer
instructs Acrobat to create the appearance when rendering the page. Default for normal:
viewer; default for rollover and down: the value of normal
fitmethod (Keyword) Method to fit the template into the annotation rectangle. If fitmethod is different
from entire the annotation rectangle will be adapted to the template box (default: entire):
nofit
Position the template only, without any scaling or clipping.
meet
Position the template according to the position option, and scale it so that it entirely fits into the rectangle while preserving its aspect ratio. Generally at least
two edges of the template will meet the corresponding edges of the rectangle.
entire
Position the template according to the position option, and scale it such that it
entirely covers the rectangle. Generally this method will distort the template.
position
(List of floats or keywords) One or two values specifying the position of the reference point
(x, y) within the template with {0 0} being the lower left corner of the template, and
{100 100} the upper right corner. The values are expressed as percentages of the template’s
width and height. If both percentages are equal it is sufficient to specify a single float value.
The keywords left, center, right (in x direction) or bottom, center, top (in y direction) can
be used as equivalents for the values 0, 50, and 100. If only one keyword has been specified
the corresponding keyword for the other direction will be added. Default: {left bottom}.
title
(Hypertext string; recommended for movie annotations) The text label to be displayed in the title bar of
the annotation’s pop-up window when open and active. This string corresponds to the »Author« field in
Acrobat. The maximum length of title is 255 single-byte characters or 126 Unicode characters. However,
a practical limit of 32 characters is advised. Default: none
usematchbox
(List of strings) The llx/lly/urx/ury parameters will be ignored, and the matchbox will be used instead.
The first element in the option list is a name string which specifies a matchbox. The second element is either an integer specifying the number of the desired rectangle, or the keyword all to specify all rectangles referring to the selected matchbox. If the second element is missing, it defaults to all.
If the matchbox itself or the specified rectangle does not exist on the current page, the function will silently return without creating any annotation.
usercoordinates
(Boolean) If false, annotation coordinates and font size will be expected in the default coordinate system; otherwise the current user coordinate system will be used. Default: the value of the global
usercoordinates parameter
windowposition
(List of 2 floats or keywords; only for type=Movie) For floating movie windows, the relative position of
the window on the screen. The two values specify the position of the floating window on the screen, with
{0 0} denoting the lower left corner of the screen and {100 100} the upper right corner. The keywords
left, center, right (in horizontal screen direction) or bottom, center, top (in vertical screen direction)
can be used as equivalents for the values 0, 50, and 100. Default: {center center}
186
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.7 Options for create_annotation( )
option
explanation
windowscale (Float or keyword; only for type=Movie) The zoom factor at which to play the movie in a floating window. If the option is absent, the movie will be played in the annotation rectangle. The value of this option is either a zoom factor for the movie, or the following keyword (default: option is absent, i.e. the
movie is played in the annotation rectangle):
fullscreen The movie will be played using all of the available screen area.
zoom
(Boolean; must not be set to true for text annotations in PDF/A mode) If true, scale the annotation to
match the magnification of the page. Otherwise the annotation’s size will remain fixed. This option will
be ignored for the icons of text annotations. Default: false for text annotations in PDF/A mode, true
otherwise
Table 12.8 Suboptions for the 3Dactivate option of create_annotation( )
option
explanation
enable
(Keyword) Specifies when the animation should be enabled (default: click):
enablestate
disable
disablestate
open
Activate when the page is opened.
visible
Activate when the page becomes visible.
click
Annotation must explicitly be activated by a script or user action.
(Keyword) Initial animation state (default: play):
pause
The 3D model is instantiated, but script animations are disabled.
play
The 3D model is instantiated; script animations are enabled if present.
(Keyword) Specifies when the animation should be disabled (default: invisible):
close
Deactivate when the page is closed.
invisible
Deactivate when the page becomes invisible.
click
Annotation must explicitly be deactivated by a script or user action.
(Keyword) State of the animation upon disabling (default: reset):
pause
The 3D model can be rendered, but animations are disabled.
play
The 3D model can be rendered and animations are enabled.
reset
Initial state of the 3D model before it has been used in any way.
modeltree
(Boolean; PDF 1.6) If true, the Model Tree navigation tab will be opened when the annotation is activated (default: false)
toolbar
(Boolean; PDF 1.6) If true, the 3D toolbar (at the top of the annotation) will be displayed when the annotation is activated (default: true)
12.4 Annotations
187
12.5 Form Fields
Cookbook A full code sample can be found in the Cookbook topic webserver/starter_webform.
VB RB Sub create_field(llx As Double, lly As Double, urx As Double, ury As Double,
name As String, type As String, optlist As String)
C# void create_field(double llx, double lly, double urx, double ury,
String name, String type, String optlist)
Create a form field on the current page subject to various options.
llx, lly, urx, ury
x and y coordinates of the lower left and upper right corners of the
field rectangle in default coordinates (if the usercoordinates parameter or option is false)
or user coordinates (if it is true).
Note that form field coordinates are different from the parameters of the rect( ) function. While create_field( ) expects parameters for two corners directly, rect( ) expects the
coordinates of one corner, plus width and height values.
name (Hypertext string) The form field name, possibly prefixed with the name(s) of
one or more groups which have been created with create_fieldgroup( ). Group names
must be separated from each other and from the field name by a period ».« character.
Field names must be unique on a page, and must not end in a period ».« character.
type
The field type according to Table 12.9.
Table 12.9 Form field types
type
icon
Options specific for this type (in addition to general options)
pushbutton
buttonlayout, caption, captiondown, captionrollover, charspacing, fitmethod, icon,
icondown, iconrollover, position, submitname
checkbox
currentvalue, itemname
radiobutton
buttonstyle, currentvalue, itemname, toggle, unisonselect
The name must be prefixed with a group name since radio buttons must always belong to a
group. For all other field types group membership is optional.
listbox
charspacing, currentvalue, itemnamelist, itemtextlist, multiselect, sorted, topindex
combobox
commitonselect, charspacing, currentvalue, editable, itemnamelist, itemtextlist, sorted,
spellcheck
textfield
comb, charspacing, currentvalue, fileselect, maxchar, multiline, password, richtext,
scrollable, spellcheck
signature
charspacing, lockmode
optlist An option list specifying field properties:
> General option: errorpolicy (see Table 2.6)
> An option list specifying the field’s properties according to Table 12.10. String options will be interpreted as hypertext strings or text strings as noted in the table. The
following options are supported for all field types (see Table 12.9 for more type-spe-
188
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
cific options):
action, alignment, backgroundcolor, bordercolor, borderstyle, calcorder, dasharray,
defaultvalue, display, exportable, fieldtype, fillcolor, font, fontsize, highlight, layer,
linewidth, locked, orientate, readonly, required, strokecolor, taborder, tooltip, usercoordinates
Details The tab order of the fields on the page (the order in which they receive the focus when
the tab key is pressed) is determined by the order of calls to create_field( ) by default, but
a different order can be specified with the taborder option. The tab order can not be
modified after creating the fields. However, this behavior can be overridden with the
taborder option of begin/end_page_ext( ).
In Acrobat it is possible to assign a format (number, percentage, etc.) to text fields.
However, this is not specified in the PDF reference, but implemented with custom JavaScript. You can achieve the same effect by attaching JavaScript actions to the field which
refers to the predefined (but not standardized) JavaScript functions in Acrobat.
This function must not be called in PDF/A mode.
In all PDF/X modes form fields are only allowed if they are positioned completely
outside of the BleedBox (or TrimBox/ArtBox if no BleedBox is present).
Tagged PDF: the field will be inserted as a child of the current item if an item is currently active.
Scope page
VB RB Sub create_fieldgroup(name As String, optlist As String)
C# void create_fieldgroup(String name, String optlist)
Create a form field group subject to various options.
name (Hypertext string) The name of the form field group, which may in turn be prefixed with the name of another group. Field groups can be nested to an arbitrary level.
Group names must be separated with a period ».« character. Group names must be
unique within the document, and must not end in a period ».« character.
optlist
An option list with field options for create_field( )
Details Field groups are useful for mirroring the contents of a field in one or more other fields.
If the name of a field group is provided as prefix for a field name created with create_
field( ), the new field will be part of this group. All field property options provided in the
optlist for a group will be inherited by all fields belonging to this group.
Scope page, document
12.5 Form Fields
189
Table 12.10 Options for field properties with create_field( ) and create_fieldgroup( )
option
explanation
action
(Action list) List of field actions for one or more of the following events. The activate event is allowed for
all field types, the other events are not allowed for type=pushbutton, checkbox, radiobutton. Default:
empty list
activate
Actions to be performed when the field is activated.
blur
Actions to be performed when the field loses the input focus.
calculate JavaScript actions to be performed in order to recalculate the value of this field when the
value of another field changes.
close
(PDF 1.5) Actions to be performed when the page containing the field is closed.
down
Actions to be performed when the mouse button is pressed inside the field’s area.
enter
Actions to be performed when the mouse enters the field’s area.
exit
Actions to be performed when the mouse exits the field’s area.
focus
Actions to be performed when the field receives the input focus.
format
JavaScript actions to be performed before the field is formatted to display its current value.
This allows the field’s value to be modified before formatting.
invisible
(PDF 1.5) Actions to be performed when the page containing the field is no longer visible.
keystroke JavaScript actions to be performed when the user types into a text field or combo box, or
modifies the selection in a scrollable list box.
alignment
open
(PDF 1.5) Actions to be performed when the page containing the field is opened.
up
Actions to be performed when the mouse button is released inside the field’s area (this is
typically used to activate a field).
validate
JavaScript actions to be performed when the field’s value is changed. This allows the new
value to be checked for validity.
visible
(PDF 1.5) Actions to be performed when the page containing the field becomes visible.
(Keyword) Alignment of text in the field: left, center, right. Default: left
background- (Color) Color of the field background or border. Supported color spaces: none, gray, rgb, cmyk. Default:
none
color
bordercolor
borderstyle
(Keyword) Style of the field border, which is one of solid, beveled, dashed, inset, underline. Default:
solid
buttonlayout
(Keyword; only for type=pushbutton) The position of the button caption relative to the button icon, provided both have been specified: below, above, right, left, overlaid. Default: right
buttonstyle
(Keyword; only for type=radiobutton and checkbox) Specifies the symbol to be used for the field: check,
cross, diamond, circle, star, square. Default: check
calcorder
(Integer; only used if the field has a JavaScript action for the calculate event) Specifies the calculation order of the field relative to other fields. Fields with smaller numbers will be calculated before fields with
higher numbers. Default: 10 plus the maximum calcorder used on the current page (and 10 initially)
caption
(Content string; only for type=pushbutton; one of the caption or icon options must be supplied for push
buttons) The caption text which will be visible when the button doesn’t have input focus. It will be displayed with the font supplied in the font option. Use an empty string (i.e. caption { }) if you don’t
want caption or icon. Default: none
captiondown
(Content string; only for type=pushbutton) The caption text which will be visible when the button is activated. It will be displayed with the font supplied in the font option. Default: none
captionrollover
(Content string; only for type=pushbutton) The caption text which will be visible when the button has
input focus. It will be displayed with the font supplied in the font option. Default: none
charspacing
(Float; not for type=radiobutton, checkbox) The character spacing for text in the field in units of the
current user coordinate system. This option is ignored by Acrobat 7. Default: 0
190
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.10 Options for field properties with create_field( ) and create_fieldgroup( )
option
explanation
comb
(Boolean; only for type=textfield; PDF 1.5) If true and the multiline, fileselect, and password options are false, and the maxchar option has been supplied with an integer value, the field will be divided
into a number of equidistant subfields (according to the maxchar option) for individual characters. Default: false
commitonselect
(Boolean; only for type=listbox, combobox; PDF 1.5) If true, an item selected in the list will be committed
immediately upon selection. If false, the item will only be committed upon exiting the field. Default:
false
currentvalue
(Not for type=pushbutton, signature) The field’s initial value. Type and default depend on the field
type:
checkbox, radiobutton
(String) Arbitrary string other than Off means that the button is activated. The string Off
means that the button is deactivated. This option should be set for the first button. Default:
Off
textfield, combobox
(Content string) Contents of the field. It will be displayed with the font supplied in the font
option. Default: empty
listbox
dasharray
(List of integers) Indices of the selected items within itemtextlist. Default: none
(List of floats; only for borderstyle=dashed). The lengths of dashes and gaps for a dashed border in default units (see setdash( )). Default: 3 3
defaultvalue The field’s value after a reset action. Types and defaults are the same as for the currentvalue option. Exception: for listboxes only a single integer value is allowed.
display
(Keyword) Visibility on screen and paper: visible, hidden, noview, noprint. Default: visible
editable
(Boolean; only for type combobox) If true, the currently selected text in the box can be edited. Default:
false
exportable
(Boolean) The field will be exported when a SubmitForm action happens. Default: true
fieldtype
(Keyword; only for create_fieldgroup( )) Type of the fields contained in the group: mixed, pushbutton,
checkbox, radiobutton, listbox, combobox, textfield, or signature. Unless fieldtype=mixed the
group may only contain fields of the specified type. If a particular fieldtype has been specified for the
group, the current value is displayed in all contained fields simultaneously, even if the fields are located
on separate pages. If fieldtype=radiobutton the option unisonselect must be supplied. The options
itemtextlist, itemnamelist, currentvalue and defaultvalue must be specified in the options of
create_fieldgroup( ), and not in the options of create_field( ). Default: mixed
fileselect
(Boolean; only for type=textfield) If true, the text in the field will be treated as a file name. Default:
false
fillcolor
(Color) Fill color for text. Supported color spaces: gray, rgb, cmyk. Default: {gray 0} (=black)
fitmethod
(Keyword; only for type=pushbutton) Method of placing a template provided with the icon, icondown,
and iconrollover options within the button. Supported keywords (default: meet):
auto
same as meet if the template fits into the button, otherwise clip
nofit
same as clip
clip
template will not be scaled, but clipped at the field border
meet
template will be scaled proportionally so that it fits into the button
slice
same as meet
entire
template will be scaled so that it fully fits into the button
12.5 Form Fields
191
Table 12.10 Options for field properties with create_field( ) and create_fieldgroup( )
option
explanation
font
(Font handle; required except for type=radiobutton and checkbox which always use ZapfDingbats; for
type=pushbutton it is only required if one or more of the caption, captionrollover, or captiondown options are specified).
The font to be used for the field. The following font types are not allowed for text form fields: TrueType
or OpenType subsets (i.e. subsetting=true), CID fonts (i.e. autocidfont=true or encoding=unicode for
TrueType fonts). Acrobat can display characters even if they are not included in the font’s encoding. For
example, you can use encoding=winansi and supply Unicode characters outside winansi.
fontsize
(Fontsize) Font size in user coordinates. The value 0 or keyword auto which means that Acrobat will adjust the fontsize to the rectangle.Default: auto
highlight
(Keyword) Highlight mode of the field when the user clicks on it: none, invert, outline, push. Default:
invert
icon
(Template handle1; only for type=pushbutton; one of the caption or icon options must be supplied for
push buttons) Handle for a template which will be visible when the button doesn’t have input focus. Default: none
icondown
(Template handle1; only for type=pushbutton) Handle for a template which will be visible when the button is activated. Default: none
iconrollover
(Template handle1; only for type=pushbutton) Handle for a template which will be visible when the button has input focus. Default: none
itemname
(Hypertext string; only for type=radiobutton, checkbox; must be used if the export value is not a Latin 1
string) Export value of the field. Item names for multiple radio buttons in a group may be identical. Default: field name
itemnamelist
(Hypertext string; only for type=listbox, combobox) Export values of the list items. Multiple items may
have the same export value. Default: none
itemtextlist
(List of content strings; only for type=listbox and combobox, and required in these cases) Text contents
for all items in the list. If both itemnamelist and itemtextlist are specified both must contain the
same number of strings.
layer
(Layer handle; PDF 1.5) Layer to which the field will belong. The field will only be visible if the corresponding layer is visible.
linewidth
(Integer) Line width of the field border in default units (=points). Default: 1
locked
(Boolean) If true, the field properties cannot be edited in Acrobat. Default: false
lockmode
(Keyword; only for type=signature; PDF 1.5) Indicates the set of fields that should be locked when the
field is signed:
all
All fields in the document will be locked.
maxchar
(Integer or keyword; only for type=textfield) The upper limit for the number of text characters in the
field, or the keyword unlimited if there is no limit. Default: unlimited
multiline
(Boolean; only for type=textfield) If true, text will be wrapped to multiple lines if required. Default:
false
multiselect
(Boolean; only for type=listbox) If true, multiple items in the list can be selected. Default: false
orientate
(Keyword) Orientation of the contents within the field: north, west, south, east. Default: north
password
(Boolean; only for type=textfield) If true, the text will be simulated with bullets or asterisks upon input. Default: false
192
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.10 Options for field properties with create_field( ) and create_fieldgroup( )
option
explanation
position
(List of floats or keywords; only for type=pushbutton) One or two values specifying the position of a
template provided with the icon... options within the field rectangle, with {0 0} being the lower left corner of the field, and {100 100} the upper right corner. The values are expressed as percentages of the field
rectangle’s width and height. If both percentages are equal it is sufficient to specify a single float value.
The keywords left, center, right (in x direction) or bottom, center, top (in y direction) can be used as
equivalents for the values 0, 50, and 100. If only one keyword has been specified, the corresponding keyword for the other direction will be added. Default: {center}. Examples:
{0 50} or {left center}
left-justified template
{50 50} or {center}
centered template
{100 50} or {right center}right-justified template
readonly2
(Boolean) If true, the field does not allow any input. Default: false
required
(Boolean) If true, the field must contain a value when the form is submitted. Default: false
richtext
(Boolean; only for type=textfield; PDF 1.5) Allow rich text formatting. If true, the fontsize must not
be 0, and fillcolor must not use color space cmyk. Default: false
scrollable
(Boolean; only for type=textfield) If true, text will be moved to the invisible area outside the field if
the text doesn’t fit into the field. If false, no more input will be accepted when the text fills the full field.
Default: true
sorted
(Boolean; only for type=listbox and combobox) If true, the contents of the list will be sorted. Default:
false
spellcheck
(Boolean; only for type=textfield and combobox) If true, the spell checker will be active in the field. Default: true
strokecolor
(Color) Stroke color for text. Supported color spaces: gray, rgb, cmyk. Default: {gray 0} (=black).
submitname (Hypertext string; recommended only for type=pushbutton) URL-encoded string of the Internet address
to which the form will be submitted. Default: none
taborder
(Integer) Specifies the tab order of the field relative to other fields. Fields with smaller numbers will be
reached before fields with higher numbers. Default: 10 plus the maximum taborder used on the current
page (and 10 for the first field on the page); the result of this default is that the creation order will specify
the tab order.
toggle
(Boolean; only for create_fieldgroup( ) and type=radiobutton) If true, a radio button within a group
can be activated and deactivated by clicking. If false, it can only be activated by clicking, and deactivating by clicking another button. Default: false
tooltip2
(Hypertext string) The text visible in the field’s tooltip. For radio buttons and groups Acrobat will always
use the tooltip of the first button in the group, others will be ignored. Default: none
topindex
(Integer; only for type=listbox) Index of the first visible entry. The first item has index 0. Default: 0
unisonselect
(Boolean; only for create_fieldgroup( ), type=radiobutton and PDF 1.5) If true, radio buttons with the
same field name or item name will be selected simultaneously. Default: false
usercoordinates
(Boolean) If false, field coordinates will be expected in the default coordinate system; otherwise the current user coordinate system will be used. Default: the value of the global usercoordinates parameter
1. Templates for icons can be created with the begin_template_ext( ) function; if the icon consists of an image only you can create the
template by supplying the template option to load_image( ).
2. For type=radiobutton this option should not be used with create_field( ), but only with create_fieldgroup( ).
12.5 Form Fields
193
12.6 Bookmarks
VB RB Function create_bookmark(text As String, optlist As String) As Long
C# int create_bookmark(String text, String optlist)
Create a bookmark subject to various options.
text
(Hypertext string) Contains the text of the bookmark.
optlist An option list specifying the bookmark’s properties. The following options can
be used:
> General option: errorpolicy (see Table 2.6)
> Bookmark control options according to Table 12.11:
action, destination, destname, fontstyle, index, open, parent, textcolor
Returns A handle for the generated bookmark, which may be used with the parent option in subsequent calls.
Details This function adds a PDF bookmark with the supplied text. Unless the destination option
has been specified the bookmark will point to the current page (or the last page if used
in document scope, or the first page if used before the first page).
Creating bookmarks sets the openmode option of begin/end_document( ) to bookmarks
unless another mode has explicitly been set.
Scope document, page
Table 12.11 Options for create_bookmark( )
option
explanation
action
(Action list) List of bookmark actions for the following event. Default: GoTo action with the target specified in the destination option.
activate
Actions to be performed when the bookmark is activated. All types of actions are permitted.
destination
(Option list; will be ignored if an activate action has been specified) Option list specifying the bookmark
destination according to Table 12.5. Default: {type fitwindow page 0} if destination, destname, and
action are absent.
destname
(Hypertext string; may be empty; will be ignored if the destination option has been specified) Name of
a destination which has been defined with add_nameddest( ). Destination or destname actions will be
dominant over this option. If destname is an empty string (i.e. {}) and neither destination nor action
are specified, the bookmark won’t have any action, which may be useful if the bookmark serves as a separator.
fontstyle
(Keyword) Specifies the font style of the bookmark text: normal, bold, italic, bolditalic. Default:
normal
index
(Integer) Index where to insert the bookmark within the parent. Values between 0 and the number of
bookmarks of the same level will be used to insert the bookmark at that specific location within the parent. The value -1 can be used to insert the bookmark as the last one on the current level. Default: -1. However, for inserted or resumed pages bookmarks will be placed as if all pages had been generated in their
physical order (the bookmarks will reflect the page order).
open
(Boolean) If false, subordinate bookmarks will not be visible. If true, all children will be folded out. Default: false
194
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.11 Options for create_bookmark( )
option
explanation
parent
(Bookmark handle) The new bookmark will be specified as a subordinate of the bookmark specified in
the handle. If parent=0 a new top-level bookmark will be created. Default: 0
textcolor
(Color) Specifies the color of the bookmark text. Supported color spaces: none, gray, rgb.
Default: rgb {0 0 0} (=black)
12.6 Bookmarks
195
12.7 PDF Packages and Portfolios
VB RB Function add_portfolio_folder(parent As Long, foldername As String, optlist As String) As Long
C# int add_portfolio_folder(int parent, String foldername, String optlist)
Add a folder to a new or existing portfolio (requires PDF 1.7ext3).
parent The parent folder, specified by a folder handle returned by an earlier call to
add_portfolio_folder( ), or -1 for the root folder.
foldername (Hypertext string with 1-255 characters; the characters / \ : * " < > | must not
be used; the last character must not be a period ’.’) Name of the folder. Two folders with
the same parent must not have the same name after case normalization. The name of
the root folder will be ignored by Acrobat.
optlist An option list specifying portfolio properties. The following options can be
used:
> General options: errorpolicy (see Table 2.6)
> Portfolio options according to Table 12.12: description, fieldlist, thumbnail
Returns A handle which can be used in add_portfolio_folder( ) or add_portfolio_file( ).
Details The generated folder structure will be used to create a PDF portfolio for the current document. The folder structure will be deleted after end_document( ). This function must
not be used if the attachments option has been supplied to begin_document( ).
Scope document
Table 12.12 Options for add_portfolio_folder( )
option
explanation
description
(Hypertext string) Description of the folder
fieldlist
(List of option lists) Specify metadata fields for the folder. Each list refers to a field in the schema suboption of the portfolio option of end_document( ). Supported suboptions are listed in Table 12.14.
thumbnail
(Image handle) Specifies an image to be used as thumbnail for the folder. The handle must have been
created with load_image( ) and the image must satisfy the conditions listed for add_thumbnail( ).
VB RB Function add_portfolio_file(folder As Long, filename As String, optlist As String) As Long
C# int add_portfolio_file(int folder, String filename, String optlist)
Add a file to a portfolio folder or a package (requires PDF 1.7).
folder A folder handle returned by an earlier call to add_portfolio_folder( ) or -1 for the
root folder. Folders different from the root folder require PDF 1.7ext3.
filename (Name string; will be interpreted according to the global filenamehandling option or parameter, see Table 2.2) Name of a disk-based or virtual file which will be attached to the specified folder of the PDF portfolio. With the createpvf option of begin_
document( ) you can create documents in memory and pass them on for inclusion in a
PDF Portfolio without creating any temporary files on disk.
196
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Note that Acrobat will use the file name suffix to determine which application to
launch when interacting with the file in Acrobat. If a file name with the appropriate suffix cannot be used due to external restrictions you can create a PVF file (which supports
arbitrary file names) instead.
optlist An option list specifying file properties:
> General options: errorpolicy (see Table 2.6)
> Options for file properties according to Table 12.13:
description, fieldlist, mimetype, name, password, thumbnail
Returns The value 1 if the file could be added successfully, or an error code of -1 if the function
call failed. If errorpolicy=exception this function will throw an exception in case of an error. PDF documents will be opened to fetch the modification and creation dates. If the
PDF document cannot be opened (e.g. because no password was supplied) the document
will be included in the PDF portfolio nevertheless.
Details The specified file will be attached to the specified folder of a PDF 1.7ext3 portfolio or a
PDF 1.7 package. If PDI is available, PDF documents will be opened if possible and their
creation and modification dates will be written to the portfolio. This function must not
be used if the attachments option has been supplied to begin_document( ).
Scope document
Table 12.13 Options for add_portfolio_file( )
option
explanation
description
(Hypertext string) Descriptive text associated with the file.
fieldlist
(List of option lists) Specify metadata fields for the file. Each list refers to a field in the schema suboption
of the portfolio option of end_document( ). Supported suboptions are listed in Table 12.14.
mimetype
(String) MIME type of the file. Note that Acrobat will use the filename suffix instead of the MIME type for
launching the appropriate application when the file is activated. The MIME type application/pdf will
be set automatically if the file can successfully be opened as PDF document.
name
(Hypertext string) Name of the file to be used in the portfolio if a name different from filename is desired. It is recommended to use names with the usual type-specific suffixes (e.g. .pdf) to make sure that
Acrobat will properly preview PDF documents and launch the appropriate application for other file types.
Two file names in the same folder must be different after case normalization. It is recommended to avoid
slash characters ’/’ in the name since Acrobat will drop all characters before the slash. Default: filename
without any path components.
password
(String with up to 127 characters; only if PDI is available) PDF master password required to open a protected PDF document for fetching its date entries.
thumbnail
(Image handle) Specifies an image to be used as thumbnail for the file. The handle must have been created with load_image( ) and the image must satisfy the conditions listed for add_thumbnail( ).
12.7 PDF Packages and Portfolios
197
Table 12.14 Suboptions of the fieldlist option of add_portfolio_folder( ) and add_portfolio_file( )
option
explanation
key
(String; required) Name of the field, which must refer to a key in the schema suboption of the portfolio
option list of end_document( ). The name must be unique.
prefix
(Hypertext string) A prefix string which will be prepended to the field value presented to the user. Acrobat will use this entry only if type=text. Default: none
type
(Keyword) Data type of the field. Supported keywords (default: text):
value
198
text
Text field: the field value will be stored as hypertext string.
date
Date field: the field value will be stored as PDF date string.
number
Number field: the field value will be stored as PDF number.
(Hypertext string; required) Specifies the value of a field in the schema suboption of the portfolio option
list of end_document( ). The data type must be specified in the type option and must match the corresponding type suboption of the schema suboption of the portfolio option.
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
Table 12.15 Suboptions of the portfolio option of end_document( )
option
explanation
coversheet
(Hypertext string) The name of the file within the portfolio which will be initially presented in the user
interface. Default: the document which contains the portfolio
coversheetfolder
(Folder handle) The name of the folder within the portfolio which contains the file specified in the
coversheet option. If a file with the coversheet name exists in multiple portfolio folders and no
coversheetfolder has been specified, the first occurrence will be used. Default: none
initialview
(Keyword) Specifies the initial view. Supported keywords (default: detail):
schema
sort
detail
The portfolio is presented in details mode, with all information in the schema option
presented in a multi-column format. This mode provides the most information to the user
(Acrobat: »View top«).
tile
The portfolio is presented in tile mode, with each file in the collection denoted by a small icon
and a subset of information from the schema option. This mode provides top-level
information about the file attachments to the user (Acrobat: »View left«).
hidden
The portfolio is initially hidden, without preventing the user from obtaining a file list via
explicit action (Acrobat: »Minimize view«).
(List of option lists) Metadata schema for the portfolio: each option list defines a field with a unique
name which corresponds to a key in the fieldlist of a folder or file, or to the name of a standard field.
These fields define the display behavior of the portfolio in Acrobat (default: Acrobat displays the file
name and size, modification date, and description if specified):
editable
(Boolean) Specifies whether Acrobat should allow editing the field value. Default: false
key
(String; required) The internal field name, which must be unique.
The following names (which can not be used for user-defined fields) can be used to assign
new labels to the builtin fields: _creationdate, _description, _filename, _moddate, _size.
label
(Hypertext string; required) The textual field label that is displayed to the user.
order
(Integer) Relative order of the fields in the user interface (1,2,3,...)
type
(Keyword) Data type of the field. The following types can be used to refer to user-defined
fields in the fieldlist option (default: text):
text
hypertext string
date
PDF date string
number number
visible
(Boolean) Initial visibility of the field in the user interface. Default: true; however, in the
presence of user-defined fields Acrobat will hide builtin fields unless they are explicitly
specified as visible.
(List of option lists, where each list contains a string and an optional keyword) Specifies the order in
which the fields specified in the schema option will be sorted in the user interface. Each sublist contains
the field name (required) and a keyword. Supported keywords (Default: ascending):
ascending field values are sorted in ascending order
descending field values are sorted in descending order
Acrobat uses this list to sort the fields in the portfolio. The list is used to allow additional fields to contribute to the sort, where each additional field is used to break ties: if multiple fields in the schema option
have the same value for the first field in the list, the values for successive fields in the list are used for
sorting until a unique order is determined or until the field names are exhausted. Default: no sorting
12.7 PDF Packages and Portfolios
199
Table 12.15 Suboptions of the portfolio option of end_document( )
option
explanation
split
(Option list; PDF 1.7ext3) Specifies the orientation and position of the splitter bar. The default depends on
the initialview option: The value detail (or no value) implies horizontal orientation and tile indicates vertical orientation. No splitter is used if initalview=hidden. Supported suboptions:
200
direction
(Keyword) Orientation of the splitter bar. Supported keywords:
horizontal Split the window horizontally.
vertical
Split the window vertically.
none
Don’t split the window. The entire window is dedicated to the file navigation
view.
position
(Percentage) Initial position of the splitter bar, specified as a percentage of the available
window area. Allowed values are in the range from 0 to 100. This entry will be ignored if
direction=none. Default: viewer dependent
Chapter 12: Interactive Features (Edition for COM, .NET, and REALbasic)
13 3D and Geospatial Features
13.1 3D Artwork
Cookbook A full code sample can be found in the Cookbook topic multimedia/starter_3d.
VB RB Function load_3ddata(filename As String, optlist As String) As Long
C# int load_3ddata(String filename, String optlist)
Load a 3D model from a disk-based or virtual file (requires PDF 1.6).
filename (Name string; will be interpreted according to the global filenamehandling option or parameter, see Table 2.2) Name of a disk-based or virtual file containing a 3D
model.
optlist An option list specifying properties of the 3D model:
> General option: errorpolicy (see Table 2.6)
> Options for specifying properties of the 3D model according to Table 13.1:
defaultview, script, type, views
Returns A 3D handle which can be used to create 3D annotations with create_annotation( ). The
3D handle can be used until the end of the enclosing document scope. If
errorpolicy=return the caller must check for a return value of -1 since it signals an error.
Details The file containing 3D data will be loaded. There is no error checking on the 3D data. The
following 3D file formats are supported
> Acrobat 7.0.7 or above: ECMA-363, Universal 3D File Format (U3D), 1st Edition1
> Acrobat 8.1 or above: ECMA-363, Universal 3D File Format (U3D), 3rd Edition
Scope page, document. The returned handle can be used until the next call to end_document( ).
Table 13.1 Options for load_3ddata( )
option
explanation
defaultview
(Keyword or 3D view handle) Specifies the initial view of the 3D annotation; One of the keywords first
or last (referring to the respective entries in the views option), or a 3D view handle created with create_
3dview( ). Default: first
script
(Hypertext string) String containing JavaScript code to be executed when the 3D model is instantiated.
Default: no script
type
(Keyword) Specify the type of 3D data (default: U3D):
U3D
views
Universal 3D File Format
(list of 3D view handles) List of predefined views for the 3D model. Each list element is a 3D view handle
created with create_3dview( ). Default: empty list
1. See www.ecma-international.org
13.1 3D Artwork
201
VB RB Function create_3dview(username As String, optlist As String) As Long
C# int create_3dview(String username, String optlist)
Create a 3D view (requires PDF 1.6).
username
(Hypertext string) User interface name of the 3D view.
optlist An option list specifying 3D view properties:
> General options: errorpolicy (see Table 2.6)
> Options for specifying 3D view properties according to Table 13.2:
background, camera2world, cameradistance, name
Returns A 3D view handle which can be used until the end of the enclosing document scope. If
errorpolicy=return the caller must check for a return value of -1 since it signals an error.
Details The 3D view handle can be attached to 3D models with the views option in load_3ddata( )
or can be used to create 3D annotations with create_annotation( ) or 3D-related actions
with create_action( ).
Scope page, document. The returned handle can be used until the next call to end_document( ).
Table 13.2 Options for create_3dview( )
option
explanation
background
(Option list) Specifies the background for the 3D model:
fillcolor
(Color) Background color, expressed in the RGB color space. Default: white
entire
(Boolean) If true, the background applies to the entire annotation; otherwise it applies only
to the rectangle specified in the annotations’s 3Dbox option. Default: false
camera2world
(List of 12 floats) 3D transformation matrix specifying position and orientation of the camera in world coordinates. For details see description of the C2W key in section 13.6.4 »3D Views« of ISO 32000-1. Default:
defined internally in the 3D data
cameradistance
(Float; must not be negative; will be ignored if camera2world is not specified) Distance between the camera and the center of the orbit. For details see description of the CO key in section 13.6.4 »3D Views« of ISO
32000-1. Default: defined internally in the 3D data
lighting
(Option list; PDF 1.7) Specifies the lighting scheme for the 3D artwork. The following option is supported:
type
(Keyword) Specifies the lighting scheme. Supported keywords (Default: Artwork):
Artwork Lights are specified in the 3D artwork.
None
No lights; lights specified in the 3D artwork will be ignored.
White
Three light-grey infinite lights, no ambient term
Day
Three light-grey infinite lights, no ambient term
Night
One yellow, one aqua, and one blue infinite light, no ambient term
Hard
Three grey infinite lights, moderate ambient term
Primary One red, one green, and one blue infinite light, no ambient term
Blue
Three blue infinite lights, no ambient term
Red
Three red infinite lights, no ambient term
Cube
Six grey infinite lights aligned with the major axes, no ambient term
CAD
Three grey infinite lights and one light attached to the camera, no ambient term
Headlamp Single infinite light attached to the camera, low ambient term
name
(Hypertext string) Name of the 3D view, which can be used in GoTo actions. This is an optional internal
name which is treated separately from the required username parameter.
rendermode
(Option list; PDF 1.7) Specifies the render mode for displaying the 3D artwork. Table 13.3 lists the supported suboptions.
202
Chapter 13: 3D and Geospatial Features (Edition for COM, .NET, and REALbasic)
Table 13.2 Options for create_3dview( )
option
explanation
U3Dpath
(Hypertext string) A View Node name used to access a view node within the 3D artwork. Will be ignored
if the camera2world option is specified.
Table 13.3 Suboptions for the rendermode option of create_3dview( )
option
explanation
crease
(Float in the range 0..180) crease value
facecolor
(RGB color or keyword; only for type=Illustration) Face color; this color will be used by several render
modes. The keyword backgroundcolor refers to the current background color. Default:
backgroundcolor
opacity
(Float in the range 0..1) Opacity for some render modes. Default: 0.5
rendercolor
(RGB color) Auxiliary color. This color will be used by several render modes. Default: black
13.1 3D Artwork
203
Table 13.3 Suboptions for the rendermode option of create_3dview( )
option
type
explanation
(Option list; PDF 1.7) Specifies the render mode for displaying the 3D artwork. Supported options:
(Keyword) Specifies the render mode. Supported keywords (Default: Artwork):
Artwork
Render mode is specified in the 3D artwork; all other suboptions of the rendermode option
will be ignored.
Solid
Displays textured and lit geometric shapes.
SolidWireframe
Displays textured and lit geometric shapes (triangles) with single color edges on top of
them.
Transparent Displays textured and lit geometric shapes (triangles) with an added level of transparency.
TransparentWireframe
Displays textured and lit geometric shapes (triangles) with an added level of transparency.
BoundingBox
Displays textured and lit geometric shapes (triangles) with an added level of transparency,
with single color opaque edges on top of it.
TransparentBoundingBox
Displays bounding boxes faces of each node, aligned with the axes of the local coordinate
space for that node, with an added level of transparency.
TransparentBoundingBoxOutline
Displays bounding boxes edges and faces of each node, aligned with the axes of the local
coordinate space for that node, with an added level of transparency.
Wireframe
Displays bounding boxes edges and faces of each node, aligned with the axes of the local
coordinate space for that node, with an added level of transparency.
ShadedWireframe
Displays only edges, though interpolates their color between their two vertices and applies
lighting.
HiddenWireframe
Displays edges in a single color, though removes back-facing and obscured edges.
Vertices
Displays only vertices in a single color.
ShadedVertices
Displays only vertices, though uses their vertex color and applies lighting.
Illustration Displays silhouette edges with surfaces, removes obscured lines.
SolidOutline Displays silhouette edges with lit and textured surfaces, removes obscured lines.
ShadedIllustration
Displays silhouette edges with lit and textured surfaces and an additional emissive term to
remove poorly lit areas of the artwork.
204
Chapter 13: 3D and Geospatial Features (Edition for COM, .NET, and REALbasic)
13.2 Geospatial Features
Note Acrobat 9 or above is required for interacting with geospatial data in PDF.
Geospatial features are implemented with the following functions and options:
> One or more georeferenced areas can be assigned to a page with the viewports option
of begin/end_page_ext( ).
> The georeference option of load_image( ) can be used to assign an earth-based coordinate system to an image.
Table 13.4 and subsequent tables specify the options for geospatial features in detail.
Table 13.4 Suboptions for the viewports option of begin/end_page_ext( )
option
explanation
boundingbox
(Rectangle; required) A rectangle in default coordinates specifying the location of the viewport on the
page.
georeference (Option list; required) Specifies the description of a world coordinate system associated with the viewport to use for geospatial measuring; see Table 13.5 for supported options.
name
(Hypertext string) A descriptive title of the viewport (map name). However, Acrobat does not display the
viewport name in the user interface.
Table 13.5 Suboptions for the georeference option of load_image( ) and the georeference suboption of the viewports
option of begin/end_page_ext( )
option
explanation
angularunit
(Keyword) Specifies the preferred angular display unit (default: deg):
areaunit
degree
degrees
grad
grad (1/400 of the full circle, or 0.9 degrees)
(Keyword) Specifies the preferred area display unit (default: sqm):
sqm
square meter
ha
hectar (10.000 square meters)
sqkm
square kilometer
sqft
square foot
a
acre
sqmi
square mile
The specified unit will be used for display only if the following Acrobat setting is disabled: »Preferences,
Measuring (Geo), Use Default Area Unit«.
bounds
(Polyline with two or more points) Specifies the bounds of an area for which the geospatial transformations are valid (for maps this bounding polyline is known as a neatline). The points are expressed relative
to the boundingbox of a page viewport or the extent of an image. Default: {0 0 0 1 1 1 1 0}, i.e. the
full viewport or image area will be used for the map.
displaysystem
(Option list) Specifies a coordinate system according to Table 13.6 for the user-visible display of position
values, such as latitude and longitude. This entry can be used to display the coordinates in another system than the one supplied in the coords option to specify the map.
13.2 Geospatial Features
205
Table 13.5 Suboptions for the georeference option of load_image( ) and the georeference suboption of the viewports
option of begin/end_page_ext( )
option
explanation
linearunit
(Keyword) Specifies the preferred linear display unit (default: m):
m
meter
km
kilometer
ft
international foot
usft
US survey foot
mi
international mile
nm
nautical mile
The specified unit will be used for display only if the following Acrobat setting is disabled: »Preferences,
Measuring (Geo), Use Default Distance Unit«.
mappoints
(List with two or more pairs of floats; required) A list of numbers where each pair defines a point in a 2D
unit square. The unit square is mapped to the rectangular bounds of the page viewport or image which
contains the georeference option list. The mappoints list must contain the same number of points as
the worldpoints list; each point is the map position in the unit square corresponding to the geospatial
position in the worldpoints list.
worldpoints
(List with two or more pairs of floats; required) A list of coordinate pairs where each pair specifies the
world coordinates of the corresponding point in the mappoints option. The number of pairs must match
the number of pairs in the mappoints option. The coordinate values are based on the coordinate system
specified in the worldsystem option: if type=geographic, latitude/longitude values in degrees must be
provided. If type=projected, projected x/y values must be provided.
worldsystem (Option list; required) World coordinate system (for interpretation of worldpoints) according to Table
13.6.
Table 13.6 Suboptions for the mapsystem and displaysystem suboptions of the georeference option of load_image( )
and the georeference suboption of the viewports option of begin/end_page_ext( )
option
explanation
epsg
(Integer; exactly one of epsg or wkt must be supplied) Specifies the coordinate system as an EPSG reference code. Note that Acrobat 9 does not support EPSG codes for type=geographic; use wkt in this case.
type
(Keyword; required) Specifies the type of the coordinate system:
geographic geographic coordinate system (supports only wkt)
projected projected coordinate system (supports wkt and epsg)
wkt
206
(String with up to 1024 ASCII characters; exactly one of epsg or wkt must be supplied) Specifies the coordinate system as a string of »Well Known Text« (WKT). WKT is recommended for custom coordinate systems without any EPSG code and seems to be required in Acrobat 9 if type=geographic.
Chapter 13: 3D and Geospatial Features (Edition for COM, .NET, and REALbasic)
14 Document Interchange
14.1 Document Information Fields
VB RB Sub set_info(key As String, value As String)
C# void set_info(String key, String value)
Fill document information field key with value.
key (Name string) The name of the document info field, which may be any of the standard names, or an arbitrary custom name (see Table 14.1). There is no limit for the number of custom fields. Regarding the use and semantics of custom document information
fields, PDFlib users are encouraged to take a look at the Dublin Core Metadata element
set.1
value (Hypertext string) The string to which the key parameter will be set. Acrobat imposes a maximum length of value of 255 bytes. Note that due to a bug in Adobe Reader 6
for Windows the & character does not display properly in some info strings.
Details The supplied info value will only be used for the current document, but not for all documents generated within the same object scope. If the autoxmp option has been supplied
to begin/end_document( ) PDFlib will automatically create synchronized XMP document
metadata from the info entries supplied to set_info( ).
The document info entries will be overwritten by XMP document metadata supplied
to the metadata option of begin/end_document( ).
Scope any. If used in object scope the supplied values will only be used for the next document.
Table 14.1 Values for the document information field key
key
explanation
Subject
Subject of the document
Title
Title of the document. This entry must be supplied in PDF/X mode.
Creator
Software used to create the document (as opposed to the Producer of the PDF output, which is always PDFlib). Acrobat will display this entry as »Application«. This
entry must be supplied in PDF/X mode.
Author
Author of the document
Keywords
Keywords describing the contents of the document
Trapped
Indicates whether trapping has been applied to the document. Allowed values are
True, False, and Unknown. In PDF/X mode Unknown is not allowed.
1. See dublincore.org
14.1 Document Information Fields
207
Table 14.1 Values for the document information field key
key
explanation
any other name
User-defined document information field. PDFlib supports an arbitrary number of
fields. A custom field name should only be supplied once. With multiple occurrences of the same field name the last one will be used. See also moddate option of
begin/end_document( ).
Custom document info fields must not contain any space character if XMP metadata is created (via the autoxmp or metadata options).
Fields which are used for standard identification will be rejected.
208
Chapter 14: Document Interchange (Edition for COM, .NET, and REALbasic)
14.2 XMP Metadata
As an alternative or in addition to document information fields PDFlib supports XMP
(Extensible Metadata Platform1) as a framework for specifying metadata. XMP is required,
for example, for PDF/A compliance, and is supported by an increasing number of applications. There are several flavors of XMP support in PDFlib as detailed below.
Automatic XMP synchronization for document info fields. If the autoxmp option in
begin/end_document( ) is true, PDFlib will synchronize document information fields supplied to set_info( ) as well as several internally generated entries (e.g. CreationDate) to the
corresponding entries in the document-level XMP metadata.
Document info fields which correspond to a well-known element in one of the standard XMP schemas will be placed in the appropriate schema. Unknown info fields will
usually be placed in the extended PDF (pdfx) schema, but will be ignored in PDF/A mode.
User-supplied XMP streams. Users can supply full or partial XMP metadata streams to
the metadata option of various functions. This option expects an XMP stream and will
validate it. PDFlib will automatically generate the XDP packet header and trailer.
Cookbook A simple XMP sample can be found in the Cookbook topic interchange/embed_xmp.
For document-level metadata PDFlib will add several internally generated properties
(e.g. CreationDate). In PDF/A mode PDFlib will synchronize relevant entries in user-supplied XMP streams to standard document info fields (analogous to autoxmp mode
which synchronizes document info fields to XMP). However, PDFlib will not synchronize other XMP entries to custom document info fields. Additional requirements for
XMP document metadata for PDF/A are discussed in the PDFlib Tutorial.
In addition to document-level metadata, XMP can be supplied for pages, fonts, ICC
profiles, images, templates, and imported PDF pages. Table 14.2 lists suboptions for the
metadata option of various functions. Example:
metadata={filename=info.xmp inputencoding=winansi}
Table 14.2 Suboptions for the metadata option in begin/end_document( ), begin/end_page_ext( ), load_font( ), load_
iccprofile( ), load_image( ), begin_template_ext( ), open_pdi_page( )
option
description
compress
(Boolean; not for begin/end_document( )) Compress the XMP metadata stream in the PDF output. If the
option is only supplied in begin_page_ext( ) but not in end_page_ext( ), its value takes precedence over
the default. Default: false
PDF/A and PDF/X: compress=true is not allowed.
inputencoding (Keyword) The encoding to interpret the metadata supplied in filename. Default: unicode
inputformat
(Keyword) The format of the metadata supplied in filename. Default: utf8, but bytes if inputencoding
is an 8-bit encoding
keepxmp
(Boolean; only for load_image( ); can not be combined with filename) XMP metadata present in an image will be kept, i.e. attached to the resulting image in the PDF document. XMP metadata is honored in
the TIFF, JPEG, and JPEG 2000 image formats. If no XMP metadata is found in the image file this option
doesn’t have any effect. Default: false
filename
(Name string; required unless keepxmp is supplied) The name of a file containing well-formed XMP metadata. It will be interpreted according to the global filenamehandling option or parameter, see Table 2.2.
1. See www.adobe.com/products/xmp
14.2 XMP Metadata
209
14.3 Tagged PDF
The tagged option in begin_document( ) must have been set to true in order to generate
Tagged PDF. The lang option must be provided as well. Tagged PDF mode will automatically be activated if the pdfa document option has been set to PDF/A-1a:2005.
Cookbook A full code sample can be found in the Cookbook topic interchange/starter_tagged.
VB RB Function begin_item(tag As String, optlist As String) As Long
C# int begin_item(String tag, String optlist)
Open a structure element or other content item with attributes supplied as options.
tag The item’s element type according to Table 14.3:
> standard element types
> pseudo element types which are not structure elements
> The tag name Plib_custom_tag implies use of a custom element type; the actual tag
name must be supplied in the tagname option.
Table 14.3 Standard, pseudo, and custom types for begin_item( ), begin_mc( ), and mc_point( )
category
tags
standard element types
grouping
Document, Part, Art, Sect, Div, BlockQuote, Caption, TOC, TOCI, Index, NonStruct, Private
paragraphlike
P, H, H1-H6 (BLSEs)
list
L, LI, Lbl, LBody (BLSEs)
table
Table (BLSE), TR, TH, TD, THead1, TBody1, TFoot1
inline-level
Span, TagSuspect2, Quote, Note, Reference, BibEntry, Code, (ILSEs)
illustration
Figure, Formula, Form
Japanese
Ruby1 (grouping), RB1, RT1, RP1, Warichu1 (grouping), WT1, WP1
pseudo element types
nonstructural
elements
Artifact
Specifies an artifact, to be distinguished from real page content.
ASpan
(Accessibility span; will be written to PDF as Span, but must be distinguished from the inlinelevel item Span) Can be used to attach accessibility properties to content which does not
belong to a structure element, or which resembles only a fraction of a structure element.
ReversedChars
(Not recommended) Specifies text in a right-to-left language with reversed characters.
Clip
Specifies a marked clipping sequence. This is a sequence containing only clipping paths or text
in rendering mode 7, but no visible graphics or save( ) / restore( ).
custom element types
user-defined
elements
The tag name Plib_custom_tag must be supplied in the tagname parameter. The actual tag name
which will be written to PDF must be supplied in the tagname option.
1. Requires PDF 1.5 or above
2. Requires PDF 1.6 or above
210
Chapter 14: Document Interchange (Edition for COM, .NET, and REALbasic)
optlist An option list specifying details of the item. All inheritable settings will be inherited to child elements, and therefore need not be repeated. All properties of an item
must be set here since they cannot be modified later. The following options can be used:
> Tag control options according to Table 14.4:
ActualText, Alt, artifactsubtype, artifacttype, Attached, BBox, ColSpan, E, index, inline,
Lang, parent, RowSpan, Scope, tagname, Title
Returns An item handle which can be used in subsequent item-related calls.
Details This function generates the document’s structure tree, which is essential for Tagged
PDF. The position of the new element in the structure tree can be controlled with the
parent and index options. Structure elements can be nested to an arbitrary level. Regular
items are not bound to the page where they have been opened, but can be continued on
an arbitrary number of pages.
Scope page for inline items, and for regular items also document; must always be paired with a
matching end_item( ) call. This function is only allowed in Tagged PDF mode.
Table 14.4 Options for structure and pseudo tags for begin_item( ), begin_mc( ), and mc_point( )
option
explanation
ActualText
(Hypertext string; not for pseudo tags except in PDF 1.5 with ASpan; not for TagSuspect) Equivalent replacement text for the content item. It should be provided for text content which is represented in some
non-standard way, such as ligatures, swash characters in illustrations, drop caps, etc. If this option is
used in PDF 1.4 mode the inline option must be set to false.
Alt
(Hypertext string; not for pseudo tags except in PDF 1.5 with ASpan; not for TagSuspect) Alternate description for the content item. It should be provided for figures, images, etc., which cannot be recognized
as text. Alternate text for images is required for accessibility. If this option is used in PDF 1.4 mode the
inline option must be set to false.
artifactsubtype
(Keyword; tag=Artifact and artifacttype=Pagination; PDF 1.7) Subtype of the artifact: Header,
Footer, Watermark
artifacttype
(Keyword; only for tag=Artifact) Identifies the artifact type of the content item: Pagination, Layout,
Page, Background (PDF 1.7)
Attached
(Keyword list; only for tag=Artifact and artifacttype=Pagination or artifacttype=Background with
full-page background artifacts) A list containing one to four of the keywords Top, Bottom, Left, and
Right
BBox
(Rectangle; only for tag=Artifact as well as all table and illustration tags; required for artifacttype=
Background, otherwise optional, but recommended for reflow) The artifact’s bounding box in the default
coordinate system (if usercoordinates=false) or the user coordinate system (if usercoordinates=true). If this option has not been supplied PDFlib will automatically create a BBox entry for imported images and PDF pages.
ColSpan
(Integer; only for tag=TH and TD) Number of table columns spanned by a cell.
E
(Hypertext string; not for pseudo tags except ASpan; not for TagSuspect; requires PDF 1.5 for structure
tags) Abbreviation expansion for the content item. It should be provided for explaining abbreviations
and acronyms. Acrobat’s Read Aloud feature will consider the expansion text as a separate word even in
the absence of explicit word breaks.
index
(Integer; not for pseudo tags and TagSuspect) The index at which to insert the element within the parent. Values between 0 and the current number of children will be used to insert the item at that specific
location within the parent. The value -1 can be used to insert the element as the last item. Default: -1
inline
(Boolean; only for tag=ASpan and all inline-level tags except TagSuspect) If true, the content item will
be written inline, and no structure element will be created. Default: true
14.3 Tagged PDF
211
Table 14.4 Options for structure and pseudo tags for begin_item( ), begin_mc( ), and mc_point( )
option
explanation
Lang
(String; not for TagSuspect and pseudo tags except ASpan) Language identifier for the content item in
the format described in Table 3.1 for the lang option. This can be used to override the document’s dominant language for individual content items.
parent
(Item handle; not for TagSuspect and pseudo tags) The item handle of the element’s parent, as returned
by another call to begin_item( ). The value 0 refers to the structure tree root. -1 refers to the parent of the
most recently opened element on the current page. In other words, parent=-1 opens a sibling of the current element. Default: -1
RowSpan
(Integer; only for tag=TH and TD) The number of table rows spanned by a cell.
Scope
(Keyword; only for tag=TH; PDF 1.5 or above) One of the keywords Row, Column, or Both indicating whether
the header cell applies to the rest of the cells in the row that contains it, the column that contains it, or
both the row and the column that contain it.
tagname
(Name string; only for tag=Plib_custom_tag, and required in this case) Arbitrary name of a custom tag
for which a mapping to a standard element type must have been defined with the rolemap option of
begin_document( ). Custom element types are restricted to 127 winansi characters or a sequence containing arbitrary Unicode characters provided the length of the corresponding UTF-8 sequence does not exceed 127 bytes.
Title
(Hypertext string; not for inline and pseudo tags) Name of the structure element
VB RB Sub end_item(id As Long)
C# void end_item(int id)
Close a structure element or other content item.
id
The item’s handle, which must have been retrieved with begin_item( ).
Details All inline items must be closed before the end of the page. All regular items must be
closed before the end of the document. However, it is strongly recommended to close all
regular items as soon as they are completed to reduce memory consumption. An item
can only be closed if all of its children have been closed before. After closing an item its
parent will become the active item.
Scope page for inline items, and for regular items also document; must always be paired with a
matching begin_item( ) call. This function is only allowed in Tagged PDF mode.
VB RB Sub activate_item(id As Long)
C# void activate_item(int id)
Activate a previously created structure element or other content item.
id The item’s handle, which must have been retrieved with begin_item( ), and must not
yet have been closed. Pseudo and inline-level items can not be activated.
Details Putting aside a structure element and activating it later gives additional flexibility for
efficiently creating Tagged PDF pages even when there are multiple parallel structure
branches on a page, e.g. with multi-column layouts or text inserts which interrupt the
main text.
Scope document, page; This function is only allowed in Tagged PDF mode.
212
Chapter 14: Document Interchange (Edition for COM, .NET, and REALbasic)
14.4 Marked Content
VB RB Sub begin_mc(tag As String, optlist As String)
C# void begin_mc(String tag, String optlist)
Begin a marked content sequence with optional properties.
tag The name of the marked content sequence. The following tags are supported:
> All inline-level and pseudo tags in Table 14.3.
> The tag Plib_custom can be used for custom entries with user-defined properties.
> The tag Plib is reserved.
optlist The following options for marked content sequences are supported:
> Options for standard properties of the according to Table 14.4.
> The tags Plib_custom and Plib additionally support the option in Table 14.5.
Details A marked content sequence with the specified tag and properties will be started. If no
options are provided a sequence without any properties will be created. Marked content
sequences can be nested to an arbitrary level. The user is responsible for creating properly nested sequences of begin/end_item( ) and begin/end_mc( ).
Scope page, pattern, template, glyph, must always be paired with a matching end_mc( ) call in
the same page, pattern, template, or glyph scope.
Table 14.5 Option for user-defined properties of tags with begin_mc( ) and mc_point( )
option
explanation
properties
(List of option lists; only for tag=Plib and tag=Plib_custom) Each list contains three options which specify a user-defined property:
key
(String; required) Name of the property.
type
(Keyword; required) Type of the property value: boolean, name, or string.
value
(Hypertext string if type=string, otherwise string; required) Value of the property.
VB RB Sub end_mc
C# void end_mc( )
End the least recently opened marked content sequence.
Details All marked content sequences must be closed before calling end_page_ext( ).
Scope page, pattern, template, glyph, must always be paired with a matching begin_mc( ) call in
the same page, pattern, template, or glyph scope.
VB RB Sub mc_point(tag As String, optlist As String)
C# void mc_point(String tag, String optlist)
Add a marked content point with optional properties.
tag The name of the marked content point. The following tags are supported:
> All inline-level and pseudo tags in Table 14.3.
> The tag Plib_custom can be used for custom entries.
14.4 Marked Content
213
> The tag Plib is reserved.
optlist The following options are supported:
> Options for standard properties of the marked content point according to Table 14.4.
> The tags Plib_custom and Plib additionally support the option in Table 14.5.
Details A marked content point with the specified tag and properties will be created. If no options are provided a marked content point without any properties will be created.
Scope page, pattern, template, glyph
214
Chapter 14: Document Interchange (Edition for COM, .NET, and REALbasic)
A List of all Functions
This appendix lists all API functions. Click on a function name to jump to the corresponding description.
General
Font
Text Formatting
Color
get_value
load_font
fit_textline
setcolor
set_value
close_font
info_textline
makespotcolor
get_parameter
setfont
add_textflow
load_iccprofile
set_parameter
info_font
create_textflow
begin_pattern
set_option
begin_font
fit_textflow
end_pattern
begin_document
end_font
info_textflow
shading_pattern
end_document
begin_glyph
delete_textflow
shfill
get_buffer
end_glyph
encoding_set_char
begin_page_ext
shading
Table Formatting
add_table_cell
Image
end_page_ext
Text Output
fit_table
load_image
suspend_page
set_text_pos
info_table
close_image
resume_page
show
delete_table
fit_image
define_layer
xshow
set_layer_dependency
show_xy
Matchboxes
begin_template_ext
begin_layer
continue_text
info_matchbox
end_template_ext
end_layer
stringwidth
info_image
add_thumbnail
create_pvf
delete_pvf
get_errnum
get_errmsg
get_apiname
Chapter A: List of all Functions
215
Graphics State
Path Construction
PDI
Interactive Features
setdash
moveto
open_pdi_document
create_action
setdashpattern
lineto
close_pdi_document
add_nameddest
setflat
curveto
open_pdi_page
create_annotation
setlinejoin
circle
close_pdi_page
create_field
setlinecap
arc
fit_pdi_page
create_fieldgroup
setmiterlimit
arcn
info_pdi_page
create_bookmark
setlinewidth
circular_arc
process_pdi
add_portfolio_folder
initgraphics
ellipse
save
rect
pCOS
restore
closepath
pcos_get_number
Multimedia
pcos_get_string
load_3ddata
pcos_get_stream
create_3dview
create_gstate
Path Painting and Clipping
set_gstate
add_portfolio_file
stroke
Coordinate Transformation
closepath_stroke
Block Filling (PPS)
Document Interchange
translate
fill
fill_textblock
set_info
scale
fill_stroke
fill_imageblock
begin_item
rotate
closepath_fill_stroke
fill_pdfblock
end_item
align
clip
activate_item
skew
endpath
begin_mc
concat
end_mc
setmatrix
Path Objects
add_path_point
draw_path
info_path
delete_path
216
Chapter A: List of all Functions (Edition for COM, .NET, and REALbasic)
mc_point
B List of all Parameters
This appendix lists all keywords for get/set_parameter( ) and get/set_value( ). Click on a
keyword to jump to the corresponding description.
setup
logging
font handling
simple text output
get/set_parameter( ):
get/set_parameter( ):
get/set_parameter( ):
get/set_parameter( ):
errorpolicy
logging1
Encoding
autospace
1
FontAFM
charref
filenamehandling
logmsg
license1
FontPFM
decorationabove
licensefile
versioning
FontOutline
escapesequence
nodemostamp
get/set_parameter( ):
HostFont
fakebold
21
resourcefile
version
get/set_value( ):
glyphcheck
scope
get/set_value( ):
font2
kerning
SearchPath1
major
fontsize2
underline, overline,
strikeout
string1
minor
revision2
image
get/set_value( ):
get/set_parameter( ):
charspacing
get/set_value( ):
page
honoriccprofile
horizscaling
compress
get/set_parameter( ):
renderingintent
italicangle
maxfilehandles
topdown
leading
get/set_value( ):
textrendering
graphics
pagewidth
textrise
get/set_parameter( ):
pageheight
textx2, texty2
fillrule
underlineposition
get/set_value( ):
ICC profiles
underlinewidth
currentx2, currenty2
get/set_parameter( ):
wordspacing
ctm_a2, ctm_b2, ctm_c2
ICCProfile
interactive
ctm_d2, ctm_e2, ctm_f2
StandardOutputIntent
get/set_parameter( ):
get/set_value( ):
usercoordinates
color
icccomponents2
get/set_parameter( ):
setcolor:iccprofilegray
preserveoldpantonenames
setcolor:iccprofilergb
spotcolorlookup
setcolor:iccprofilecmyk
PDI
get/set_parameter( ):
pdi1
1. Only for get_parameter( )
2. Only for get_value( )
B List of all Parameters
217
C List of all Options and Keywords
This index contains an alphabetical list of all options and keywords along with the functions in which they can be used. Click on the page number to jump to the description.
&
&name option list macro call in fit_textflow() 80
3D
3Dactivate in create_annotation() 181
3Ddata in create_annotation() 181
3Dinitialview in create_annotation() 181
3Dinteractive in create_annotation() 181
3Dshared in create_annotation() 181
3Dview in create_action() 174
A
acrobat suboption for fontname in info_font() 57
action
in begin/end_page_ext() 39
in create_annotation() 182
in create_bookmark() 194
in create_field() and create_fieldgroup() 190
in end_document() 30
in process_pdi() 162
actual suboption for encoding in info_font() 56
ActualText in begin_item() 211
addfitbox suboption for wrap in fit_textflow() 87
adjustmethod in add/create_textflow() 78
adjustpage
in fit_image/pdi_page() 148
in fit_pdi_page() 160
advancedlinebreak in add/create_textflow() 78
align in draw_path() 101
alignchar in fit/info_textline() 101
alignment
in add/create_textflow() 76
in create_annotation() 182
suboption for leader in fit/info_textline() and
add/create_textflow() 70
alphachannelname in load_image() 144
alphaisshape in create_gstate() 115
Alt in begin_item() 211
angle keyword in info_textline() 73
angularunit suboption for georeference 205
annotation suboption for targetpath in
create_action() 177
annotationtype in add_table_cell() 91
annotcolor in create_annotation() 182
antialias
in shading() 139
suboption for shading option of several
functions 111
api
suboption for encoding in info_font() 56
suboption for fontname in info_font() 57
area suboption for fill in fit_table() 95
areaunit suboption for georeference 205
artbox in begin/end_page_ext() 39
artifactsubtype in begin_item() 211
artifacttype in begin_item() 211
ascender
in info_font() 56
in load_font() 51
keyword in info_textline() 73
Attached in begin_item() 211
attachmentpassword in begin_document() 30
attachmentpoint in draw_path() 101
attachments in begin/end_document() 30
autocidfont in load_font() 51
autosubsetting in load_font() 51
autoxmp in begin/end_document() 30
avoidbreak in add/create_textflow() 78
avoidemptybegin in add/create_textflow() 76
B
background in create_3dview() 202
backgroundcolor in create_field() and
create_fieldgroup() 190
basestate in set_layer_dependency() 45
BBox in begin_item() 211
begoptlistchar in create_textflow() 81
beziers suboption for wrap in fit_textflow() 87
bitreverse in load_image() 144
bleedbox in begin/end_page_ext() 39
blendmode in create_gstate() 115
blind
in fit_table() 94
in fit_textflow() 83
in many functions 101
bordercolor in create_field() and
create_fieldgroup() 190
borderstyle
in create_annotation() 182
in create_field() and create_fieldgroup() 190
borderwidth in several functions 109
bottom in add_nameddest() and suboption for
destination in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 178
List of all Options
219
boundingbox
in shading() 139
keyword in info_image() 149
keyword in info_path() 128
keyword in info_pdi_page() 161
keyword in info_table() 96
keyword in info_textflow() 88
suboption for viewports option in begin/
end_page_ext() 205
bounds suboption for georeference 205
boxes suboption for wrap in fit_textflow() 87
boxheight suboption for matchbox 105
boxlinecount keyword in info_textflow() 88
boxsize in various functions 101
boxwidth suboption for matchbox 105
bpc in load_image() 144
buttonlayout in create_field() and
create_fieldgroup() 190
buttonstyle in create_field() and
create_fieldgroup() 190
C
calcorder in create_field() and
create_fieldgroup() 190
calloutline in create_annotation() 182
camera2world in create_3dview() 202
cameradistance in create_3dview() 202
canonicaldate in create_action() 174
capheight
in info_font() 56
in load_font() 51
keyword in info_textline() 73
caption in create_field() and create_fieldgroup()
190
captiondown in create_field() and
create_fieldgroup() 190
captionoffset in create_annotation() 182
captionposition in create_annotation() 182
captionrollover in create_field() and
create_fieldgroup() 190
cascadedflate in load_image() 144
centerwindow suboption for viewerpreferences
in begin/end_document() 35
charclass in add/create_textflow() 79
charmapping in add/create_textflow() 79
charref in many functions 67
charspacing
in create_field() and create_fieldgroup() 190
in many functions 67
checkwordsplitting in add_table_cell() 91
children in set_layer_dependency() 45
cid in info_font() 55, 56
cidfont in info_font() 56
circles suboption for wrap in fit_textflow() 87
circular keyword in add_path_point() 125
classes for logging parameter 28
clip in draw_path() 127
clipping suboption for matchbox 105
220
List of all Options
clippingarea in open_pdi_page() 159
clippingpath keyword in info_image() 149
clippingpathname in load_image() 144
cloneboxes
in fit_pdi_page() 160
in open_pdi_page() 159
close
in add_path_point() 126
in draw_path() 127
suboption for textpath in fit_textline() 73
cloudy in create_annotation() 182
code in info_font() 55, 56
codepage in info_font() 56
codepagelist in info_font() 56
colorize in load_image() 144
colorized in begin_font() 59
colscalegroup in add_table_cell() 91
colspan in add_table_cell() 91
ColSpan in begin_item() 211
colwidth in add_table_cell() 91, 92
colwidthdefault
in fit_table() 94
comb in create_field() and create_fieldgroup() 191
comment option list macro definition in
fit_textflow() 79
commitonselect in create_field() and
create_fieldgroup() 191
compatibility in begin_document() 31
components in load_image() 144
compress suboption for metadata 209
contents in create_annotation() 182
continuetextflow in add_table_cell() 91
control keyword in add_path_point() 125
convert in pcos_get_stream() 165
copy in create_pvf() 23
copyglobals in load_image() 144
coversheet suboption for portfolio in
begin_document() 199
coversheetfolder suboption for portfolio in
begin_document() 199
crease suboption for rendermode in
create_3dview() 203
createdate in create_annotation() 182
createfittext in fit_textflow() 83
createlastindent in fit_textflow() 83
creatematchboxes suboption for wrap in
fit_textflow() 87
createorderlist in set_layer_dependency() 45
createpvf in begin_document() 31
createrichtext in create_annotation() 183
createwrapbox suboption for matchbox 105
creatorinfo in define_layer() 43
cropbox in begin/end_page_ext() 39
currentvalue in create_field() and
create_fieldgroup() 191
curve keyword in add_path_point() 125
custom in create_annotation() 183
D
dasharray
in add_path_point() 125
in create_annotation() 183
in create_field() and create_fieldgroup() 191
in many functions 67
in setdashpattern 112
in several functions 109
dashphase
in add_path_point() 125
in setdashpattern 112
in several functions 109
debugshow in fit_table() 94
decorationabove
in fit/info_textline() and add/
create_textflow() 62
in many functions 67
defaultcmyk in begin/end_page_ext() 39
defaultdir in create_action() 174
defaultgray in begin/end_page_ext() 39
defaultrgb in begin/end_page_ext() 39
defaultstate in define_layer() 43
defaultvalue in create_field() and
create_fieldgroup() 191
defaultvariant in set_layer_dependency() 45
defaultview in load_3d() 201
depend in set_layer_dependency() 46
descender
in info_font() 56
in load_font() 51
keyword in info_textline() 73
description
in add_portfolio_file() 197
in add_portfolio_folder() 196
in load_iccprofile() 133
suboption for attachments in begin/
end_document() 30
destination
in begin/end_document() 31
in create_action() 174
in create_annotation() 183
in create_bookmark() 194
destname
in create_action() 174
in create_annotation() 183
in create_bookmark() 194
in end_document() 31
suboption for targetpath in create_action()
177
direction suboption for viewerpreferences in
begin/end_document() 35
disable
for logging parameter 27
suboption for 3Dactivate in
create_annotation() 187
disablestate suboption for 3Dactivate in
create_annotation() 187
display
in create_annotation() 183
in create_field() and create_fieldgroup() 191
displaydoctitle suboption for viewerpreferences
in begin/end_document() 35
displaysystem suboption for georeference 205
domain
in shading() 139
suboption for shading option of several
functions 111
doubleadapt suboption for matchbox 105
doubleoffset suboption for matchbox 105
down
suboption for template in
create_annotation() 186
dpi in many functions 101
drawbottom, drawleft, drawright, drawtop
suboptions for matchbox 105
dropcorewidths in load_font() 51
duplex suboption for viewerpreferences in begin/
end_document() 35
duration
in begin/end_page_ext() 39
in create_action() 174
E
E in begin_item() 211
editable in create_field() and create_fieldgroup()
191
embedding in load_font() 51
embedprofile in load_iccprofile() 133
enable
for logging parameter 27
suboption for 3Dactivate in
create_annotation() 187
enablestate suboption for 3Dactivate in
create_annotation() 187
encoding
in info_font() 56
in load_font() 51
end
suboption for matchbox 106
suboption for shading option of several
functions 111
endcolor suboption for shading option of several
functions 111
endingstyles in create_annotation() 183
endoptlistchar in create_textflow() 81
endx, endy keywords in info_textline() 73
entire suboption for background in
create_3dview() 202
epsg suboption for the coords and displaycoords
suboptions of georeference 206
errorpolicy parameter and option for various
functions 25
escapesequence in many functions 67
exceedlimit suboption for matchbox 106
exchangefillcolors in fit_textflow() 84
List of all Options
221
exchangestrokecolors in fit_textflow() 84
exclude in create_action() 174
exists keyword in info_matchbox() 107
exportable in create_field() and
create_fieldgroup() 191
exportmethod in create_action() 175
extend0, extend1 in shading() 139
F
facecolor suboption for rendermode in
create_3dview() 203
fakebold in many functions 67
faked
suboption for ascender in info_font() 56
suboption for fontstyle in info_font() 57
fallbackfont in info_font() 56
fallbackfonts in load_font() 52
familyname
in begin_font() 59
in info_font() 56
feature in info_font() 57
featurelist in info_font() 57
features in many functions 69
fieldlist
in add_portfolio_file() 197
in add_portfolio_folder() 196
fieldname in add_table_cell() 91
fieldtype
in add_table_cell() 91
in create_fieldgroup() 191
filename
for logging parameter 27
in create_action() 175
in create_annotation() 183
suboption for attachments in begin/
end_document() 30
suboption for metadata 209
suboption for reference in
begin_template_ext(), load_image(), and
open_pdi_page() 151
suboption for search in begin/
end_document() 33
filename keyword in info_image() 149
filenamehandling in set_option() 19
fileselect in create_field() and create_fieldgroup()
191
fill
in draw_path() 126, 127
in fit_table() 95
222
List of all Options
fillcolor
in add_path_point() 125
in create_annotation() 183
in create_field() and create_fieldgroup() 191
in many functions 68
in several functions 109
suboption for background in create_3dview()
202
suboption for leader in fit/info_textline() and
add/create_textflow() 70
suboption for leader in fit_textline() 72
fillrule
in add_path_point() 125
in several functions 109
suboption for wrap in fit_textflow() 87
firstbodyrow
keyword in info_matchbox() 107
keyword in info_table() 96
firstdraw in fit_table() 95
firstlinedist
in fit_textflow() 84
keyword in info_textflow() 88
firstparalinecount keyword in info_textflow() 88
fitannotation in add_table_cell() 91
fitfield in add_table_cell() 91
fitimage in add_table_cell() 91
fitmethod
in create_field() and create_fieldgroup() 191
in fit_textflow() 84
in various functions 101
suboption for template in
create_annotation() 186
fitpath in add_table_cell() 91
fitpdipage in add_table_cell() 91
fitscalex, fitscaley
keywords in info_image() 149
keywords in info_pdi_page() 161
fittext keyword in info_textflow() 88
fittextflow in add_table_cell() 92
fittextline in add_table_cell() 92
fitwindow suboption for viewerpreferences in
begin/end_document() 35
fixedleading in add/create_textflow() 76
flatness
in add_path_point() 125
in create_gstate() 115
in several functions 109
flush for logging parameter 27
font
in create_annotation() 184
in create_field() and create_fieldgroup() 192
in many functions 68
suboption for leader in fit/info_textline() and
add/create_textflow() 70
fontfile in info_font() 57
fontname
in info_font() 57
in load_font() 52
fontscale
in fit_textflow() 84
keyword in info_textflow() 88
fontsize
in create_annotation() 184
in create_field() and create_fieldgroup() 192
in many functions 68
suboption for ascender in info_font() 56
suboption for leader in fit/info_textline() and
add/create_textflow() 70
fontstyle
in create_bookmark() 194
in info_font() 57
in load_font() 52
fonttype in info_font() 57
footer in fit_table() 95
full suboption for fontname in info_font() 57
G
georeference
in begin_template_ext() 150
in load_image() 144
suboption for viewports in begin/
end_page_ext() 205
glyphcheck in many functions 67
glyphid in info_font() 55, 57
glyphname in info_font() 55, 57
group
in begin_page_ext() 39
in resume_page() 42
in set_layer_dependency() 46
option in add_nameddest() and suboption for
destination option in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 178
suboption for labels in begin_document() 34
groups in begin_document() 31
gstate
in add_path_point() 125
in fit/info_textline() and add/
create_textflow() 84
in fit_image/pdi_page() 148
in fit_pdi_page() 160
in fit_table() 95
in many graphics functions 109
in many text functions 68
in shading_pattern() 138
suboption for shadow in fit_textline() 72
H
header in fit_table() 95
height
in begin/end_page_ext() 39
in load_image() 144
keyword in info_image() 149
keyword in info_matchbox() 107
keyword in info_path() 128
keyword in info_pdi_page() 161
keyword in info_table() 96
keyword in info_textline() 74
hide in create_action() 175
hidemenubar suboption for viewerpreferences in
begin/end_document() 35
hidetoolbar suboption for viewerpreferences in
begin/end_document() 35
hidewindowui suboption for viewerpreferences
in begin/end_document() 35
highlight
in create_annotation() 184
in create_field() and create_fieldgroup() 192
honorclippingpath in load_image() 144
honoriccprofile in load_image() 144
horboxgap keyword in info_table() 97
horizscaling in many functions 68
horshrinking keyword in info_table() 97
horshrinklimit in fit_table() 95
hortabmethod in add/create_textflow() 77
hortabsize in add/create_textflow() 77
hostfont in info_font() 57
hyphenchar in add/create_textflow() 79
I
iccprofile
in load_image() 144
keyword in info_image() 149
icon in create_field() and create_fieldgroup() 192
icondown in create_field() and
create_fieldgroup() 192
iconname
in begin_template_ext() 150
in create_annotation() 184
in load_image() and begin_template_ext()
144
in open_pdi_page() 159
iconrollover in create_field() and
create_fieldgroup() 192
ignoreclippingpath in fit_image/pdi_page() 148
ignoremask in load_image() 144
ignoreorientation
in fit_image/pdi_page() 148
in load_image() 145
image in add_table_cell() 92
imagehandle in load_image() 145
imageheight keyword in info_image() 149
imagemask keyword in info_image() 149
imagetype keyword in info_image() 149
imagewidth keyword in info_image() 149
List of all Options
223
index
in begin_item() 211
in create_bookmark() 194
indextype suboption for search in begin/
end_document() 33
infomode in open_pdi_document() 156
initialexportstate in define_layer() 43
initialprintstate in define_layer() 43
initialsubset in load_font() 52
initialview suboption for portfolio in
begin_document() 199
initialviewstate in define_layer() 43
inittextstate in fit/info_textline() 72
inline
in begin_item() 211
in load_image() 145
inmemory
in begin_document() 31
in open_pdi_document 156
innerbox suboption for matchbox 106
inputencoding suboption for metadata 209
inputformat suboption for metadata 209
inreplyto in create_annotation() 184
intent in define_layer() 43
interiorcolor in create_annotation() 184
interpolate in load_image() 145
inversefill suboption for wrap in fit_textflow() 87
invert in load_image() 145
invisiblelayers in set_layer_dependency() 46
ismap in create_action() 175
italicangle
in info_font() 57
in many functions 68
itemname in create_field() and
create_fieldgroup() 192
itemnamelist in create_field() and
create_fieldgroup() 192
itemtextlist in create_field() and
create_fieldgroup() 192
K
K in load_image() 145
keepfilter in pcos_get_stream() 165
keepfont in load_font() 52
keephandles in delete_table() 97
keepnative
in info_font() 57
in load_font() 52
keepxmp suboption for metadata 209
kerning in many functions 68
kerningpairs in info_font() 57
224
List of all Options
key
suboption for custom in create_annotation()
183
suboption for fieldlist in
add_portfolio_folder() and
add_portfolio_file() 198
suboption for properties in begin_mc() and
mc_point() 213
L
label in begin/end_page_ext() 39
labels in begin/end_document() 31
lang in begin_document() 31
Lang in begin_item() 212
language
in define_layer() 43
in many functions 69
suboption for feature in info_font() 57
lastalignment in add/create_textflow() 77
lastbodyrow keyword in info_table() 97
lastfont keyword in info_textflow() 88
lastfontsize keyword in info_textflow() 88
lastlinedist
in fit_textflow() 84
keyword in info_textflow() 88
lastmark keyword in info_textflow() 88
lastparalinecount keyword in info_textflow() 88
layer
in begin_template_ext() 150
in create_annotation() 184
in create_field() and create_fieldgroup() 192
in load_image() and begin_template_ext()
145
in open_pdi_page() 159
layerstate in create_action() 175
leader
in add/create_textflow() 77
in fit/info_textline() 72
leaderlength in create_annotation() 184
leaderoffset
in create_annotation() 184
leading
in add/create_textflow() 77
keyword in info_textflow() 88
left option in add_nameddest() and suboption
for destination in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 178
leftindent in add/create_textflow() 77
leftlinex, leftliney keywords in info_textflow() 88
lighting in create_3dview() 202
line
in create_annotation() 184
keyword in add_path_point() 125
suboption for stroke in fit_table() 96
linearize in begin_document() 31
linearunit suboption for georeference 206
linecap
in add_path_point() 125
in create_gstate() 115
in load_font() 52
in several functions 110
linegap in info_font() 57
lineheight suboption for wrap in fit_textflow() 87
linejoin
in add_path_point() 125
in create_gstate() 115
in several functions 110
linespreadlimit in fit_textflow() 84
linewidth
in add_path_point() 125
in create_annotation() 184
in create_field() and create_fieldgroup() 192
in create_gstate() 115
in several functions 110
listmode in set_layer_dependency() 46
locale in add/create_textflow() 78
locked
in create_annotation() 185
in create_field() and create_fieldgroup() 192
lockedcontents in create_annotation() 185
lockmode in create_field() and
create_fieldgroup() 192
logging in set_option() 19
M
macro option list macro definition in
fit_textflow() 80
maingid in info_font() 57
mappoints suboption for georeference 206
mapsystem suboption for georeference 206
margin
in add_table_cell() 92
in various functions 102
suboption for matchbox 106
marginbottom in add_table_cell() 92
marginleft in add_table_cell() 92
marginright in add_table_cell() 92
margintop in add_table_cell() 92
mark in add/create_textflow() 79
mask in load_image() 145
masked in load_image() 145
masterpassword in begin_document() 31
matchbox
in fit/info_textline() and add/
create_textflow() 79
in various functions 102
suboption for createlastindent in
fit_textflow() 83
maxchar in create_field() and create_fieldgroup()
192
maxcode in info_font() 57
maxlinelength keyword in info_textflow() 88
maxlines in fit_textflow() 84
maxliney keyword in info_textflow() 88
maxspacing in add/create_textflow() 78
mediabox in begin/end_page_ext() 40
menuname in create_action() 175
metadata 209
in begin/end_document() 31
in begin/end_page_ext() 40
in begin_template_ext() 150
in load_font() 52
in load_iccprofile() 133
in load_image() and begin_template_ext()
145
in open_pdi_page() 159
metricsfile in info_font() 57
mimetype
in add_portfolio_file() 197
in create_annotation() 185
suboption for attachments in begin/
end_document() 30
minfontsize in fit_textflow() 85, 102
mingapwidth in fit_textflow() 85
minlinecount in add/create_textflow() 77
minlinelength keyword in info_textflow() 88
minliney keyword in info_textflow() 88
minrowheight in add_table_cell() 92
minspacing in add/create_textflow() 78
mirroringx, mirroringy
keywords in info_image() 149
keywords in info_pdi_page() 161
miterlimit
in add_path_point() 125
in create_gstate() 115
in several functions 110
moddate in begin/end_document() 31
modeltree suboption for 3Dactivate in
create_annotation() 187
monospace
in info_font() 57
in load_font() 53
move keyword in add_path_point() 125
movieposter in create_annotation() 185
multiline in create_field() and create_fieldgroup()
192
multiselect in create_field() and
create_fieldgroup() 192
N
N
in shading() 139
suboption for shading option of several
functions 111
List of all Options
225
name
in add_path_point() 126
in add_portfolio_file() 197
in create_3dview() 202
in create_annotation() 185
keyword in info_matchbox() 107
suboption for attachments in begin/
end_document() 30
suboption for codepage in info_font() 56
suboption for feature in info_font() 57
suboption for matchbox 106
suboption for targetpath in create_action()
177
suboption for viewports in begin/
end_page_ext() 205
namelist in create_action() 175
newwindow in create_action() 175
nextline in add/create_textflow() 79
nextparagraph in add/create_textflow() 79
nofitlimit in add/create_textflow() 78
nonfullscreenpagemode suboption for
viewerpreferences in begin/end_document()
35
normal suboption for template in
create_annotation() 186
numcids in info_font() 57
numcopies suboption for viewerpreferences in
begin/end_document() 35
numglyphs in info_font() 58
numpoints in info_path() 128
numusableglyphs in info_font() 58
numusedglyphs in info_font() 58
O
objectstreams in begin_document() 32
offset
suboption for shadow in fit_textline() 72
suboption for wrap in fit_textflow() 87
offsetbottom, offsetleft, offsetright, offsettop
suboptions for matchbox 106
onpanel in define_layer() 44
opacity
in create_annotation() 185
suboption for rendermode in create_3dview()
203
opacityfill in create_gstate() 115
opacitystroke in create_gstate() 115
open
in create_annotation() 185
in create_bookmark() 194
openmode in begin/end_document() 32
openrect suboption for matchbox 106
operation in create_action() 176
OPI-1.3 in load_image() and
begin_template_ext() 146
OPI-2.0 in load_image() and
begin_template_ext() 146
optimize in begin_document() 32
226
List of all Options
optimizeinvisible in load_font() 53
orientate
in create_annotation() 185
in create_field() and create_fieldgroup() 192
in fit_textflow() 85
in various functions 102
origin keyword in add_path_point() 125
outlineformat in info_font() 58
overline in many functions 68
overprintfill in create_gstate() 115
overprintmode in create_gstate() 115
overprintstroke in create_gstate() 116
P
page
in load_image() 146
option in add_nameddest() and suboption
for destination in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 178
pageelement in define_layer() 44
pageheight keyword in info_pdi_page() 161
pagelabel suboption for reference in
begin_template_ext(), load_image(), and
open_pdi_page() 151
pagelayout in begin/end_document() 32
pagenumber
in begin_page_ext() 40
in resume_page() 42
suboption for labels in begin/
end_document() and label in begin/
end_page_ext() 34
suboption for reference in
begin_template_ext(), load_image(), and
open_pdi_page() 151
suboption for targetpath in create_action()
177
pages suboption for separationinfo in begin/
end_page_ext() 40
pagewidth keyword in info_pdi_page() 161
parameters in create_action() 176
parent
in begin_item() 212
in create_bookmark() 195
in set_layer_dependency() 46
parentname in create_annotation() 185
parindent in add/create_textflow() 77
passthrough
in load_image() 146
password
in add_portfolio_file() 197
in create_field() and create_fieldgroup() 192
in open_pdi_document 156
path
in add_table_cell() 92
suboption for textpath in fit_textline() 73
paths suboption for wrap in fit_textflow() 87
pdfa in begin_document() 32
pdfx in begin_document() 32
pdipage in add_table_cell() 92
pdiusebox
in open_pdi_page() 159
suboption for reference in
begin_template_ext(), load_image(), and
open_pdi_page() 151
permissions in begin_document() 33
perpendiculardir keyword in info_textline() 74
picktraybypdfsize suboption for
viewerpreferences in begin/end_document()
35
playmode in create_annotation() 185
polar in add_path_point() 126
polygons suboption for wrap in fit_textflow() 87
polylinelist in create_annotation() 185
popup in create_annotation() 185
portfolio in end_document() 33
position
in create_field() and create_fieldgroup() 193
in various functions 102
suboption for template in
create_annotation() 186
predefcmap in info_font() 58
prefix
suboption for fieldlist in
add_portfolio_folder() and
add_portfolio_file() 198
suboption for labels in begin/
end_document() and label in begin/
end_page_ext() 34
preserveradio in create_action() 176
printarea suboption for viewerpreferences in
begin/end_document() 35
printclip suboption for viewerpreferences in
begin/end_document() 35
printpagerange suboption for viewerpreferences
in begin/end_document() 35
printscaling suboption for viewerpreferences in
begin/end_document() 35
printsubtype in define_layer() 44
properties in begin_mc() and mc_point() 213
px, py
in info_path() 128
R
r0, r1 in shading() 139
radians in add_path_point() 126
readfeatures in load_font() 53
readkerning in load_font() 53
readonly
in create_annotation() 185
in create_field() and create_fieldgroup() 193
readshaping in load_font() 53
rectangle keyword in info_matchbox() 107
reference
in begin_template_ext() 150
in open_pdi_page() 159
refpoint
in fill_*block() 127
in fill_*block() and info_path() 102
relation suboption for targetpath in
create_action() 177
relative in add_path_point() 126
remove for logging parameter 27
removeunused in define_layer() 44
rendercolor suboption for rendermode in
create_3dview() 203
renderingintent
in create_gstate() 116
in load_image() 146
rendermode in create_3dview() 202
repair in open_pdi_document 156
repeatcontent in add_table_cell() 92
replacedchars in info_textline() 74
replacementchar
in info_font() 58
in load_font() 53
replyto in create_annotation() 185
required in create_field() and create_fieldgroup()
193
requiredmode in open_pdi_document 157
resetfont in add/create_textflow() 79
resourcefile in set_option() 19
resx, resy keywords in info_image() 149
return
in add/create_textflow() 79
in add_table_cell() 92
returnatmark in fit_textflow() 85
returnreason
keyword in info_table() 97
keyword in info_textflow() 88
rewind
in fit_table() 95
in fit_textflow() 85
richtext in create_field() and create_fieldgroup()
193
right option in add_nameddest() and suboption
for destination in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 178
rightindent
in add/create_textflow() 77
suboption for createlastindent in
fit_textflow() 83
rightlinex, rightliney keywords in info_textflow()
88
righttoleft in info_textline() 74
rolemap in begin_document() and
end_document() 33
rollover
suboption for template in
create_annotation() 186
List of all Options
227
rotate
in begin/end_page_ext() 40
in create_annotation() 185
in fit_textflow() 85
in various functions 102
keyword in info_pdi_page() 161
suboption for textpath in fit_textline() 73
round
in add_path_point() 126
in draw_path() 127
suboption for matchbox 106
suboption for textpath in fit_textline() 73
rowcount keyword in info_table() 97
rowheight in add_table_cell() 92
rowheightdefault
in fit_table() 95
rowjoingroup in add_table_cell() 93
rowscalegroup in add_table_cell() 92
rowspan in add_table_cell() 93
RowSpan in begin_item() 212
rowsplit keyword in info_table() 97
ruler in add/create_textflow() 77
S
scale
in various functions 103
suboption for textpath in fit_textline() 73
scalex, scaley keywords in info_textline() 74
schema suboption for portfolio in
begin_document() 199
Scope in begin_item() 212
script
in create_action() 176
in load_3d() 201
in many functions 69
suboption for feature in info_font() 57
scriptlist keyword in info_textline() 74
scriptname in create_action() 176
scrollable in create_field() and
create_fieldgroup() 193
search in begin/end_document() 33
searchpath in set_option() 20
separationinfo in begin_page_ext() 40
shading in several functions 110
shadow in fit/info_textline() 72
shaping in many functions 69
shapingsupport in info_font() 58
showborder
in fit_textflow() 85
in various functions 103
showcaption in create_annotation() 186
showcells in fit_table() 96
showcontrols in create_annotation() 186
showgrid in fit_table() 96
showtabs in fit_textflow() 85
shrinklimit
in add/create_textflow() 78
in various functions 103
228
List of all Options
shutdownstrategy in set_option() 20
singfont in info_font() 58
smoothness in create_gstate() 116
softmask in create_gstate() 116
sort suboption for portfolio in begin_document()
199
sorted in create_field() and create_fieldgroup()
193
soundvolume in create_annotation() 186
space in add/create_textflow() 79
spellcheck in create_field() and
create_fieldgroup() 193
split
keyword in info_textflow() 88
suboption for portfolio in begin_document()
200
spotcolor suboption for separationinfo in begin/
end_page_ext() 40
spotname suboption for separationinfo in begin/
end_page_ext() 40
spreadlimit in add/create_textflow() 78
stamp
in fit/info_textline() 72
in fit_textflow() 85
standardfont in info_font() 58
start
suboption for labels in begin/
end_document() and label in begin/
end_page_ext() 34
suboption for shading option of several
functions 111
startcolor in shading() 139
startoffset suboption for textpath in
fit_textline() 73
startx, starty keywords in info_textline() 74
stretch in begin_font() 59
strikeout in many functions 68
stringlimit for logging parameter 27
strips keyword in info_image() 149
stroke
in draw_path() 126, 127
in fit_table() 96
strokeadjust in create_gstate() 116
strokecolor
in add_path_point() 125
in create_field() and create_fieldgroup() 193
in many functions 68
in several functions 110
strokewidth in many functions 68
strongref suboption for reference in
begin_template_ext() and open_pdi_page()
151
style suboption for labels in begin/
end_document() and label in begin/
end_page_ext() 34
subject in create_annotation() 186
submitemptyfields in create_action() 176
submitname in create_field() and
create_fieldgroup() 193
subpaths
in draw_path() 127
suboption for textpath in fit_textline() 73
subsetlimit in load_font() 53
subsetminsize in load_font() 53
subsetting in load_font() 53
supplement in info_font() 58
symbolfont in info_font() 58
T
tabalignchar in add/create_textflow() 79
tabalignment in add/create_textflow() 77
taborder
in begin/end_page_ext() 40
in create_field() and create_fieldgroup() 193
tagged in begin_document() 33
tagname in begin_item() 212
target
in create_action() 176
suboption for reference in
begin_template_ext(), load_image(), and
open_pdi_page() 151
targetbox keyword in info_image() 149
targetpath
in create_action() 176
suboption for targetpath in create_action()
177
targetx1, targety1, ..., targetx4, targety4
keywords in info_image() 149
tempdirname in begin_document() 33
template
in create_annotation() 186
in load_image() 146
text suboption for leader in fit/info_textline()
and add/create_textflow() 70
textcolor in create_bookmark() 195
textendx, textendy keywords in info_textflow()
88
textflow
in add_table_cell() 93
in fill_textblock() 169
suboption for createrichtext in
create_annotation() 183
textflowhandle in fill_textblock() 169
textheight keyword in info_textflow() 88
textknockout in create_gstate() 116
textlen in create_textflow() 81
textpath in fit/info_textline() 72
textrendering in many functions 68
textrise in many functions 68
textwidth keyword in info_textflow() 89
thumbnail
in add_portfolio_file() 197
in add_portfolio_folder() 196
Title in begin_item() 212
title in create_annotation() 186
toggle in create_fieldgroup() 193
tolerance suboption for textpath in fit_textline()
73
toolbar
suboption for 3Dactivate in
create_annotation() 187
tooltip in create_field() and create_fieldgroup()
193
top option in add_nameddest() and suboption for
destination in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 178
topdown
in begin_page_ext() 40
in begin_template_ext() 150
topindex in create_field() and create_fieldgroup()
193
transition
in begin/end_page_ext() 41
in create_action() 176
transparencygroup
in begin/end_page_ext() 41
in begin_template_ext() 150
in open_pdi_page() 158
trimbox in begin/end_page_ext() 41
type
in load_3d() 201
option in add_nameddest() and suboption for
destination in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 179
suboption for custom in create_annotation()
183
suboption for fieldlist in
add_portfolio_folder() and
add_portfolio_file() 198
suboption for properties in begin_mc() and
mc_point() 213
suboption for rendermode in create_3dview()
204
suboption for shading option of several
functions 111
suboption for the coords and displaycoords
suboptions of georeference 206
U
U3Dpath in create_3dview() 203
underline in many functions 68
underlineposition many functions 69
underlinewidth in many functions 69
unicode in info_font() 55, 58
unicodefont in info_font() 58
unicodemap in load_font() 53
unisonselect in create_fieldgroup() 193
unknownchars in info_textline() 74
unmappedchars
in info_font() 58
in info_textline() 74
List of all Options
229
uri in begin/end_document() 33
url in create_action() 176
urls in load_iccprofile() 133
usage in load_iccprofile() 133
used keyword in info_textflow() 89
usedglyph in info_font() 58
usematchbox in create_annotation() 186
usematchboxes suboption for wrap in
fit_textflow() 87
usercoordinates
in create_annotation() 186
in create_field() and create_fieldgroup() 193
userpassword in begin_document() 33
userunit
in begin/end_page_ext() 41
suboption for createrichtext in
create_annotation() 183
V
value
suboption for custom in create_annotation()
183
suboption for fieldlist in
add_portfolio_folder() and
add_portfolio_file() 198
suboption for properties in begin_mc() and
mc_point() 213
variantname in set_layer_dependency() 46
vertboxgap keyword in info_table() 97
vertical
in info_font() 58
in load_font() 53
verticalalign in fit_textflow() 86
vertshrinking keyword in info_table() 97
vertshrinklimit in fit_table() 96
viewarea suboption for viewerpreferences in
begin/end_document() 35
viewclip suboption for viewerpreferences in
begin/end_document() 35
viewerpreferences in begin_document() and
end_document() 33
viewports in begin/end_page_ext() 41
views in load_3d() 201
visiblelayers in set_layer_dependency() 46
W
weight
in begin_font() 59
in info_font() 58
wellformed keyword in info_textline() 74
230
List of all Options
width
in begin/end_page_ext() 41
in load_image() 146
keyword in info_image() 149
keyword in info_matchbox() 107
keyword in info_path() 128
keyword in info_pdi_page() 161
keyword in info_table() 97
keyword in info_textline() 74
widthsonly in begin_font() 59
willembed in info_font() 58
willsubset in info_font() 58
windowposition in create_annotation() 186
windowscale in create_annotation() 187
wkt suboption for the coords and displaycoords
suboptions of georeference 206
wordspacing in many functions 69
worldpoints suboption for georeference 206
wrap in fit_textflow() 86
writingdirx, writingdiry keywords in
info_textline() 74
X
x1, y1, ..., x4, y4
keywords in info_image() 149
keywords in info_matchbox() 107
keywords in info_path() 128
keywords in info_pdi_page() 161
keywords in info_table() 97
keywords in info_textflow() 89
xadvancelist in fit/info_textline() 72
xheight
in info_font() 58
in load_font() 53
keyword in info_textline() 74
xvertline keyword in info_table() 97
Y
yhorline keyword in info_table() 97
yposition suboption for leader in fit/
info_textline() and add/create_textflow() 70
Z
zoom
in add_nameddest() and suboption for
destination in create_action(),
create_annotation(), create_bookmark() and
begin/end_document() 179
in create_annotation() 187
in define_layer() 44
D Revision History
Date
Changes
December 09, 2010
> Various updates and corrections for PDFlib 8.0.2
September 22, 2010
> Various updates and corrections for PDFlib 8.0.1p7
April 13, 2010
> Various updates and corrections for PDFlib 8.0.1
December 04, 2009
> Updates for PDFlib 8.0.0
April 20, 2010
> Minor corrections for PDFlib 7.0.5
March 13, 2009
> Various updates and corrections for PDFlib 7.0.4
February 13, 2008
> Various updates and corrections for PDFlib 7.0.3
August 08, 2007
> Various updates and corrections for PDFlib 7.0.2
March 09, 2007
> Various updates and corrections for PDFlib 7.0.1
October 03, 2006
> Updates and restructuring for PDFlib 7.0.0; split the manual in tutorial and API reference
February 15, 2007
> Various updates and corrections for PDFlib 6.0.4
February 21, 2006
> Various updates and corrections for PDFlib 6.0.3; added Ruby section
August 09, 2005
> Various updates and corrections for PDFlib 6.0.2
November 17, 2004
> Minor updates and corrections for PDFlib 6.0.1
> introduced new format for language-specific function prototypes in chapter 8
> added hypertext examples in chapter 3
June 18, 2004
> Major changes for PDFlib 6
January 21, 2004
> Minor additions and corrections for PDFlib 5.0.3
September 15, 2003
> Minor additions and corrections for PDFlib 5.0.2; added block specification
May 26, 2003
> Minor updates and corrections for PDFlib 5.0.1
March 26, 2003
> Major changes and rewrite for PDFlib 5.0.0
June 14, 2002
> Minor changes for PDFlib 4.0.3 and extensions for the .NET binding
January 26, 2002
> Minor changes for PDFlib 4.0.2 and extensions for the IBM eServer edition
May 17, 2001
> Minor changes for PDFlib 4.0.1
April 1, 2001
> Documents PDI and other features of PDFlib 4.0.0
February 5, 2001
> Documents the template and CMYK features in PDFlib 3.5.0
December 22, 2000
> ColdFusion documentation and additions for PDFlib 3.03; separate COM edition of the manual
August 8, 2000
> Delphi documentation and minor additions for PDFlib 3.02
July 1, 2000
> Additions and clarifications for PDFlib 3.01
Feb. 20, 2000
> Changes for PDFlib 3.0
Aug. 2, 1999
> Minor changes and additions for PDFlib 2.01
June 29, 1999
> Separate sections for the individual language bindings
> Extensions for PDFlib 2.0
D Revision History
231
Date
Changes
Feb. 1, 1999
> Minor changes for PDFlib 1.0 (not publicly released)
Aug. 10, 1998
> Extensions for PDFlib 0.7 (only for a single customer)
July 8, 1998
> First attempt at describing PDFlib scripting support in PDFlib 0.6
Feb. 25, 1998
> Slightly expanded the manual to cover PDFlib 0.5
Sept. 22, 1997
> First public release of PDFlib 0.4 and this manual
232
(Edition for COM, .NET, and REALbasic)
Index
Note that parameters and options are listed in separate appendices.
A
action lists in option lists 13
activate_item() 212
add_nameddest() 178
add_path_point() 125
add_portfolio_folder() 196
add_textflow() 75
add_thumbnail() 153
align() 117
alignment (position option) 102
All spot color name 131
arc() 120
arcn() 121
Author field 207
B
begin_document() 29
begin_font() 59
begin_glyph() 60
begin_item() 210
begin_layer() 46
begin_mc() 213
begin_page_ext() 38, 39
begin_pattern() 137
begin_template_ext() 150
Bézier curve 120
Boolean values in option lists 11
C
circle() 120
circles in option lists 14
circular_arc() 121
clip() 124
close_font() 54
close_image() 147
close_pdi_document() 157
close_pdi_page() 158
closepath() 122
closepath_fill_stroke() 124
closepath_stroke() 123
CMYK color 129
cmyk keyword 13
color functions 129
color in option lists 12
concat() 118
continue_text() 64
create_3dview() 202
create_action() 173
create_annotation() 180
create_bookmark() 194
create_field() 188
create_fieldgroup() 189
create_gstate() 114
create_pvf() 23
create_textflow() 81
Creator field 207
curves in option lists 15
curveto() 120
D
dash pattern for lines 112
define_layer() 43
delete_path() 128
delete_pvf() 23
delete_textflow() 89, 97
document and page functions 29
document information fields 207
document scope 17
draw_path() 126
Dublin Core 207
E
ellipse() 121
encoding_set_char() 61
end_document() 29
end_font() 60
end_glyph() 60
end_item() 212
end_layer() 47
end_mc() 213
end_pattern() 137
end_template_ext() 151
endpath() 124
F
fast Web view 31
fill() 123
fill_imageblock() 170
fill_pdfblock() 171
fill_stroke() 123
fill_textblock() 168
fit_image() 147
fit_pdi_page() 159
fit_textflow() 82
fit_textline() 71
float and integer values in option lists 11
floats in option lists 11
font scope 17
Index
233
fontsize in option lists 12
function scopes 17
load_image() 142
logging 27
G
M
get_apiname() 26
get_buffer() 37
get_errmsg() 25
get_errnum() 25
get_parameter() 18
get_value() 18
glyph scope 17
graphics functions 109
gray keyword 13
makespotcolor() 131
mc_point() 213
metadata 209
mirroring 117
moveto() 119
H
nested option lists 8
None spot color name 131
numbers in option lists 11
handles in option lists 11
O
I
object scope 17
open_pdi_document() 155
open_pdi_page() 158
option list syntax 7
outline text 68
ICC Profiles 133
ICC-based color 129
iccbasedcmyk keyword 13
iccbasedgray keyword 13
iccbasedrgb keyword 13
image functions 141
import functions for PDF (PDI) 155
indexed color 130
info fields 207
info_font() 55
info_image() 148
info_path() 127
info_pdi_page() 160
info_textflow() 86, 96, 106
info_textline() 72
initgraphics() 113
inline option lists for Textflows 81
inner cell box for table cells 92
invisible text 68
K
Keywords field 207
keywords in option lists 11
L
lab keyword 13
landscape mode 39
licence 21
license 21
linearized PDF 31
lines in option lists 14
lines: dashed and patterned 112
lineto() 119
list values in option lists 8
load_3ddata() 201
load_font() 49
load_iccprofile() 133
234
N
Index
P
page scope 17
page size formats 38
parameter handling functions 18
path painting and clipping 123
path scope 17
pattern keyword 13
pattern scope 17
pcircle() 120
pCOS functions 155, 163
pcos_get_number() 163
pcos_get_stream() 164
pcos_get_string() 163
PDF import functions (PDI) 155
PDF/A or PDF/X output intent 162
PDFlib Personalization Server (PPS) 167
PDI (PDF import) 155
polylines in option lists 14
PPS (PDFlib Personalization Server) 167
process_pdi() 162
pscale() 117
R
raster image functions 141
rect() 121
rectangles in option lists 14
reflection 117
restore() 114
resume_page() 42
RGB color 129
rgb keyword 13
rotate() 117
S
save() 114
scale() 117
scopes 17
separation color space 129
set_gstate() 116
set_info() 207
set_layer_dependency() 44
set_option() 19
set_parameter() 19
set_text_pos() 63
set_value() 18
setcolor() 130
setdash() 112
setdashpattern() 112
setflat() 112
setfont() 63
setlinecap() 113
setlinejoin() 112
setlinewidth() 113
setmatrix() 118
setmiterlimit() 113
setup functions 21
shading() 138
shading_pattern() 138
shfill() 138
show() 64
show_xy() 64
skew() 118
spot color (separation color space) 129
spot keyword 13
spotname keyword 13
standard page sizes 38
string index 21
strings in option lists 10
stringwidth() 64
stroke() 123
Subject field 207
subscript 68
superscript 68
suspend_page() 42
syntax of option lists 7
T
table formatting 90
template scope 17
text functions 49
text position 63
Textflow: inline option lists 81
thumbnails 153
Title field 207
translate() 117
Trapped field 207
U
Unichar values in option lists 10
Unicode ranges in option lists 10
W
web-optimized PDF 31
X
XMP metadata 209
Index
235
ABC
PDFlib GmbH
Franziska-Bilek-Weg 9
80339 München, Germany
www.pdflib.com
phone +49 • 89 • 452 33 84-0
fax +49 • 89 • 452 33 84-99
If you have questions check the PDFlib mailing list
and archive at tech.groups.yahoo.com/group/pdflib
Licensing contact
[email protected]
Support
[email protected] (please include your license number)

advertisement

Was this manual useful for you? Yes No
Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Related manuals

Download PDF

advertisement