PDFlib API Reference
PDFlib API Reference
API Reference
For use with C, C++, Cobol, COM, Java, .NET, Objective-C,
Perl, PHP, Python, REALbasic/Xojo, RPG, Ruby
Copyright 19972017 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 Mnchen, 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
groups.yahoo.com/neo/groups/pdflib/info
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 lia-
bility for any errors or inaccuracies, makes no warranty of any kind (express, implied or statutory) with re-
spect to this publication, and expressly disclaims any and all warranties of merchantability, fitness for par-
ticular 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 regis-
tered 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 the RSA Security, Inc. MD5 message digest algorithm.
Contents
1 Programming Concepts 7
1.1 Option Lists 7
1.1.1 Syntax 7
1.1.2 Simple Data Types 9
1.1.3 Fontsize and Action Data Types 12
1.1.4 Color Data Type 13
1.1.5 Geometric Data Types 15
1.2 Function Scopes 17
1.3 Logging 18
2 General Functions 21
2.1 Exception Handling 21
2.2 Unicode Conversion 23
2.3 Global Options 25
2.4 Creating and Deleting PDFlib Objects 32
2.5 PDFlib Virtual File System (PVF) 34
2.6 PDF Object Creation API (POCA) 37
Contents 3
6.2 Matchboxes 131
4 Contents
12.3 Form Fields 223
12.4 Actions 231
12.5 Named Destinations 236
12.6 PDF Packages and Portfolios 238
12.7 Geospatial Features 243
Index 293
Contents 5
1 Programming Concepts
1.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 C language binding: you may want to use the sprintf( ) function for constructing optlists.
.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 re-
placed 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.1 Syntax
Formal option list syntax definition. Option lists must be constructed according to fol-
lowing 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.
> If an element contains brace characters these must be protected with a preceding
backslash character.
> If an element contains a sequence of one or more backslash characters in front of a
brace, each backslash in the sequence must be protected with another backslash
character.
> Option lists must not contain binary zero values.
An option may have a list value according to its documentation in this PDFlib API Refer-
ence. 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.
Note Option names (i.e. the key) never contain hyphen characters. Keep this in mind since the tables
with option descriptions may sometimes contain long option names which are hyphenated.
The hyphen must be omitted when supplying the option in an option list.
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
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 mul-
tiply 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} (list containing three numbers)
position={ center bottom } (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 op-
tion 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} }}
Common traps and pitfalls. This paragraph lists some common errors regarding op-
tion 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} WRONG!
key={{value1}{value2}} WRONG!
Braces must be balanced; the following is wrong (see below for unquoted string syntax):
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!
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 option
escapesequence is set. For details on these string types and encoding choices for string
options see the PDFlib Tutorial.
Non-Unicode capable language bindings: if an option list starts with a [EBCDIC-]UTF-
8 BOM, each content, hypertext or name string of the option list is interpreted as a [EBC-
DIC-]UTF-8 string.
Unquoted string values. In the following situations the actual characters in an option
value may conflict with optlist syntax characters:
> Passwords or file names may contain unbalanced braces, backslashes and other spe-
cial characters
> Japanese SJIS filenames in option lists (reasonable only in non-Unicode-capable lan-
guage bindings)
> Supplying JavaScript code in options is problematic due to the use of { and } braces
In order to provide a simple mechanism for supplying arbitrary text or binary data
which does not interfere with option list syntax elements, unquoted option values can
be supplied along with a length specifier in the following syntax variants:
key[n]=value
key[n]={value}
The braces around the string value are optional, but strongly recommended. They are
required for strings starting with a space or other separator character. Braces, separators
and backslashes within the string value are taken literally without any special interpre-
tation.
Example for specifying a 7-character password containing space and brace charac-
ters. The whole string is surrounded by braces which are not part of the option value:
password[7]={ ab}c d}
If an option value in a nested option list is provided with a length count, the enclosing
option list must also supply a length count, e.g.
fitannotation[34]={contents[19]={this is a brace '}'}}
Single characters which happen to be a number are treated literally, not as decimal Uni-
code values:
replacementchar=3 (U+0033 THREE, not U+0003!)
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 (equivalent to embedding=true)
noembedding (equivalent to embedding=false)
Keyword. An option of type keyword can hold one of a predefined list of fixed key-
words. Example:
blendmode=overlay
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, ICC profiles or ac-
tions. Technically these are integer values which have been returned earlier by an API
function. For example, an image handle is returned by PDF_load_image( ). Handles must
always be treated as opaque types; they must never be modified or created by the appli-
cation 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 ex-
pects an image handle must not be supplied with a graphics handle, although both han-
dles are integer types.
The second variant contains a percentage, where the basis of the percentage depends on
the context (e.g. the width of the fitbox for PDF_fit_textline( )):
fontsize=8%
In the third variant, the fontsize is specified as an option list which must contain a key-
word 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}
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 PDF_create_action( ). Actions will be performed in the listed order. The set of al-
lowed events (e.g. docopen) and the type of actions (e.g. JavaScript) are documented sep-
arately for the respective options.
List containing a single trigger with three actions:
bodyheight The number is interpreted as minimum distance between baselines, i.e. descenders and ascenders of ad-
jacent lines may exactly touch if this value is used as leading. This is the default behavior if no keyword is
provided.
action={ activate={ 0 1 2 } }
The default color for stroke and fill operations is black. The color space for this default
color is selected automatically to match PDF/X and PDF/A color requirements.
Color options. Color options can be defined in three different forms: using an RGB col-
or name, hexadecimal RGB values, or a flexible option list for colors in any color space.
Cookbook A full code sample for using RGB color values can be found in the Cookbook topic
color/web_colornames.
In the first form all valid color names from SVG 1.1 can be supplied directly to specify an
RGB color or an sRGB color if the sRGB ICC profile has been selected, e.g.
strokecolor=pink
The color names are case-insensitive. A list of valid RGB 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 three pairs of hexadecimal dig-
its 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 op-
tion list contains a color space keyword and a list with a variable number of float values
depending on the particular color space. Table 1.2 contains descriptions of color space
keywords with examples. As detailed in the respective function descriptions, a particu-
lar option list may support only a subset of the color space keywords.
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 created with PDF_makespotcolor( ), followed by { spot <handle> 0.8 }
a float specifying the tint value
spotname (up to 63 bytes; fewer Unicode characters depending on format { spotname {PANTONE 281 U} 0.5 }
and encoding) spot color name and a float specifying the tint val-
ue in the range 0..1
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 defi-
nitions must be consistent (i.e. define the same alternate color).
devicen DeviceN color space handle created with PDF_create_devicen( ) fol- { devicen <handle> 0.8 0.9 }
lowed by N float values for the tint values of the colorants in the { devicen <handle> 0 0 0.1 0.2}
range 0..1.
iccbased ICC profile handle or keyword srgb, plus 1, 3 or 4 color values de- { iccbased <handle> 0.5 }
pending on the type of ICC profile (gray, RGB, or CMYK). The srgb { iccbased <handle> 0 0 0.75 }
keyword must not be used in document scope. { iccbased srgb 0 0 0.75 }
{ iccbased <handle> 0 0 0.3 1 }
iccbasedgray single float value referring to an ICC profile selected with the op- { iccbasedgray 0.5 }
tion iccprofilegray
iccbasedrgb three float values value referring to an ICC profile selected with the { iccbasedrgb 1 0 0 }
option iccprofilergb
iccbasedcmyk four float values value referring to an ICC profile selected with the { iccbasedcmyk 0 1 0 0 }
option iccprofilecmyk
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}
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 inter-
preting the coordinates (default or user coordinate system) varies depending on the op-
tion, 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 coordi-
nates can be supplied by adding the suffix r immediately after a number. Within a coor-
dinate list a relative coordinate relates to the previous x or y coordinate. Relative coordi-
nates 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%}
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 coordi-
nates (default or user coordinate system) varies depending on the option, and is docu-
mented separately:
circle={200 325 200 200}
Curve list. A curve list consists of two or more connected third-order Bzier curve seg-
ments. A Bzier 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:
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.
path started by one of PDF_moveto( ), PDF_circle( ), PDF_arc( ), PDF_arcn( ), PDF_rect( ), PDF_ellipse( ) or PDF_
elliptical_arc( );
terminated by any of the functions in Section 7.5, Painting and Clipping, page 149
document between PDF_begin_document( ) and PDF_end_document( ), but outside of page, path, glyph, template,
pattern, and font scope
object during the lifetime of the PDFlib object, but outside of document scope; in the C, Cobol and RPG language
bindings between PDF_new( ) and PDF_delete( ), but outside of document scope
> In an environment variable called PDFLIBLOGGING. This will activate the logging out-
put starting with the very first call to one of the API functions.
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 ex-
isting contents. Default:
pdflog on z/OS
PDFlib.log on OS X/macOS 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
includepid (Boolean; not on MVS) Include the process id in the log file name. This should be enabled if multiple pro-
cesses use the same log file name. Default: false
includetid (Boolean; not on MVS) Include the thread id in the log file name. This should be enabled if multiple
threads in the same process use the same log file name. Default: false
includeoid (Boolean; not on MVS) Include the object id in the log file name. This should be enabled if multiple PDFlib
objects in the same thread use the same log file name. Default: false
remove (Boolean) If true, an existing log file will be deleted before writing new output. Default: false
removeon- (Boolean) Remove the generated log file in PDF_delete( ) unless an exception occurred. This may be useful
success for analyzing occasional problems in multi-threaded applications or problems which occur only sporadi-
cally. It is recommended to combine this option with includepid/includetid/includeoid as appropri-
ate.
stringlimit (Integer) Limit for the number of characters per line, or 0 for unlimited. Default: 0
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 en-
able 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.
filesearch Log all attempts related to locating files via SearchPath or PVF.
resource Log all attempts at locating resources via Windows registry, UPR definitions as well as the
results of the resource search.
tagging Structure element (tag) operations
user User-specified logging output supplied with the userlog option.
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 PDF_get_errmsg( ), and the reason for all failed attempts at
opening a file (searching for a file in searchpath) will also be logged.
1.3 Logging 19
2 General Functions
2.1 Exception Handling
Table 2.1 details the relevant option for this section. This option is supported by many
functions as indicated in the corresponding option list descriptions. It can also be sup-
plied as global option to PDF_set_option( ) (see Section 2.3, Global Options, page 25).
errorpolicy (Keyword) Controls the error behavior of functions which return a value. The global option errorpolicy
can be overridden by the errorpolicy option of many functions, and serves as default for this option.
Supported keywords (default: legacy):
legacy (Deprecated) Some functions return an error code, while others throw an exception according
to the respective API description.
return If a processing error occurs the function will return. Functions which can return an error code
(e.g. PDF_load_image( )) return -1 (in PHP: 0). Functions which return result strings (e.g. PDF_
fit_table( )) return the string _error. Application developers must check the return value
against -1 (in PHP: 0) or _error to detect error situations. In case of an error a detailed
description can be queried with PDF_get_errmsg( ). This setting is recommended for new
applications.
Even with errorpolicy=return an exception is thrown if a syntactic error in an option list is
found or the PDF output cannot be written.
exception If an error occurs the function will throw an exception. The exception must be caught in client
code. The partial PDF output generated so far is unusable and must be discarded (this can be
automated with the removefragments document option).
Get the number of the last thrown exception or the reason of a failed function call.
Scope Between an exception thrown by PDFlib and the death of the PDFlib object. Alternative-
ly, this function may be called after a function returned a -1 (in PHP: 0) error code, but
before calling any other function except those listed in this section.
Bindings In C++, Java, Objective-C, .NET, PHP and REALbasic/Xojo this function is also available as
get_errnum( ) in the PDFlibException object.
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. Alternative-
ly, this function may be called after a function returned a -1 (in PHP: 0) error code, but
before calling any other function except those listed in this section.
Bindings In C++, Java, Objective-C, .NET, PHP and REALbasic/Xojo this function is also available as
get_errmsg( ) in the PDFlibException object.
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 re-
cently called function which failed with an error code.
Scope Between an exception thrown by PDFlib and the death of the PDFlib object. Alternative-
ly, this function may be called after a function returned a -1 (in PHP: 0) error code, but
before calling any other function except those listed in this section.
Bindings In C++, Java, Objective-C, .NET, PHP and REALbasic/Xojo this function is also available as
get_apiname( ) in the PDFlibException object.
Returns The opaque application pointer stored in PDFlib which has been supplied in the call to
PDF_new2( ).
Details PDFlib never touches the opaque pointer, but supplies it unchanged to the client. This
may be used in multi-threaded applications for storing private thread-specific data
within the PDFlib object. It is especially useful for thread-specific exception handling.
Scope any
inputlen (C language binding only) Length of the input string in bytes. If inputlen=0 a
null-terminated string must be provided.
outputlen (C language binding only) C-style pointer to a memory location where the
length of the returned string (in bytes) will be stored.
optlist An option list specifying options for input interpretation and Unicode conver-
sion:
> Text filter options according to Table 4.6: charref, escapesequence
> Unicode conversion options according to Table 2.2:
bom, errorpolicy, font, inflate, outputformat
Returns A Unicode string created from the input string according to the specified parameters
and options. If the input string does not conform to the specified input format (e.g. in-
valid UTF-8 string) an empty output string will be returned if errorpolicy=return, and an
exception will be thrown if errorpolicy=exception.
Details This function may be useful for general Unicode string conversion. It is provided for the
benefit of users who work in environments without suitable Unicode converters.
Scope any
Bindings C binding: the returned strings will be stored in a ring buffer with up to 10 entries. If
more than 10 strings are converted, the buffers will be reused, which means that clients
must copy the strings if they want to access more than 10 strings in parallel. For exam-
ple, up to 10 calls to this function can be used as parameters for a printf( ) statement
since the return strings are guaranteed to be independent if no more than 10 strings are
used at the same time.
bom (Keyword; will be ignored for outputformat=utf32) Policy for adding a byte order mark (BOM) to the
output string. Supported keywords (default: none):
add Add a BOM.
keep Add a BOM if the input string has a BOM.
none Dont add a BOM.
optimize Add a BOM except if outputformat=utf8 or ebcdicutf8 and the output string contains only
characters in the range < U+007F.
errorpolicy (Keyword) Behavior in case of conversion errors (default: the value of the errorpolicy global option, see
Table 2.1):
return The replacement character will be used if a character reference cannot be resolved or a code
or glyph ID doesnt exist in the specified font. An empty string will be returned in case of con-
version errors.
exception An exception will be thrown in case of conversion errors.
font (Font handle; required for inputformat=builtin and glyphid) Apply font-specific conversion according
to the specified font.
inflate (Boolean; only for inputformat=utf8) If true, an invalid UTF-8 input string will not trigger an excep-
tion, but rather an inflated byte string in the specified output format will be generated. The inflated
string contains Unicode characters which correspond to the ASCII interpretation of the bytes in the input
string. This may be useful for debugging. Default: false
output- (Keyword) Unicode text format of the generated string: utf8, ebcdicutf8, utf16, utf16le, utf16be,
format utf32. An empty string is equivalent to utf16. Default: utf16
Unicode-capable language bindings: the output format will be forced to utf16.
C++ language binding: only the following output formats are allowed: ebcdicutf8, utf8, utf16, utf32.
optlist An option list specifying global options according to Table 2.3. The following
options can be used:
> Options for resource handling and resource categories according to Table 2.3:
CMap, Encoding, enumeratefonts, FontAFM, FontnameAlias, FontOutline, FontPFM,
HostFont, ICCProfile, resourcefile, saveresources, searchpath
> Options for file handling and licensing according to Table 2.3:
avoiddemostamp, filenamehandling, license, licensefile
> Text filter options according to Table 2.3:
charref,escapesequence, glyphcheck, stringformat, textformat
> Options for interactive elements according to Table 2.3:
hypertextencoding, hypertextformat, usehypertextencoding, usercoordinates
> Other options according to Table 2.3:
asciifile, autospace, compress, kerning, logging, shutdownstrategy, usehostfonts, userlog
> Option for error handling according to Table 2.1: errorpolicy
> Options for color handling according to Table 2.3 and Table 8.2:
iccprofilecmyk, iccprofilegray, iccprofilergb
Details Except for resource category options new values override previously set option values.
The following options provide default values for the same-named text options (see
Table 4.6 and Table 4.7):
charref, escapesequence, glyphcheck, kerning, textformat
At the same time these options change the options of the same name in the current
text state. It is recommended to set options for content strings only in PDF_set_text_
option( ) to avoid unwanted side effects.
asciifile (Boolean; only supported on i5/iSeries and zSeries). Expect text files (PFA, AFM, UPR, encodings) in ASCII
encoding. Default: true on i5/iSeries; false on zSeries
autospace If true and the current font contains a glyph for U+0020, PDFlib will automatically add a space character
after each text output. This may be useful for generating Tagged PDF. Note that adding spaces changes
the current text position. Default: false
avoiddemo- (Boolean) If true, an exception will be thrown when no valid license key was found; if false, a demo
stamp stamp will be created on all pages. This option must be set before the first call to PDF_begin_
document( ). Default: false
charref (Boolean) If true, enable substitution of numeric and character entity references and glyph name refer-
ences for all content, name and hypertext strings. In order to avoid character reference substitution in
places where it is not desired (e.g. file names) it is recommended to set this option for content strings only
in PDF_set_text_option( ); see PDFlib Tutorial for details. Default: false
CMap (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
compress (Integer) Compression level from 0=no compression, 1=best speed, etc. to 9=best compression. This op-
tion does not affect image data handled in passthrough mode. Default: 6. Scope: any except object
Encoding (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
enumerate- (Boolean) If true, PDFlib will search for font outline files in all directories which can be accessed via the
fonts SearchPath resource. This may take significant time if a large number of fonts is accessible, and should
therefore be used with care. The generated resource list can be saved to a file with the saveresources
option. The recommended strategy is to create and save the resource list only if the number of accessible
fonts has changed, and not for each generated document or for each PDFlib object.
For each valid font outline file PDFlib determines the font-family, font-weight and font-style names
and synthesizes an API font name according to the following scheme:
<font-family>[,<font-weight>][,font-style]
PDFlib creates a FontOutline resource of the form <fontname>=<pathname> which connects the artificial
font name with the full path name of the font. For PostScript Type 1 fonts the corresponding FontAFM or
FontPFM resource will be created as well. In addition to the API font name PDFlib creates a Fontname-
Alias resource with the PostScript name of the font if it is different from the artificial name:
<PostScript fontname>=<artificial fontname>
As a result, the font can be loaded via the artificial font name or its PostScript name. Default: false
escape- (Boolean) If true, enable substitution of escape sequences in all content, name and hypertext strings. In
sequence order to avoid escape sequence substitutions in places where it is not desired (e.g. file names) it is recom-
mended to set this option for content strings only in PDF_set_text_option( ); Default: false
filename- (Keyword) Indicates the encoding of file names. File names supplied as function parameters without
handling UTF-8 BOM in non-Unicode aware language bindings are interpreted according to this option to guard
against characters which would be illegal in the file system and to create a Unicode version of the file
name. An error occurs if the file name contains characters outside the specified encoding. Default:
unicode on Windows and OS X/macOS, auto on i5/iSeries, otherwise honorlang:
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 (Not on i5/iSeries) The environment variables LC_ALL, LC_CTYPE and LANG are interpreted The
codeset specified in LANG is applied to file names if it is available.
legacy Use host encoding to interpret the file name
unicode Unicode encoding in (EBCDIC-) UTF-8 format
all valid encoding names
Any encoding recognized by PDFlib (see Table 4.2) except CMaps, glyphid and builtin
FontAFM (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
Fontname- (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
Alias equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
FontOutline (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
FontPFM (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
glyphcheck (Keyword) See Table 4.6 for a description. It is recommended to set this option for content strings only in
PDF_set_text_option( ); see PDFlib Tutorial for details. Default: replace
HostFont (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
hypertext- (String; only for non-Unicode-capable language bindings) Encoding for hypertext strings. An empty
encoding string is equivalent to unicode. Default: auto
hypertext- (Keyword; only for non-Unicode-capable language bindings) Format for hypertext strings as function pa-
format rameters. Supported keywords are bytes, utf8, ebcdicutf8, utf16, utf16le, utf16be, and auto. Default:
auto
ICCProfile (List of pairs of name strings) List of key/value pairs for a resource definition separated by whitespace or
equal signs = (see PDFlib Tutorial for details). Multiple calls add new entries to the internal list.
iccprofilecmyk (ICC profile handle) ICC profile which specifies a CMYK, Gray, or RGB color space for use with the icc-
iccprofilegray basedcmyk/gray/rgb color options. Default: no ICC color space
iccprofilergb
kerning (Boolean) If true, enable kerning for fonts which have been opened with the readkerning option; disable
kerning otherwise. Default: true
license (String) License key for PDFlib, PDFlib+PDI, or PPS (see PDFlib Tutorial for details). The key can be set be-
fore the first call to PDF_begin_document( ). Use the avoiddemostamp option to make sure that missing
license keys will not accidentally result in a demo stamp.
licensefile (Name string) Name of a file containing the license key (see PDFlib Tutorial for details). The license file
can only be set once before the first call to PDF_begin_document( ).
maxfile- (Unsupported; implemented on Windows only) New maximum for the number of simultaneously open
handles files (in the C runtime). The number must be greater or equal than 20 and less or equal than 2048. An ex-
ception will be thrown if the new value is not accepted by the C runtime. Scope: object
resourcefile (Name string) Relative or absolute file name of the PDFlib UPR resource file. The resource file will be load-
ed immediately before the first access to any resource. Existing resources will be kept; their values are
overridden by new ones if they are set again.
saveresources (Option list) Save the current resource list to a file. The following option is supported:
filename The name of the resource file to which the resource list will be saved. Default: pdflib.upr
searchpath (List of name strings) One or more relative or absolute path name(s) of directories 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). It is recommended to use double braces even for a single entry to
avoid problems with directory names containing space characters. An empty string list (i.e. {{}} )
deletes all existing search path entries including the default entries. On Windows the search path can
also be set via a registry entry. Default: platform-specific, see PDFlib Tutorial
shutdown- (Integer) Strategy for releasing global resources which are allocated once for all PDFlib objects. Each
strategy global resource is initialized on demand when it is first needed. This option must be set to the same value
for all PDFlib objects in a process; otherwise the behavior is undefined (default: 0):
0 A reference counter keeps track of how many PDFlib objects use the global resources. When
the last PDFlib object is deleted the resources are released.
1 The resources are kept until the end of the process. This may slightly improve performance,
but requires more memory after the last PDFlib object is deleted.
stringformat (Keyword; only for non-Unicode-capable language bindings) Format used to interpret all strings at the
API, i.e. name strings, content strings, hypertext strings and option lists. Supported keywords (default:
legacy):
ebcdicutf8 (Only on i5/iSeries and zSeries) All strings and option lists are expected in EBCDIC-UTF-8
format with or without BOM.
legacy Name strings, content strings, hypertext strings and option lists are treated according to the
textformat, hypertextformat and hypertextencoding options.
utf8 (Not on i5/iSeries and zSeries) All strings and option lists are expected in UTF-8 format with or
without BOM. The options textformat, hypertextformat and hypertextencoding are not
allowed. The Textflow option fixedtextformat is forced to true. Legacy CJK CMaps can not
be used for loading fonts. In the C language binding name strings as function parameters are
still interpreted as UTF-16 strings if the length parameter is supplied with a value larger than
0. Use PDF_convert_to_unicode( ) to convert strings in 8-bit encodings to UTF-8.
user- (Boolean) If false, coordinates for hypertext rectangles are expected in the default coordinate system;
coordinates otherwise the current user coordinate system will be used. Default: false
usehostfonts (Boolean) If true, host fonts are included in the font search. Default: true
usehypertext- (Boolean; only for non-Unicode-capable language bindings) If true, the encoding specified in the
encoding hypertextencoding option will also be used for name strings. If false, the encoding for name strings
without UTF-8 BOM is host. Default: false
textformat (Keyword; only for non-Unicode capable language bindings) Format used to interpret content strings.
Supported keywords: bytes, utf8, ebcdicutf8 (only on i5/iSeries and zSeries), utf16, utf16le,
utf16be, and auto. Default: auto
keyword Keyword specifying the option to retrieve. The keywords below are support-
ed; see description of PDF_set_option( ), PDF_set_text_option( ) and PDF_set_graphics_
option( ) regarding their meaning. Keywords for which no corresponding option exists
are described in Table 2.4:
> Keywords for the string index of the n-th entry of the specified resource, where n cor-
responds to the resourcenumber option:
Encoding, FontAFM, FontnameAlias, FontOutline, FontPFM, HostFont, ICCProfile,
searchpath
> Keywords for Boolean option values return 1 for true or 0 for false:
asciifile, autospace,avoiddemostamp, charref, decorationabove, escapesequence, fakebold,
activeitemid (Integer) Item id of the currently active structure item. This may be used with PDF_activate_item() or the
parent suboption of PDF_begin_item() and the tag option. -1 is returned if no root element has been cre-
ated yet. Scope: document, page
activeitem- (Integer) Zero-based index of the currently active structure item within its parent. This may be used with
index the index tag option. If the current item is a pseudo element or the root element or no root element has
been created yet -1 is returned. Scope: document, page
activeitem- (Integer) 1 if the currently active structure item is an inline element, 0 otherwise Scope: document, page
isinline
activeitem- (Integer) Number of child elements of the currently active structure element created up to this point (not
kidcount counting pseudo elements). -1 is returned if no root element has been created yet. Scope: document, page
activeitem- String index for the type name of the currently active structure element or pseudo element, or -1 if no
name root element has been created yet. Scope: document, page
activeitem- String index for the standard element type name to which the currently active item is role mapped, or -1
standard- if no root element has been created yet or the current item is a custom element for which no role map-
name ping is available. If no rolemap is active the original type name is returned. Scope: document, page
ctm_a (Float) The components of the current transformation matrix (CTM) for vector graphics. Scope: page,
ctm_b pattern, template, glyph, path
ctm_c
ctm_d
ctm_e
ctm_f
currentx (Float) The x or y coordinate (in units of the current coordinate system), respectively, of the current point.
currenty Scope: page, pattern, template, glyph, path
icccomponents (Integer) Number of color components in the ICC profile referenced by the handle provided in the
iccprofile option
major (Integer) Major, minor, or revision number of PDFlib, respectively. Scope: any, null1
minor
revision
pageheight (Float) Page size of the current page (dimensions of the MediaBox), template or glyph. Scope: any except
pagewidth object
pdi (Integer) Returns 1 if PDI has been included when building the underlying library. This is true for all com-
bined PDFlib, PDFlib+PDI, and PPS binaries distributed by PDFlib GmbH, regardless of the license key. Oth-
erwise it returns 0. Scope: any, null1
scope (Integer) String index for the name of the current scope (see Table 1.3)
textx (Float) The x or y coordinate of the current text position. Scope: page, pattern, template, glyph
texty
Returns The value of some option as requested by keyword. If no value for the requested key-
word is available, the function returns -1. If the requested keyword produces text, a
string index is returned, and the corresponding string must be retrieved with PDF_get_
string( ).
iccprofile (ICC profile handle; must not refer to an output intent ICC profile) ICC profile for use with the
icccomponents keyword
resource- (Integer) Number of the resource to be retrieved; res0urces are numbered starting with 1. Default: 1
number
Bindings C: The returned string is valid until the next call to any API function.
version (Boolean) Full PDFlib version string in the format <major>.<minor>.<revision>, possibly suffixed with
additional qualifiers such as beta, rc, etc. Scope: any, null1
Details This function creates a new PDFlib object, using PDFlibs internal default error handling
and memory allocation routines.
Returns A handle to a PDFlib object which is to be used in subsequent PDFlib calls. If this func-
tion doesnt succeed due to unavailable memory it returns NULL or throws an excep-
tion.
Scope null; this function starts object scope, and must always be paired with a matching PDF_
delete( ) call.
Bindings C: In order to load the PDFlib DLL dynamically at runtime use PDF_new_dl( ). PDF_new_
dl( ) returns a pointer to a PDFlib_api structure filled with pointers to all PDFlib API func-
tions. If the DLL cannot be loaded, or a mismatch of major or minor version number is
detected, NULL will be returned.
Other language bindings: this function is not available since it is hidden in the PDFlib
constructor.
Create a new PDFlib object with client-supplied error handling and memory allocation
routines.
opaque Pointer to some user data which may be retrieved later with PDF_get_
opaque( ).
Returns A handle to a PDFlib object which is to be used in subsequent PDFlib calls. If this func-
tion doesnt succeed due to unavailable memory it will return NULL in C or throw an ex-
ception in C++.
Details This function creates a new PDFlib object with client-supplied error handling and mem-
ory allocation routines. Unlike PDF_new( ), the caller may optionally supply own proce-
dures for error handling and memory allocation. The function pointers for the error
handler, the memory procedures, or both may be NULL. PDFlib will use default routines
in these cases. Either all three memory routines must be provided, or none.
Bindings C++: this function is indirectly available via the PDF constructor. Not all function argu-
ments must be given since default values of NULL are supplied. All supplied functions
must be C style functions, not C++ methods.
Details This function deletes a PDFlib object and frees all document-related PDFlib-internal re-
sources. This function must only be called once for a given PDFlib object. PDF_delete( )
should also be called for cleanup when an exception occurred. PDF_delete( ) itself is guar-
anteed to not throw any exception. If more than one PDF document will be generated it
is not necessary to call PDF_delete( ) after each document, but only when the complete
sequence of PDF documents is done.
Scope any; no more API function calls with the same PDFlib object are allowed with the PDF
object after this call.
Bindings C: If the PDFlib DLL has been loaded dynamically at runtime with PDF_new_dl( ), use
PDF_delete_dl( ) to delete the PDFlib object.
C++ void create_pvf(string filename, const void *data, size_t size, string optlist)
Java C# void create_pvf(String filename, byte[ ] data, String optlist)
Perl PHP create_pvf(string filename, string data, string optlist)
C void PDF_create_pvf(PDF *p,
const char *filename, int len, const void *data, size_t size, const char *optlist)
filename (Name string) 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 di-
rectory or file name separators.
len (C language binding only) Length of filename (in bytes). If len=0 a null-terminated
string must be provided.
data A reference to the data for the virtual file. In C and C++ this is a pointer to a mem-
ory location. In Java this is a byte array. In Perl, Python, and PHP this is a string. In COM
this is a variant. In REALbasic/Xojo this is a MemoryBlock.
size (C and C++ only) The length in bytes of the memory area containing the data.
optlist An option list according to Table 2.7. The following option can be used: copy
Details The virtual file name can be supplied to any API function which uses input files. Use the
createpvf option of PDF_begin_document( ) to create a PVF file which contains the gener-
ated PDF output. 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 PDF_delete_pvf( ), or automatically in PDF_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 docu-
ments with the same PDFlib object. Multiple threads working with separate PDFlib ob-
jects 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 PDF_delete_pvf( ). Not obey-
ing to this rule will most likely result in a crash.
Scope any
copy (Boolean) If true, PDFlib, creates an internal copy of the supplied data. In this case the caller may dispose
of the supplied data immediately after this call. Default: false for C and C++, but true for all other lan-
guage bindings
filename (Name string; will be interpreted according to the global filenamehandling op-
tion (see Table 2.3) The name of the virtual file as supplied to PDF_create_pvf( ).
len (C language binding only) Length of filename (in bytes). If len=0 a null-terminated
string must be provided.
Returns -1 (in PHP: 0) if the virtual file exists but is locked, and 1 otherwise.
Details If the file isnt 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 PDF_delete( ).
The detailed semantics depend on whether or not the copy option has been supplied
to the corresponding call to PDF_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
Query properties of a virtual file or the PDFlib Virtual File system (PVF).
filename (Name string) The name of the virtual file. The filename may be empty if
keyword=filecount.
len (C language binding only) Length of filename (in bytes). If len=0 a null-terminated
string must be provided.
filecount Total number of files in the PDFlib Virtual File system maintained for the current PDFlib object. The
filename parameter will be ignored.
exists 1 if the file exists in the PDFlib Virtual File system (and has not been deleted), otherwise 0
size (Only for existing virtual files) Size of the specified virtual file in bytes.
iscopy (Only for existing virtual files) 1 if the copy option was supplied when the specified virtual file was creat-
ed, otherwise 0
lockcount (Only for existing virtual files) Number of locks for the specified virtual file set internally by PDFlib func-
tions. The file can only be deleted if the lock count is 0.
Details This function returns various properties of a virtual file or the PDFlib Virtual File sys-
tem (PVF). The property is specified by keyword.
Scope any
Supplying a PDF container object to any of the options listed above freezes the contain-
er object itself as well as all objects referenced from the container directly or indirectly,
i.e. the full object tree created by the container will be frozen. Frozen objects can be used
again with the options above, but they can no longer be modified with PDF_poca_
insert( ) or PDF_poca_remove( ).
Create a new PDF container object of type dictionary, array, or stream and insert objects.
Returns A POCA container handle which can be used until it is deleted with PDF_poca_delete( ).
Details This function creates an empty PDF container object of the specified container type. The
container can immediately be populated in the same call or later calls to PDF_poca_
insert( ).
PDF/VT A POCA container handle for an object of type dictionary with usage=dpm can be sup-
plied as Document Part Metadata (DPM) with the dpm option of PDF_begin/end_dpart( ).
Scope any
container- (Keyword; required) Type of the container: dict, array, or stream. Unspecified array slots and array slots
type which have been removed without inserting a new object will contain the keyword null in the PDF out-
put. Note: containertype=stream is not yet implemented.
usage (Keyword; required) Context in which the new container will be used. This option enables some checks to
make sure that the container is suited for the intended use:
blocks (Only relevant for containertype=dict; only in the PPS product) The Block dictionary (the
container which will be supplied to the blocks option of PDF_begin/end_page_ext( )) must
contain one or more PDFlib Block definitions. The option usage=blocks must also be supplied
to all container objects which will directly or indirectly be inserted into the new dictionary.
dpm (Only relevant for containertype=dict) All keys in the new dictionary or any dictionary
contained in it must consist of ASCII characters, must conform to the rules of an XML
NMTOKEN. This ensures that the dictionary can be used as Document Part Metadata (DPM)
dictionary for PDF/VT. The option usage=dpm must also be supplied to all container objects
which will directly or indirectly be inserted into the new dictionary.
richmediaargs
(Only for containertype=array) The array can contain objects of type string, integer, float,
or Boolean. However, the following is recommended to pass parameters from PDF to Flash: if
a parameter for an ActionScript function parameter has type string, number, or int, use
type=string in POCA (i.e. numbers must be wrapped within strings); if the parameter is de-
clared as Boolean, use type=boolean in POCA (i.e. do not wrap boolean values as string). The
POCA types integer and float should not be used since Acrobat does not pass them correctly
to ActionScript.
optlist An option list according to Table 2.10. The following option can be used:
recursive
Details The container will be deleted and can no longer be used. If the container is referenced
from another dictionary or array all dictionary references to the deleted container are
removed, and all array references to the deleted container are replaced with the null ob-
ject. POCA container objects are not automatically deleted in PDF_end_document( ).
recursive (Boolean) If true, the container object itself and all objects referenced from it will be deleted recursively.
This may be useful as a shortcut for deleting a full object tree which is no longer needed. Default: false
container A valid POCA container handle retrieved with PDF_poca_new( ). Frozen con-
tainers (see Object types and frozen objects, page 37) are not allowed since they can no
longer be modified.
optlist An option list according to Table 2.11. The following options can be used:
direct, hypertextencoding, index, key, type, value, values
Details This function inserts an object in a container. The order in which objects are inserted in
a container is not significant. Inserted containers may be populated after insertion; it is
not required that inserted containers be complete at the time of insertion.
Inserting an object into a container must not create a loop of direct objects within
the object graph. For example, a directly inserted dictionary cannot include a direct ref-
erence to its container. In order to create cyclic references use direct=false to create indi-
rect objects which can reference arbitrary other objects.
Scope any
hypertext- (Keyword) Specifies the encoding for the key, value, and values options. An empty string is equivalent to
encoding unicode. Default: value of the global hypertextencoding option
index (Integer; only for containers with type=array; required for PDF_poca_remove( )) The zero-based index
at which the value(s) will be inserted or deleted in the array. The value -1 can be used to insert the ele-
ment as the new last item. The array will grow as necessary to include an element with the specified in-
dex. If the array already contains a value at the specified index it will be replaced with the new value. De-
fault for PDF_poca_new( ) and PDF_poca_insert( ): -1
key (Hypertext string; only for containers with type=dict and stream; required for type=dict) The key un-
der which the value will be inserted in the dictionary container or the dictionary associated with the
stream container. The key must not include the leading / slash character. The key must conform to the
conditions specified in the dictionarys usage option. If the dictionary already contains an entry with the
same key it will be replaced with the new value.
For type=stream the key must be different from Length and Filter.
1
type (Keyword; required except for stream containers without the key option) Type of the inserted object:
array, boolean, dict, integer, name, float, stream, string, percentage, color
The following types are not allowed if the container has been created with usage=dpm: name (use
type=string instead), stream
The following types are only allowed if the container has been created with usage=blocks: color,
percentage
container A valid POCA dictionary or array handle retrieved with PDF_poca_new( ). Fro-
zen containers (see Object types and frozen objects, page 37) are not allowed since
they can no longer be modified.
optlist The following options of PDF_poca_insert( ) in Table 2.11 can be used:
hypertextencoding, index, key
Details This function removes an object from a container of type array or dictionary. Nothing
happens if the specified object doesnt exist in the container.
Scope any
C++ void begin_document_callback(size_t (*writeproc) (^PDF *p, void *data, size_t size), string optlist)
C void PDF_begin_document_callback(PDF *p,
size_t (*writeproc) (PDF *p, void *data, size_t size), const char *optlist)
filename (Name string; will be interpreted according to the global filenamehandling op-
tion, see Table 2.3) 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 PDF_get_buffer( )
function. On Windows it is OK to use UNC paths or mapped network drives.
len (C language binding only) Length of filename (in bytes). If len=0 a null-terminated
string must be provided.
writeproc (Only for C and C++) C callback function which will be called by PDFlib in or-
der to submit (portions of) the generated PDF data. The supplied writeproc must be a C-
style function, not a C++ method.
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.
PDF_begin_document_callback( ) opens a new PDF document, but instead of writing to
a disk file it calls a client-supplied callback function to deliver the PDF output data. The
function supplied as writeproc must return the number of bytes written. If the return
value doesnt match the size argument supplied by PDFlib, an exception will be thrown.
The frequency of writeproc calls is configurable with the flush option.
Scope object; this function starts document scope if the file could successfully be opened, and
must always be paired with a matching PDF_end_document( ) call.
Bindings ASP: the MapPath facility should be used to construct full path names to be passed to
this function.
C, C++, Java, JScript: take care of properly escaping the backslash path separator. For ex-
ample, the following denotes a file on a network drive: \\\\malik\\rp\\foo.pdf.
PDF_begin_document_callback( ) is only available in C and C++.
Details This function finishes the generated PDF document, frees all document-related resourc-
es, and closes the output file if the PDF document has been opened with PDF_begin_
document( ). This function must be called when the client is done generating pages, re-
gardless 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 PDF_
get_buffer( )), and will be freed in the next call to PDF_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 one of PDF_begin_document( ) or PDF_begin_document_callback( ).
associated- (List of asset handles; only for PDF 2.0 and PDF/A-3) Asset handles for associated files. The files must have
files1 been loaded with PDF_load_asset( ) and type=attachment.
attachments (List of option lists or list of asset handles; not for PDF/X-1a/3 and PDF/A-1; PDF/A-2: only PDF/A-1 and
PDF/A-2 documents can be attached; PDF/A-3: not allowed, use associatedfiles instead) Specifies docu-
ment-level file attachments which have been loaded with PDF_load_asset( ) and type=attachment. It is
OK to supply file attachments both in PDF_begin_document( ) and PDF_end_document( ). However, as-
set handles can only be supplied in PDF_end_document( ). Supported suboptions: see Table 13.6
autoxmp (Boolean; forced to true for PDF/X-3/4/5 and PDF/A) If true, PDFlib will create XMP document metadata
from document info fields (see Section 14.2, XMP Metadata, page 261). 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.10.
destname1 (Hypertext string; will be ignored if the destination option has been specified) The name of a destina-
tion which has been defined with PDF_add_nameddest( ), and will be used as the document open action.
groups2 (List of strings; not allowed in PDF/VT mode or if a document part hierarchy is created) 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 as-
signed to a page group.
labels (List of option lists) A list containing one or more option lists according to Table 3.6 specifying symbolic
page names. The page name will be displayed as a page label (instead of the page number) in Acrobats
status line. The combination of style/prefix/start must be unique within a document. Default: no
page labels
linearize (Boolean; only for PDF_begin_document( ); forces objectstreams=none) If true, the output document
will be linearized. On z/OS this option cannot be combined with an empty filename. Default: false
metadata (Option list) Supply XMP document metadata (see Section 14.2, XMP Metadata, page 261). Individual
XMP properties may be overridden with document info fields supplied with PDF_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
openmode (Keyword) Set the appearance when the document is opened. Default: bookmarks if the document con-
tains 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.
2
optimize (Boolean; forces objectstreams=none)) 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). On z/OS this option cannot be
combined with in-core generation (i.e. an empty filename). Default: false
pagelayout (Keyword) The page layout to be used when the document is opened (default: default):
default The default setting of the PDF 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.
1
portfolio (Option list; PDF 1.7) Suboptions for creating a PDF portfolio according to Table 12.13
search (Option list; deprecated because not part of ISO 32000-1) Instruct Acrobat to attach a search index when
opening the document. The following suboptions are supported:
filename (Hypertext string; required) Name of a file containing a search index
indextype (Name string) Type of the index; must be PDX for Acrobat. Default: PDX
uri (String) Set the documents 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: no base
URI
viewer- (Option list) Option list specifying various viewer preferences according to Table 3.7. Default: empty
preferences
compatibility (Keyword; ignored if one of the pdfa, pdfua, pdfvt or pdfx options is used with a value different from
none) Set the documents PDF version to one of the keywords below. This option affects which PDF cre-
ation features are available and which PDF documents can be imported with PDFlib+PDI (default: 1.7):
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 or above.
2.0 PDF 2.0 is specified in ISO 32000-2.
limitcheck If true, the limit for the number of indirect PDF objects (8.388.607) is enforced in PDF/A-1/2/3 and PDF/X-
4/5 modes. Default: true
nodenamelist (List of name strings; required for pdfvt=PDF/VT-1 and pdfvt=PDF/VT-2) Names for all levels of the doc-
ument part hierarchy. All names must consist of ASCII characters and must conform to the rules of an
XML NMTOKEN. The first string specifies the name for level 0 in the document part hierarchy.
pdfa (Keyword) Set the PDF/A conformance level to one of the following (default: none):
PDF/A-1a:2005, PDF/A-1b:2005 (implies compatibility=1.4)
PDF/A-2a, PDF/A-2b, PDF/A-2u (implies compatibility=1.7)
PDF/A-3a, PDF/A-3b, PDF/A-3u (implies compatibility=1.7)
none
PDF/A1-a:2005, PDF/A-2a, and PDF/A-3a imply tagged=true. PDF/A can simultaneously conform to oth-
er standards as follows:
pdfx=PDF/X-1a:2003, PDF/X-3:2003, PDF/X-4
pdfvt=PDF/VT-1
pdfua=PDF/UA-1
If multiple options for PDF standards are specified the lowest compatibility value is used.
pdfua (Keyword) Set the PDF/UA conformance level to one of the following (default: none):
PDF/UA-1 Implies compatibility=1.7 and tagged=true.
none No PDF/UA output
pdfvt (Keyword) Set the PDF/VT conformance level to one of the following (default: none):
PDF/VT-1 Implies pdfx=PDF/X-4; any other value for the pdfx option is an error.
PDF/VT-2 The pdfx option must specify one of PDF/X-4p, PDF/X-5g, PDF/X-5pg; any other value for the
pdfx option is an error.
none No PDF/VT output
pdfx (Keyword) Set the PDF/X conformance level to one of the following (default: none):
PDF/X-1a:2003 (implies compatibility=1.4)
PDF/X-3:2003 (implies compatibility=1.4)
PDF/X-4, PDF/X-4p1 (implies compatibility=1.6)
PDF/X-5g, PDF/X-5pg1, PDF/X-5n1 (implies compatibility=1.6)
none
recordlevel (Non-negative integer; only relevant if a document part hierarchy is created) Zero-based level of the
document part hierarchy which corresponds to recipient records.
uses- (Boolean; only for PDF/VT) If false, none of the pages in the generated document will contain any trans-
transparency parent objects. PDFlib will throw an exception if this assertion is violated. Setting this option to false is
allowed only for documents without transparency, and facilitates generation of encapsulated XObjects
for PDF/VT since all XObjects will unconditionally be marked as encapsulated. Default: true
1. The PDFlib Tutorial contains an important note about Acrobat problems with referenced ICC profiles.
checktags (Keyword; must be strict in PDF/UA-1 mode) Specifies whether the structure element nesting rules (see
PDFlib Tutorial) are checked for elements created with PDF_begin_item( ) or the tag option of various
functions. This option is only provided as a migration aid. It does not affect the tags in imported pages
(see option checktags of PDF_open_pdi_document( )). Supported keywords (default: strict):
none Tag nesting rules are not enforced. This setting may result in an invalid structure hierarchy
and is therefore not recommended.
relaxed Similar to strict except that a few rules are not enforced (see PDFlib Tutorial).
strict If a tag violates the nesting rules an exception will be thrown.
lang (String; recommended if tagged=true) Set the primary 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 structure items on all levels of the structure
tree, but should be set initially for the document as a whole.
PDF/UA-1: the natural language must be specified with this option or with the lang suboption of individ-
ual structure elements.
rolemap (List of string lists; the first element in each string list is a name string, the second element is a string; only
for Tagged PDF; required if custom element types are used) Mapping of custom element types to stan-
dard element types. Each sublist contains the name of a standard or custom element type, and the name
of the standard element type to which the first type will be mapped. Inline and pseudo element types are
not allowed for the second entry in a sublist. Standard element type names also can be mapped to other
standard element types in order to assign different semantics to existing element types. Indirect map-
pings are allowed, i.e. a custom type is mapped to another custom type which is then mapped to a stan-
dard type. Pairs with identical entries are silently ignored. See Section 14.3, Tagged PDF, page 262, re-
garding the use of custom element types in Tagged PDF. Custom element type names must not start with
the reserved prefix Plib.
In PDF/UA-1 it is not allowed to remap standard element types.
structuretype (Keyword; only for PDF/UA-1) Type of document structure. Supported keywords (default: weak):
strong The document is strongly structured, i.e. the structure tree reflects the documents logical
organization. The only allowed structure type for headings is H, while H1, H2, etc. are not
allowed. Each node in the structure tree contains at most one H tag plus one or more
paragraph tags P.
weak The document is weakly structured, i.e. the structure tree is only a few levels deep with all
headings, paragraph etc. as immediate children. Logical structure may be expressed with
heading tags H1, H2, etc., while H is not allowed. Headings may not have any descendants.
tag (Option list) Tagging options according to Table 14.4. The specified structure element comprises the docu-
ment structure root and will be closed automatically in PDF_end_document( ). Only grouping elements
are allowed for the tagname suboption.
tagged (Boolean) If true, generate Tagged PDF output. Proper structure information must be provided by the cli-
ent in Tagged PDF mode (see Section 14.3, Tagged PDF, page 262). If PDF/A-1a:2005, PDF/A-2a, PDF/A-
3a or PDF/UA-1 mode is active this option is automatically set to true. Default: false
Table 3.4 Security options for PDF_begin_document( ); not allowed for PDF/A and PDF/X
option description
attachment- (String2; PDF 1.6; will be ignored if userpassword or masterpassword are set; can not be combined with
password1 the linearize and optimize options; not for PDF/A and PDF/X) File attachments will be encrypted using
the supplied string as password. The rest of the document will not be encrypted. On EBCDIC platforms
the password is expected in ebcdic encoding or EBCDIC-UTF-8.
master- (String; required if permissions has been specified; not for PDF/A and PDF/X) The master password for
password1 the document. If it is empty no master password will be applied. On EBCDIC platforms the password is
expected in ebcdic encoding or EBCDIC-UTF-8. Default: empty
permissions (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
Acrobat will prevent high-resolution printing. If noprint isnt 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 (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 (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
(Deprecated in PDF 2.0; not allowed in PDF/UA-1) Acrobat will prevent extracting text or
graphics for accessibility (e.g. a screenreader).
plainmetadata
(PDF 1.5) Keep XMP document metadata unencrypted even in an encrypted document.
user- (String; not for PDF/A and PDF/X) The user password for the document. If it is empty no user password
password1 will be applied. On EBCDIC platforms the password is expected in ebcdic encoding or EBCDIC-UTF-8. De-
fault: empty
1. In order to pass arbitrary strings with this option the option list syntax described in Unquoted string values, page 10, may be useful.
2. Characters outside of Winansi encoding are only allowed in passwords for compatibility=1.7ext3 or above
createoutput (Boolean) If false, the filename parameter is ignored and no output file or memory area is created. This
option implies compress=0, linearize=false and optimize=false. Default: true
createpvf (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 PDF_end_document( ). In this case PDF_get_buffer( )
cannot be called to fetch the PDF output data; instead, the name of the generated PVF file can be sup-
plied to other PDFlib functions. This may be useful when generating documents which will be included in
a PDF Portfolio. Default: false
filemode (String, z/OS and USS only) Parameter string for setting the file mode of the document file and any tem-
porary file (e.g. with the linearize option). The supplied string is appended to the default file mode of
wb,. The option recordsize must be consistent with the parameters specified in this option. Default:
empty, or recfm=v for unblocked output (which is default, see option recordsize)
Example strings:
recfm=fb,lrecl=80,space=(cyl,(1,5)
Honor attributes of the dataset if it has already been allocated: recfm=*
flush (Keyword; only for PDF_begin_document_callback( )) Set the flushing strategy (default: page):
none flush only once at the end of the document
page flush at the end of each page
content flush after all fonts, images, file attachments, and pages
heavy always flush when the internal 64 KB document buffer is full
inmemory (Boolean; not for PDF_begin_document_callback( )) 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 mem-
ory. This can result in tremendous performance gains on some systems (especially z/OS), but requires
memory twice the size of the document. If false, a temporary file will be created for linearization and op-
timization. Default: false
recordsize (Integer; z/OS and USS only) The record size of the output file, and any temporary file which may have to
be created for the linearize and optimize options. Default: 0 (unblocked output)
remove- If true, a partial PDF output document which exists after an exception will be removed in PDF_delete( ).
fragments Such PDF fragments are never usable as documents. This option has no effect if an empty filename has
been specified, i.e. for in-memory PDF generation. Default: false
tempdirname (String; not for PDF_begin_document_callback( )) Directory where temporary files for the linearize and
optimize options will be created. If this option is missing, PDFlib will generate temporary files in the cur-
rent directory. This option will be ignored if the tempfilenames option has been supplied. Default: not
present
temp- (List of two strings; only for z/OS and USS) Full file names for two temporary files required for the
filenames linearize and optimize options. If empty, PDFlib will generate unique temporary file names. The user is
responsible for deleting the temporary files after PDF_end_document( ). If this option is supplied the
filename parameter must not be empty. Default: not present
group (String; only for PDF_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
PDF_begin_document( ).
hypertext- (Keyword) Specifies the encoding for the prefix option. An empty string is equivalent to unicode. De-
encoding fault: value of the global hypertextencoding option.
pagenumber (Integer; only for PDF_end_document( ); required if the document does not use page groups, but not al-
lowed 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 num-
bered sequentially starting with this value. Default: 1
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; only true allowed in PDF/UA-1 mode) Display the Title document info field in Acrobats title bar
(true) or the file name (false). Default: true for PDF/UA-1, otherwise 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.
none No paper handling specified.
Simplex Print single-sided.
fitwindow (Boolean) Specifies whether to resize the documents window to the size of the first page. Default: false
1
hidemenubar (Boolean) Specifies whether to hide Acrobats menu bar. Default: false
1
hidetoolbar (Boolean) Specifies whether to hide Acrobats tool bars. Default: false
hide- (Boolean) Specifies whether to hide Acrobats window controls. Default: false
windowui1
nonfullscreen- (Keyword; only relevant if the openmode option is set to fullscreen) Specifies how to display the docu-
pagemode ment 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
picktrayby- (Boolean; PDF 1.7; no effect on X/macOS) Specifies whether the PDF page size is used to select the input
pdfsize 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.
printpage- (List with pairs of integers; PDF 1.7) Page numbers for the print dialog. Each pair denotes the start and end
range page numbers of a page range to be printed (first page is 1). Default: viewer-specific
printarea (Keyword; for PDF/X only media and bleed are allowed) The type of the page boundary box representing
printclip the area of a page to be displayed or clipped when viewing the document on screen or printing it. Acro-
viewarea bat ignores this setting, but it may be useful for other applications. Supported keywords (default: crop):
viewclip art Use the ArtBox
bleed Use the BleedBox
crop Use the CropBox
media Use the MediaBox
trim Use the TrimBox
1. Acrobat 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.
size (C and C++ language bindings only) C-style pointer to a memory location where
the length of the returned data in bytes will be stored.
Returns A buffer full of binary PDF data for consumption by the client. The function returns a
language-specific data type for binary data. The returned buffer must be used by the cli-
ent before calling any other PDFlib function.
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 generat-
ing PDF into memory, this function must at least be called after PDF_end_document( ),
and will return the remainder of the PDF document. It can be called earlier to fetch par-
tial document data. If there is only a single call to this function which happens after
PDF_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 ac-
cept non-printable characters including null values.
Scope object, document (in other words: after PDF_end_page_ext( ) and before PDF_begin_page_
ext( ), or after PDF_end_document( ) and before PDF_delete( ). This function can only be
used if an empty filename has been supplied to PDF_begin_document( ).
If the linearize option in PDF_begin_document( ) has been set to true, the scope is re-
stricted to object, i.e. this function can only be called after PDF_end_document( ).
Bindings C and C++: the size parameter is only used for C and C++ clients.
COM: 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).
Other bindings: an object of appropriate length will be returned, and the size param-
eter must be omitted.
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.8. The PDFlib
Tutorial lists applicable page size limits in Acrobat. See also Table 3.9 for more details
(options width and height).
1. Note that ISO B5 is different from JIS B5. More information about ISO, Japanese, and U.S. standard formats can be
found atwww.cl.cam.ac.uk/~mgk25/iso-paper.html
optlist An option list with page options according to Table 3.9. These options have low-
er priority than identical options specified in PDF_end_page_ext( ):
action, artbox, associatedfiles, bleedbox, blocks, 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 to their default values,
and establishes a coordinate system according to the topdown option.
Scope document; this function starts page scope, and must always be paired with a matching
PDF_end_page_ext( ) call.
action (Action list; not for PDF/A) 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.
associatedfiles (List of asset handles; only for PDF 2.0 and PDF/A-3) Asset handles for associated files. The files must have
been loaded with PDF_load_asset( ) and type=attachment.
artbox (Rectangle) Specify the ArtBox, BleedBox, or CropBox for the current page, respectively. The coordinates
bleedbox are specified in the default coordinate system. Default: no box entries
cropbox
blocks (POCA container handle; may be supplied to PDF_begin_page_ext( ) or PDF_end_page_ext( ), but not to
both functions for the same page; only available in PPS) Handle for a dictionary container created with
PDF_poca_new( ) which contains PDFlib Block definitions for the PDFlib Personalization Server (PPS). The
specified Blocks will be attached to the page. The dictionary must have been created with the option
usage=blocks. Default: no Blocks
defaultgray1 (ICC handle or keyword; not for PDF/X-1a) Set a default gray, RGB, or CMYK color space for the page ac-
defaultrgb1 cording to the supplied ICC profile handle. The option defaultrgb also supports the keyword srgb. The
defaultcmyk1 specified color space is used to map device-dependent gray, RGB, or CMYK colors on the page.
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; not allowed in PDF/VT
mode or if a document part hierarchy is created) 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 PDF_resume_
page( ). The group name must have been defined with the groups option in PDF_begin_document( ).
height (Float or keyword; not allowed if the topdown option is true) 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 pages MediaBox, but the
MediaBox can also explicitly be set using the mediabox option. The width and height options override
the parameters with the same name.
The following symbolic ISO 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.6 specifying symbolic page names. The page name will be
displayed as a page label (instead of the page number) in Acrobats 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.
mediabox (Rectangle; not allowed if the topdown option 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 overrides the width and height options
and parameters.
metadata (Option list) Metadata for the page (see Section 14.2, XMP Metadata, page 261)
1
pagenumber (Integer; not allowed in PDF/VT mode or if a document part hierarchy is created) 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 doesnt use page groups). If this option is not speci-
fied 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 coordi-
nate system. Possible values are 0, 90, 180, 270. Default: 0
separation- (Option list) An option list containing color separation details for the current page. This will be ignored in
info1 Acrobat, but may be useful in third-party software for identifying and correctly previewing separated
pages in a pre-separated workflow:
pages (Integer; required for the first page of a set of separation pages, but not allowed for subse-
quent pages of the same set) The number of pages which belong to the same set of separa-
tion 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; only structure allowed in PDF/UA-1) Keyword specifying the tab order for form fields
and annotations (Default: structure in Tagged PDF mode for PDF 1.5 and above, otherwise none):
column Column by column from top to bottom, where columns are ordered as specified by the
direction suboption of the viewerpreferences option of PDF_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.
row 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 PDF_begin/end_document( ).
topdown1 (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
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 Acrobats full-screen 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.
trans- (Option list or keyword; not for PDF/A-1 and PDF/X-1a/3; restrictions apply to PDF/A-2/3 and PDF/X-4/5)
parency- Create a transparency group for the page. The following keywords are supported (default: auto):
group auto If transparent objects are present on the page itself or on an imported PDF page, graphics or
template, the transparencygroup option is automatically created with a suitable color
space; otherwise no transparency group is created.
none (Not allowed for PDF/A-2/3 without output intent and PDF/X-5n if transparency is used on the
page) Dont create any transparency group for the page.
The following suboptions can be used to explicitly create a transparency group:
colorspace (Keyword or ICC profile handle; required for PDF/A-2/3 without output intent and PDF/X-5n if
transparency is used on the page) Blending color space for the page (default: none):
DeviceCMYK PDF/A-2/3 and PDF/X-4/5g/pg: only allowed with a CMYK output intent or if the
defaultcmyk option has been supplied.
PDF/X-5n: only allowed if the output intent contains the Colorants Cyan, Magenta,
Yellow and Black or if the defaultcmyk option has been supplied.
DeviceGray PDF/A-2/3 and PDF/X-4/5g/pg: only allowed with a gray or CMYK output intent or
if the defaultgray option has been supplied.
PDF/X-5n: only allowed if the output intent contains the Colorant Black or if the
defaultcmyk option has been supplied.
DeviceRGB PDF/A-2/3 and PDF/X-4/5g/pg: only allowed with an RGB output intent or if the
defaultrgb option has been supplied.
PDF/X-5n: only allowed if the defaultrgb option has been supplied.
none (Not allowed for PDF/A-2/3 without output intent and PDF/X-5n if transparency is
used on the page) No color space is emitted for the transparency group.
srgb Keyword for selecting the sRGB color space
isolated (Boolean) Specifies whether the transparency group is isolated. Default: false
knockout (Boolean) Specifies whether the transparency group is a knockout group. Default: false
trimbox (Rectangle) Specify the TrimBox for the current page. The coordinates are specified in the default coordi-
nate 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 dont change the actual
page contents; they are only a hint to Acrobat which is used when printing the page or using the mea-
surement 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 12.7, Geospatial Features, page 243, for details.
Viewports allow different geospatial references (specified by the georeference option) to be used on dif-
ferent 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 is true) See height option.
Details The full graphics, color, text and layer states of the current page are saved internally.
The page can later be resumed with PDF_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
PDF_resume_page( ) call. In Tagged PDF mode all inline and pseudo items must be closed
before calling this function.
optlist An option list according to Table 3.10. The following options can be used:
group, pagenumber
Details The page must have been suspended with PDF_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.
In Tagged PDF mode it must be kept in mind that resuming a page does not restore
any structure item. Instead, the item which is active when PDF_resume_page( ) is called
will be the current item for subsequent page contents. It is recommended to use PDF_
activate_item( ) to restore a specific structure element on the page as parent for
subsequently generated contents.
Scope document; this function starts page scope, and must always be paired with a matching
PDF_suspend_page( ) call.
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 PDF_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 doesnt use page groups) will be resumed. If this
option is missing the last page in the group will be resumed.
len (C language binding only) Length of name (in bytes). If len = 0 a null-terminated
string must be provided.
Returns A layer handle which can be used in calls to PDF_begin_layer( ) and PDF_set_layer_
dependency( ) until the end of the enclosing document scope.
Details PDFlib will issue a warning if a layer was defined but hasnt been used in the document.
Layers which are used on multiple pages should be defined only once (e.g. before creat-
ing the first page). If PDF_define_layer( ) is called repeatedly on multiple pages, the layer
definitions will accumulate (even if they have the same name), which is usually not de-
sired.
creatorinfo (Option list; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) 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 is visible by default. Default: true
initial- (Boolean; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) Specifies the layers recommended export state. If
exportstate true, Acrobat includes the layer when converting/exporting to older PDF versions or other document for-
mats. Default: true
initial- (Boolean; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) The layers recommended printing state. If true,
printstate Acrobat includes the layer when printing the document. Default: true
initial- (Boolean; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) The layers recommended viewing state. If true,
viewstate Acrobat displays 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/A-2/3, PDF/X-4/5, and PDF/UA-1) 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
onpanel (Boolean; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) If false, the layer name will not be visible in Acro-
bats layer panel, and therefore cannot be manipulated by the user. Default: true
pageelement (Keyword; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) Specifies that the layer contains a pagination ar-
tifact: one of HF (header/footer), FG (foreground image or graphic), BG (background image or graphic), or
L (logo).
printsubtype (Option list; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) Specifies whether the layer is intended for print-
ing:
subtype (Keyword) One of Trapping, PrintersMarks, or Watermark specifying the kind of content in
the layer.
printstate (Boolean) If true, Acrobat activates 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 pages layer list.
A layer is considered used on a page if it has been supplied to PDF_begin_layer( ) at least once on that
page. Default: false
zoom (List of floats or percentages; not for PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) One or two values specifying
the layers 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.
GroupAllOn The layer specified in the depend option will be visible if all layers specified in the group option are visi-
ble. Options specific for this type: depend, group
GroupAnyOn 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 The layer specified in the depend option will be visible if all layers specified in the group option are invis-
ible. Options specific for this type: depend, group
GroupAnyOff The layer specified in the depend option will be visible if any layer specified in the group option is invisi-
ble. Options specific for this type: depend, group
3.4 Layers 59
Table 3.12 Dependency and relationship types for layers
type notes; options specific for this type
Lock (PDF 1.6) The layers specified in the group option are locked, i.e. their state cannot be changed interac-
tively in Acrobat. Options specific for this type: group
Parent Specify a hierarchical relationship between the layer specified in the parent option and the layers speci-
fied in the children option. Setting the parent to invisible automatically sets its children to invisible. A
layer cannot belong to more than one parent layer. Options specific for this type: children, parent
Radiobtn Specify a radio button relationship between the layers specified in the group option. This means that at
most one layer in the group is visible at a time, which is particularly useful for multiple language layers.
Option specific for this type: group
Title The layer specified in the parent option does not control any page contents directly, but serves as a hier-
archical separator for the layers specified in the children option. Options specific for this type:
children, parent
Details Layer relationships specify the presentation of layer names in Acrobats layer pane as
well as the visibility of one or more layers when the user interactively enables or dis-
ables layers.
Scope any except object; Layer relationships should be specified after all layers have been
defined.
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.
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.
parent (Layer handle; only for type=Parent and Title) The layer which is the parent of the layers specified in
the children option.
Start a layer for subsequent output on the page (requires PDF 1.5).
layer The layers handle, which must have been retrieved with PDF_define_layer( ).
Scope page
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 PDF_begin_layer( ) is suffi-
cient; it is not required to explicitly call PDF_end_layer( ) to close layer A. PDF_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 61
62 Chapter 3: Document and Page Functions
4 Font and Text Functions
4.1 Font Handling
fontname (Name string) Name of the font. It can alternatively be provided via the
fontname option which overrides this parameter. See option fontname in Table 4.2 for
details.
encoding Name of the encoding. It can alternatively be provided via the encoding op-
tion which overrides this parameter. See option encoding in Table 4.2 for details. Note
the following common encoding-related problems:
> An 8-bit encoding was supplied but the font does not contain any glyph for this en-
coding, or the font is a standard CJK font.
> The encoding builtin was supplied, but the font does not contain any internal encod-
ing. This can only happen for TrueType fonts.
> A CMap was supplied but doesnt match the font.
Returns A font handle for later use with PDF_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 (in PHP: 0) will be returned or an exception
raised. The error behavior can be changed with the errorpolicy option.
If the function returns an error you can request the reason of the failure with PDF_
get_errmsg( ). Otherwise, the value returned by this function can be used as font handle
when calling other font-related functions. The returned handle doesnt have any signif-
icance to the user other than serving as a font handle.
The returned font handle is valid until the font is closed with PDF_close_font( ). Fin-
ishing the document with PDF_end_document( ) closes each open font handle unless the
option keepfont has been supplied in the respective PDF_load_font( ) call, or the font has
been loaded in object scope (i.e. outside of any document).
Scope any
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 other-
wise (which can be queried with PDF_info_font( ))
auto- (Boolean) Dynamically decide whether or not the font will be subset, subject to the subsetlimit and
subsetting subsetminsize options and the actual usage of glyphs. This option will be ignored if the subsetting op-
tion has been supplied. Default: true
dropcore- (Boolean; unsupported; forced to false for PDF/A, PDF/UA, and PDF/X) The widths for unembedded core
widths fonts will not be emitted in the generated PDF. The slightly reduces output file size, but may create incor-
rect 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, PDF/UA 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 en-
codings 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.
Font embedding can also be controlled with the skipembedding option.
encoding (String; required for implicit font loading if the text appearance option font is not specified) Encoding in
which incoming text for this font is interpreted:
Wide character encodings:
> unicode or the name of a Unicode CMap
> Identity-H or Identity-V for CID addressing
> glyphid: all glyphs in the font can be addressed by their font-specific ID
fallbackfonts (List of option lists according to Table 4.3) Specify one or more fallback fonts for the loaded font. Each fall-
back 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.1).
If glyphcheck=replace and the text contains a character which is not part of the base fonts 8-bit encod-
ing, 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 or-
der 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 PDF_fill_textblock( ) if the text appearance op-
tion 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.
PDF_load_font( ): the font name can alternatively be provided as function parameter.
fontstyle (Keyword; deprecated) Controls the creation of artificial font styles. Possible keywords are normal, bold,
italic, bolditalic. All text created with this font will be styled with the fakebold and/or italicangle
text appearance options as appropriate. Unless another value of italicangle has been set, -12 is used.
If this option is applied to one of the core fonts, the appropriate bold, italic, or bolditalic font variant will
be selected instead of faking the font style. If no such font is available (e.g. applying bold to Times-Bold),
the option is ignored. Default: normal
initialsubset (List of Unichars or Unicode ranges, or list of keywords; only relevant for embedding=true and sub-
setting=true) Specify the Unicode values for which glyphs will be included in the initial font subset.
This can be used to reduce the PDF output file size by creating identical subsets, which facilitates later op-
timizations when merging multiple documents. The Unicode values can be specified explicitly by Uni-
chars 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 PDF_end_
document( ). If true the font can also be used in subsequent documents until PDF_close_font( ) has been
called. Default: true if PDF_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 or custom CMaps; will be forced to false if embedding=true) If false, text in this font will be con-
verted to CID values when creating PDF output. The text supplied to API functions must still match the
selected CMap (e.g. Shift-JIS). However, the font can be used in Textflow and all simple text output func-
tions (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.
metadata (Option list) Supply metadata for the font (see Section 14.2, XMP Metadata, page 261)
monospace (Integer between 1 and 2048; not for PDF/A and PDF/UA; deprecated) 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 should only be used for standard
CJK fonts, and is not supported for core fonts; it will be ignored if the font is embedded. Default: absent
(metrics from the font will be used)
optimize- (Boolean; not for PDF/X-1/2/3) If true, fonts which are exclusively used for invisible text (i.e. text-
invisible rendering=3) will not be embedded even if embedding=true. This may be useful to avoid font embed-
ding 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 docu-
ment. Default: false
preservepua (Boolean) If true, characters which are mapped to a Unicode value in the Private Use Area (PUA) in the
font retain their PUA value in the PDF output. This may be useful if the PUA characters carry locally de-
fined semantics such as Japanese Gaiji/EUDC characters. If false, PUA characters are mapped to
U+FFFD (Unicode replacement character) in the ToUnicode CMap in the PDF output. 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 option (see Table 5.4). 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 kern-
ing values to text is controlled by the kerning text option (see Table 4.7). Setting this option to false
may speed up font loading if kerning is not required. Default: true for horizontal writing mode, false for
vertical writing mode
readselectors (Boolean; only relevant for TrueType and OpenType fonts) If true, the variation selectors will be read
from the font if available. This is required for automatically substituting Ideographic Variation Sequences
(IVS) within Unicode text. Default: true
readshaping (Boolean; only relevant for TrueType and OpenType fonts and the encodings unicode and glyphid) Spec-
ifies 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 option (see Table 5.4). Setting
readfeatures to false can save memory if shaping is not required. Default: true
readvertical- (Boolean) If true and the option vertical is also true the vertical metrics of a TrueType or OpenType
metrics font (if present) is used for formatting the text output. Default: false
replace- (Unichar or keyword; only relevant for glyphcheck=replace; ignored for fonts loaded with a non-Uni-
mentchar code 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. If the font doesnt contain any glyph for the specified Unicode character, the behavior of
auto will be applied. U+0000 can be used to specify the fonts missing glyph symbol. For symbolic
fonts loaded with encoding=builtin the byte code must be supplied instead of the Unicode value. The
following keywords can be used as an alternative to a Unicode character (default: auto):
auto The first character from the following list for which a glyph is available in the font will be
used as a replacement character:
U+00A0 (NO-BREAK SPACE), U+0020 (SPACE), U+0000 (missing glyph symbol).
drop No output will be created for the character.
error An exception will be thrown if a typographically similar character is not available. This may
be used to avoid unreadable text output.
simplefont (Boolean; only relevant for TrueType fonts with an 8-bit encoding) If this option is true, the font is emit-
ted as simple font instead of as a CID font. For some PDF viewers (particularly Acrobat) this is required for
successful font substitution if the font is not installed on the viewing machine. The value true is recom-
mended when loading fonts for use in form fields. Default: false
skip- (List of keywords; only relevant for embedding=true) Silently ignore font embedding if the font satisfies
embedding one or more of the conditions specified in the list. This may be useful in situations where font embedding
is generally desired, but an unembedded font is preferable for specific kinds of fonts or error situations.
Supported keywords:
fstype The font is a TrueType or OpenType font and cannot be embedded because it doesnt permit
embedding according to the fsType flag in the fonts OS/2 table.
hostfont The font was loaded as a host font.
latincore The font is included in the set of 14 Latin core fonts (see PDFlib Tutorial for full list), but cannot
be embedded because no font outline file is available.
metricsonly
Only the PFM or AFM metrics file for the font is available, but the font cannot be embedded
because no font outline (PFA, PFB) file is available.
standardcjk
The font is included in the set of standard CJK fonts (see PDFlib Tutorial for full list), but
cannot be embedded because no font outline file is available.
Default: empty list
In PDF/A, PDF/X and PDF/UA only an empty list is allowed.
skippost- (Boolean; unsupported; only relevant for TrueType and OpenType fonts) Specifies whether the post table
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; ignored for Type 3 fonts) Disable automatic font subsetting if the percentage of
glyphs used in the document related to the total number of glyphs in the font exceeds the provided per-
centage. Default: 100%
subsetminsize (Float; ignored for Type 3 fonts) Disable automatic font subsetting 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
PDF_load_font( ). Default: subsetting is enabled automatically based on the subsetlimit/subsetmin-
size settings.
unicodemap (Boolean; must not be set to false for PDF/A-1a/2a/2u/3a/3u and PDF/UA-1) Controls generation of ToU-
nicode 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.
font loading If the font is specified implicitly (i.e. via the fontname and encoding options, as opposed to the font op-
options tion), all font loading options according to Table 4.2 except fallbackfonts can be supplied as subop-
tions. 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 PDF_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
doesnt match that of the base font. Default: 100%
forcechars (List of Unichars or Unicode ranges, or single keyword) Specify characters which are always 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.
One of the following keywords can be supplied:
gaiji 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.
all All glyphs in the fallback font will be used to replace the corresponding characters in the base
font, even if the character is available in the base font.
textrise (Float or percentage) Text rise value (see Table 4.7). Percentages are based on the size specified for the fall-
back font (i.e. after applying the fontsize suboption if present). This option can be used to adjust the po-
sition of text in the fallback font if the design size of the fallback font doesnt match that of the base font.
Default: 0
Close an open font handle which has not yet been used in the document.
font A font handle returned by PDF_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 PDF_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 PDF_
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
font A font handle returned by PDF_load_font( ), or -1 (in PHP: 0) for some keywords.
keyword A keyword specifying the requested information according to Table 4.5. 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, hostfont, kerningpairs, numglyphs,
shapingsupport, vertical
> Keywords for Ideographic Variation Selectors:
maxuvsunicode, minuvsunicode, selector, selectorlist
> 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.5.
> Mapping options according to Table 4.4 for specifying glyphs:
cid, code, glyphid, glyphname, selector, 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.
code (Number in the range 0...255; only for fonts with 8-bit encoding) Encoding slot
selector (Unichar) Unicode value of a variation selector in the range U+0xFE00..U+FE0F or U+E0100..U+E01EF. All
values returned by the selector keyword can be supplied here.
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 (in PHP: 0)
Details This function supplies information from the following distinct sources:
> If a valid font handle is supplied it returns information gathered from the font. Ex-
amples: font metrics, name, or type; unicode value for a particular glyphid.
> If font = -1 (in PHP: 0) and the encoding option is supplied it returns information
about this encoding. Example: unicode value for a code in the encoding.
> If font = -1 (in PHP: 0) and the encoding option is not supplied it returns information
gathered from PDFlibs internal tables. Example: unicode value for a particular
glyphname.
Scope any
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, selector
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 (in PHP: 0)). Supported options are the map-
ping 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) 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).
encoding String index of the name of the fonts 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 op-
tion. 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
feature Check whether the font contains a specific OpenType feature table which is supported by PDFlib.
Supported options:
language (Keyword; only if script is supplied) Specifies the language name. Default: _none
name (Keyword; 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 (Keyword) Specifies the script name. Default: _none
An exception is thrown if an unknown keyword for language, name, or script is supplied; see PDFlib Tu-
torial for lists of known keywords. The following return values indicate whether the specified OpenType
feature table is present in the font and supported by PDFlib:
-1 No feature tables are available in the font.
0 The feature is not availablefor the specified specified script and language in the font, or is not
known to PDFlib.
1 The feature is available for the specified script and language.
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):
acrobat (Boolean) If true, the font name as displayed in Acrobat
api (Boolean) If true, the font name as specified in the API
full (Boolean) If true, the /FontName entry in the PDF font descriptor
fontstyle String index for the value of the fontstyle option (normal, bold, italic, or bolditalic)
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,
selector.
glyphname String index of the name of the specified glyph, or -1 if no such glyph was found in the font or in the spec-
ified encoding (if the encoding option was supplied and font=-1 (in PHP: 0)). Supported options are the
mapping options code, glyphid, glyphname, unicode plus the following:
encoding (String) Name of an 8-bit encoding
italicangle Italic angle of the font (ItalicAngle in the PDF font descriptor)
maxcode Highest code value for the fonts 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
maxuvs- Largest Unicode value which may be contained in a valid Ideographic Variation Sequence (IVS).
unicode
minuvs- Smallest Unicode value which may be contained in a valid Ideographic Variation Sequence (IVS).
unicode
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.
numusable- Number of glyphs in the font which can be reached by the encoding supplied in PDF_load_font( )
glyphs
outlineformat Font format; one of PFA, PFB, LWFN, TTF, OTF. For TTC and WOFF fonts the keyword for the underlying base
font format is returned, e.g. TTF. For CEF fonts the returned string is OTF.
predefcmap String index of the name of a predefined CMap which was specified as encoding for the font, or -1 if un-
available.
replace- Unicode value of the character specified in the replacementchar option. For symbolic fonts loaded with
mentchar encoding=builtin the code will be returned instead of the Unicode value.
selector Unicode value of the variation selector with the number specified in the index option. If the index option
is not specified or the specified selector is not available in the font, -1 is returned. Supported option:
index (Non-negative Integer) Index of a selector.
selectorlist String index of a string containing a space-separated list of the Unicode values of all variation selectors in
the font. Each value is provided in the form hhhhh where h is a hexadecimal digit.
shaping- 1 if the font supports shaping and the readshaping option was supplied when loading the font, other-
support wise 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 (in PHP: 0)). Supported options are the mapping op-
tions cid, code, glyphid, glyphname, unicode, selector 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.
unmapped- Number of glyphs in the font which are mapped to Unicode PUA values, regardless of whether the PUA
glyphs 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
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 subset-
ting to be activated), otherwise 0
Table 4.6 Text filter options for PDF_set_text_option( ), PDF_fit/info_textline( ), PDF_fill_textblock( ) and PDF_add/
create_textflow( )
option description
actualtext (Boolean; only for PDF_set_text_option( ), PDF_fit_textline( ), and PDF_fill_textblock( )) If true, PDFlib
creates a marked content Span with suitable ActualText if the Unicode value(s) derived from the ToUni-
code CMap wouldnt be correct and no user-provided Alt or ActualText was provided. This ensures cor-
rect text extraction for glyphs which are used to represent multiple similar looking Unicode values in a
font, e.g. Ohm and Omega. Default: true
charref (Boolean) If true, enable substitution of numeric and character entity references and glyph name refer-
ences in content strings.1 Default: the global charref option
escape- (Boolean) If true, enable substitution of escape sequences in content strings.1 Default: the global
sequence escapesequence option
glyphcheck (Keyword) Glyph checking policy: what happens if a code in the text cannot be mapped to a glyph in the
selected font (default: the global glyphcheck option)1:
error An exception is thrown for unavailable glyphs. A detailed error message can be retrieved with
PDF_get_errmsg( ).
none No checking. notdef glyphs trigger an exception in PDF/A, PDF/UA-1 or PDF/X-4/5 mode; oth-
erwise notdef glyphs may appear in the output.
replace Try to replace unavailable glyphs with typographically similar characters in the base and
fallback fonts and decompose ligatures. If no suitable glyph could be found, the character is
handled according to the replacementchar option.
normalize (Keyword; ignored for encoding=glyphid and non-Unicode CMaps) Normalize incoming text to one of
the Unicode normalization forms (default: none):
none Do not apply any normalization. This is the default behavior; the client is responsible for
supplying text which can be represented with glyphs from the selected font.
nfc Normalization Form C (NFC): canonical decomposition followed by canonical composition.
NFC replaces combining sequences with precomposed characters. This is useful for workflows
with combining sequences since fonts usually contain only glyphs for the precomposed
character. Without NFC normalization PDFlib emits a sequence of multiple characters instead
of the precomposed character.
nfkc Normalization Form KC (NFKC): compatibility decomposition followed by canonical composi-
tion. This is useful for workflows which are only interested in the semantics of characters, but
not in formatting differences, e.g. convert shaped Arabic characters to their base form, resolve
ligatures and fractions, replace vertical forms with horizontal forms, wide characters with
regular characters.
nfd Normalization Form D (NFD): canonical decomposition
nfkd Normalization Form KD (NFKD): compatibility decomposition
Since NFD and NFKD can create combining sequences they are unlikely to be useful in PDFlib workflows.
textformat (Keyword; only for non-Unicode compatible language bindings) Format used to interpret content strings.
Supported keywords: bytes, utf8, ebcdicutf8 (only on iSeries and zSeries), utf16, utf16le, utf16be,
and auto.1 Default: the global textformat option
1. The value may be overridden by a subsequent call to PDF_set_option( ) with the same option.
Table 4.7 Text appearance options for PDF_set_text_option( ), PDF_fit/info_textline( ), PDF_fill_textblock( ) and PDF_add/
create_textflow( )
option description
charspacing (Float or percentage) Character spacing, i.e. the shift of the current point after placing individual charac-
ters 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 nega-
tive values for vertical writing mode. Default: 0
dasharray (List of two non-negative floats or keyword) The lengths of dashes and gaps for stroked (outline) text and
decoration. The keyword none can be used to create solid lines. Default: none
decoration- (Boolean) If true, the text decoration enabled with the underline, strikeout, and overline options will
above be drawn above the text, otherwise below the text. Changing the drawing order affects visibility of the
decoration lines, i.e. you can control whether the text overprints the lines or vice versa. Default: false
fakebold (Boolean) If true, simulate bold text by stroking glyph outlines or multiple overprinting. Default: false
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 selected with PDF_setfont( ) for simple text
output and PDF_fit_textline( ) with inittextstate=false. Otherwise no font is available which will trig-
ger an error.
fontsize (Fontsize) Size of the font, measured in units of the current user coordinate system. In PDF_fit_textline( )
percentages relate to the box width (for orientate=north and south) or box height (for orientate=
east and west). In PDF_set_text_option( ) and Textflow percentages relate to the size of the preceding
text.
Default: PDF_setfont( ) sets the default only for simple text output functions and PDF_fit_textline( ) with
inittextstate=false. Otherwise no font size is available which will trigger an error.
gstate (Gstate handle) Handle for a graphics state retrieved with PDF_create_gstate( ). The graphics state af-
fects 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. Text scal-
ing shrinks or expands the text by a given percentage. Text scaling always relates to the horizontal coor-
dinate. Default: 100%
inittextstate (Boolean; only for PDF_fit_textline( )) If true all text appearance options are initialized with the default
values. If false the current text state values are used. Default: false
italicangle (Float; not supported for vertical writing mode) The italic (slant) angle of text in degrees (between -90
and 90). Negative values can be used to simulate italic text when only a plain upright font is available,
especially for CJK fonts. Default: 0
kerning (Boolean) If true, enable kerning for fonts which have been opened with the readkerning option; disable
kerning otherwise.2 Default: the global option kerning
leading (Float or percentage) Specify the leading for multi-line text, i.e. the distance between baselines of adja-
cent lines of text as absolute value in user coordinates or as a percentage of fontsize. Setting the lead-
ing equal to the font size results in dense line spacing. However, ascenders and descenders of adjacent
lines generally dont overlap (leading=0 results in overprinting lines). Default: 100%
The leading for PDF_add/create_textflow( ) is determined as follows: if there are option lists at the begin-
ning of a line, the leading is 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 are only taken into ac-
count if fixedleading=false. If there are no option lists in the line, the previous leading value is used.
overline (Boolean) If true, a line will be drawn above the text. Default: false
shadow (Option list; only for PDF_fit_textline( ), PDF_fill_textblock( ), PDF_add/create_textflow( )) Create a shad-
ow effect for the text (default: no shadow):
disable (Boolean; only for PDF_add/create_textflow( )) If true, a previously specified shadow is
disabled. Default: false
fillcolor (Color) Fill color of the shadow. Default: {gray 0.8}
gstate (Gstate handle) Graphics state created with PDF_create_gstate( ) which will be applied to the
shadow. Default: none
offset (List of 2 floats or percentages) The shadows offset from the reference point of the text in user
coordinates or as a percentage of the font size. Default: {5% -5%}
strokecolor (Color; only effective if textrendering is set to stroke text) Stroke color of the shadow.
Default: current stroke color
strokewidth (Float, percentage or keyword; only effective if textrendering is set to stroke text) Line width
for outline text in the shadow (in user coordinates or as a percentage of the font size). The
keyword auto or the equivalent value 0 uses a built-in default. Default: current stroke width if
the main text is also set to stroke text, otherwise auto
textrendering
(Integer) Text rendering mode of the shadow. Default: current value of textrendering
strikeout (Boolean) If true, a line will be drawn through the text; see also decorationabove. Default: false
strokecolor (Color; only effective for stroked text, see textrendering) Stroke color of the text. Default: see fillcolor
strokewidth (Float, percentage, or keyword; only effective if textrendering is set to stroke text) Line width for outline
text (in user coordinates or as a percentage of the fontsize). The keyword auto or the equivalent value
0 uses a built-in default. Default: auto
tagtrailing- (Unichar or keyword; only relevant for Tagged PDF) If the last character in the text (after possibly apply-
hyphen ing glyph replacements) is equal to the specified Unicode value, it will be tagged as Span with Actual-
Text soft hyphen U+00AD if required by the font, and no autospace will be added. The keyword none re-
sults in no tagging for soft hyphens. Default: U+00AD
textrendering (Integer) Text rendering mode. Only textrendering=3 has an effect on Type 3 fonts (default: 0):
0
P fill text 4 fill text and add it to the clipping path
1 stroke text (outline) 5 stroke text and add it to the clipping path
2
P fill and stroke text 6 fill and stroke text and add it to the clipping path
underline (Boolean) If true, a line will be drawn below the text. Default: false
underline- (Float, percentage, or keyword) Position of the stroked line for underlined text relative to the baseline
position (absolute values or relative to the fontsize; a typical value is -10%). The keyword auto specifies a font-spe-
cific value which will be retrieved from the font metrics or outline file. Default: auto
underline- (Float, percentage, or keyword) Line width for underlined text (absolute value or percentage of the font-
width size). The keyword auto or the value 0 uses a font-specific value from the font metrics or outline file if
available, otherwise 5%. Default: 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. Default: 0
1. The value may be overridden by a subsequent call to PDF_setcolor( ) for simple text output functions and PDF_fit_textline( ) with
inittextstate=false.
2. The value may be overridden by a subsequent call to PDF_set_option( ) with the same option.
Set one or more text filter or text appearance options for simple text output functions.
Details The values of text options are relevant for all simple text output functions and PDF_fit_
textline( ) with inittextstate=false. Calls to PDF_set_text_option( ) should not be mixed
with calls to PDF_setfont( ) and PDF_setcolor( ).
All text options are reset to their default values at the beginning of a page, pattern,
template, or glyph description, and retain their values until the end of the current page,
pattern, template, or glyph scope. However, the text options can also be reset with the
inittextstate option.
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 and font size to be used by simple text output functions (e.g.
PDF_show( )) and PDF_fit_textline( ). It is almost equivalent to a call to PDF_set_text_
option( ) with the option list font=<font> fontsize=<fontsize>. However, unlike PDF_set_
text_option( ) this function additionally sets the leading text option to fontsize.
The font must be set on each page before calling any of the simple text output func-
tions. Font settings are not retained across pages.
The use of PDF_set_text_option( ) is recommended over PDF_setfont( ). Calls to PDF_
setfont( ) should not be mixed with calls to PDF_set_text_option( ).
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 sepa-
rately.
Print text in the current font and size at the current text position.
text (Content string) The text to be printed. In C text must not contain null bytes when
using PDF_show( ), since it is assumed to be null-terminated; use PDF_show2( ) for strings
which may contain null characters.
len (Only for PDF_show2( )) Length of text (in bytes). If len = 0 a null-terminated string
must be provided.
Details The font and font size must have been set before with PDF_setfont( ) or PDF_set_text_
option( ). The current text position is moved to the end of the printed text. The char-
spacing parameter is taken into account after the last glyph.
Bindings PDF_show2( ) is only available in C since in all other bindings arbitrary string contents
can be supplied with PDF_show( ).
text (Content string) The text to be printed. In C text must not contain null bytes when
using PDF_show_xy( ), since it is assumed to be null-terminated; use PDF_show_xy2( ) for
strings which may contain null characters.
x, y The position in the user coordinate system where the text will be printed.
len (Only for PDF_show_xy2( )) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
Details The font and font size must have been set before with PDF_setfont( ) or PDF_set_text_
option( ). The current text position is moved to the end of the printed text. The char-
spacing parameter is taken into account after the last glyph.
Bindings PDF_show_xy2( ) is only available in C since in all other bindings arbitrary string con-
tents can be supplied with PDF_show_xy( ).
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. In C text must not contain null bytes when using
PDF_continue_text( ), since it is assumed to be null-terminated; use PDF_continue_text2( )
for strings which may contain null bytes.
len (Only for PDF_continue_text2( )) Length of text (in bytes). If len = 0 a null-terminat-
ed string must be provided as in PDF_continue_text( ).
Details The positioning of text (x and y position) and the spacing between lines is determined
by the leading text option (which can be set with PDF_set_text_option( )) and the most re-
cent call to PDF_show_xy( ) or PDF_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.
Bindings PDF_continue_text2( ) is only available in C since in all other bindings arbitrary string
contents can be supplied with PDF_continue_text( ).
text (Content string) The text for which the width will be queried. In C text must not
contain null bytes when using PDF_stringwidth( ), since it is assumed to be null-termi-
nated; use PDF_stringwidth2( ) for strings which may contain null bytes.
len (Only for PDF_stringwidth2( )) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
fontsize Size of the font, measured in units of the user coordinate system.
Returns The width of text in a font which has been selected with PDF_load_font( ) and the sup-
plied 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 re-
turned (use PDF_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 PDF_info_textline( )).
Details The width calculation takes into account the values of the following text options (which
can be set with PDF_set_text_option( )): horizscaling, kerning, charspacing, and wordspacing.
Bindings PDF_stringwidth2( ) is only available in C since in all other bindings arbitrary string con-
tents can be supplied with PDF_stringwidth( ).
fontname (Name string) The name under which the font will be registered, and can
later be used with PDF_load_font( ).
a, b, c, d, e, f (Will be ignored in the second pass of the font definition for Type 3 font
subsets) 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) Option list according to Table 4.8.
The following options can be used: colorized, defaultcmyk, defaultgray, defaultrgb,
familyname, stretch, weight, widthsonly
Details The font may contain an arbitrary number of glyphs. The font can be used until the end
of the current document scope.
Scope any except object; this function starts font scope, and must always be paired with a
matching PDF_end_font( ) call. For the second pass of subsetted fonts only document
scope is allowed.
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
defaultgray (ICC handle or keyword; only reasonable for colorized=true; not for PDF/X-1a) Set a default gray, RGB,
defaultrgb or CMYK color space for the glyph descriptions in the font according to the supplied ICC profile handle.
defaultcmyk The option defaultrgb also supports the keyword srgb.
stretch1 (Keyword; PDF 1.5) Font stretch value: ultracondensed, extracondensed, condensed, semicondensed,
normal, semiexpanded, expanded, extraexpanded, ultraexpanded. Default: normal
weight1 (Integer or keyword; PDF 1.5) Font weight: 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 de-
fined. No other API functions should be called between PDF_begin_glyph_ext( ) and PDF_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.
Scope font; this function terminates font scope, and must always be paired with a matching
PDF_begin_font( ) call.
uv Unicode value for the glyph. Each Unicode value can be supplied only for one glyph
description. The glyph with the Unicode value 0 always gets glyph ID 0 and glyph name
.notdef, regardless of whether or not the glyph was specified.
If uv=-1 the Unicode value is derived from the glyphname option according to PDFlibs
internal glyph name list. If a glyph name is unknown, consecutive PUA values (starting
at U+E000) will be assigned. This value can be queried with PDF_info_font( ).
optlist Option list according to Table 4.9. The following options can be used:
boundingbox, code, glyphname, width
Details The glyphs in a font can be defined using text, graphics, and image functions. Images,
however, can only be used if the fonts colorized option is true, or if the image has been
opened with the mask option. This function resets all text, graphics, and color state pa-
rameters to their default values.
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. line-
width).
Scope font; this function starts glyph scope, and must always be paired with a matching PDF_
end_glyph( ) call. If widthsonly=true in PDF_begin_font( ) all API function calls between
PDF_begin_glyph_ext( ) and PDF_end_glyph( ) will be ignored.
bounding- (List of 4 floats; will be ignored in the second pass of the font definition for Type 3 font subsets and if the
box fonts colorized option is true) If the fonts colorized option is false (which is default), the coordi-
nates of the lower left and upper right corners of the glyphs bounding box. The bounding box values
must be correct in order to avoid problems with PostScript printing. Default: {0 0 0 0}
code (Integer) Specify the glyphs slot number, i.e. its byte code in the Type 3 fonts builtin encoding. By default
the glyphs are numbered sequentially (starting with 0) in the order of creation.
glyphname (String) Name of the glyph. The name for glyph 0 with Unicode 0 is forced to .notdef. Default: G<i> for
glyph <i>=1,2,3,...
width (Float; required; will be ignored in the second pass of the font definition for Type 3 font subsets) Width of
the glyph in the glyph coordinate system as specified by the fonts matrix.
Scope glyph; this function changes from glyph scope to font scope, and must always be paired
with a matching PDF_begin_glyph_ext( ) call.
C++ Java C# void encoding_set_char(String encoding, int slot, String glyphname, int uv)
Perl PHP encoding_set_char(string encoding, int slot, string glyphname, int uv)
C void PDF_encoding_set_char(PDF *p, const char *encoding, int slot, const char *glyphname, int uv)
encoding The name of the encoding. This is the name which must be used with PDF_
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.
Details This function is only required for specialized applications which must work with non-
standard 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.
Scope any
len (C language binding only) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
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 123,
for a description of the fitting algorithm.
optlist An option list specifying font, text, and formatting options. The following op-
tions are supported:
> General option: errorpolicy (see Table 2.1)
> Font loading options according to Table 4.2 for implicit font loading (i.e. font option
in the text appearance group not supplied):
ascender, autosubsetting, capheight, descender, embedding, encoding, fallbackfonts,
fontname, fontstyle, keepnative, linegap, metadata, monospace, readfeatures, replace-
mentchar, subsetlimit, subsetminsize, subsetting, unicodemap, vertical, xheight
> Text filter options according to Table 4.6:
actualtext, charref, escapesequence, glyphcheck, normalize, textformat
> Text appearance options according to Table 4.7:
charspacing, dasharray, decorationabove, fakebold, fillcolor, font, fontsize, gstate,
horizscaling, inittextstate, italicangle, kerning, leading, overline, shadow, strikeout,
strokecolor, strokewidth, textrendering, textrise, underline, underlineposition, underline-
width, wordspacing
> Options for Textline formatting according to Table 5.1:
justifymethod, leader, textpath, xadvancelist
> Shaping and typographic options according to Table 5.4:
features, language, script, shaping
> Fitting options according to Table 6.1:
alignchar, blind, boxsize, fitmethod, margin, matchbox, orientate, position, rotate, stamp,
showborder, shrinklimit
> Option for abbreviated structure element tagging according to Table 14.5 (only al-
lowed in page scope): tag
justifymethod (List of keywords; only relevant for fitmethod=auto and stamp=none; requires boxsize; ignored in verti-
cal writing mode) Ensure that the text will not extend beyond the fitbox by applying one or more for-
matting methods without changing the fontsize. One or more of the following keywords can be sup-
plied; if multiple keywords are present justification will be applied in the following order of decreasing
priority: wordspacing, charspacing, horizscaling (default: none):
charspacing Justify with an appropriate charspacing value.
horizscaling Justify with an appropriate horizscaling value.
none No justification
wordspacing
Justify with an appropriate wordspacing value. If the text does not contain any space
characters wordspacing justification will not be applied.
leader (Option list; 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.3 for a list of supported suboptions. Default: no leader
textpath (Option list) Draw text along a path. Text beyond the end of the path will not be displayed. If
showborder=true the flattened path will be drawn with the current linewidth and stroke color. The op-
tions listed in Table 5.2 plus the following options of PDF_draw_path( ) are supported:
align, attachmentpoint, boxsize, fitmethod, orientate, scale (see Table 6.1)
close, round, subpaths (see Table 7.6)
bboxexpand, boundingbox (see Table 7.6)
The following options of PDF_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 are 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; ignored if shaping=true) Advance width of the glyphs in the text in user coordinates. The
length of the list must be less than or equal to 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.
path (Path handle; required) 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 on the other side of the path and the top of the text will
touch the path. The parameters x and y of PDF_fit_textline( ) are used as reference point for the path.
startoffset (Float or percentage) Offset of the starting point of the text along the path in user coordinates or as per-
centage 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%
Perform Textline formatting without creating output and query the resulting metrics.
len (C language binding only) The length of text in bytes, or 0 for null-terminated
strings.
optlist An option list specifying options for PDF_fit_textline( ). Options which are not
relevant for the requested keyword are silently ignored.
font loading If the font is specified implicitly (i.e. via the fontname and encoding options, as opposed to the font op-
options tion), all font loading options according to Table 4.2 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 lead-
er 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 val-
ue or as one of the keywords fontsize, ascender, xheight, baseline, descender, textrise. Default:
baseline
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 returns 0 in case of an error. If errorpolicy= exception
this function throws an exception in case of an error (even for the keyword wellformed).
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 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 lan-
guage, 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 Tuto-
rial. The keyword _auto selects the script to which the majority of characters in the text belong, where
latn and _none are ignored. _auto is only relevant for shaping and will be ignored for features and
advancedlinebreak. Default: _none
shaping (Boolean) If true, complex script shaping and bidirectional reordering will be applied to the text accord-
ing 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
endx, endy x/y coordinates of the logical text end position in user coordinates
pathlength (Only for text on a path) Length of the path covered by the text from its starting point to the end
point. This value can be queried even if PDF_fit_textline( ) was called in blind mode. The value
can be used for the startoffset option of PDF_fit_textline( ) to continue labeling a path with
additional text.
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
couldnt 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 mark-
ers which may be present in the text (e.g. U+202D or &LRO; LEFT-TO-RIGHT OVERRIDE).
scriptlist String containing the space-separated list of the names of all scripts in the text. This may be use-
ful 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
textwidth, Width and height of the text. The height is subject to the matchbox definition of boxheight,
textheight which defaults to {capheight none}.
unknownchars If glyphcheck=none: number of skipped characters. The number includes character references
which couldnt be resolved, and characters which couldnt be mapped to a code in the current en-
coding or to a glyph in the font.
If glyphcheck=replace: number of characters which were replaced with the specified replace-
ment character (option replacementchar). The number includes characters which couldnt 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 well-formed according to the selected font/encoding (and textformat, if applica-
ble), otherwise 0.
writingdirx x/y coordinates of the dominant writing direction (i.e. the direction of inline text progression)
writingdiry which describes a unit vector from (startx, starty) to (endx, endy). For left-to-right horizon-
tal 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.
Create a Textflow object, or add text and explicit options to an existing Textflow.
text (Content string) The contents of the Textflow. The text may not contain any in-
line options.
len (C language binding only) The length of text in bytes, or 0 for null-terminated
strings.
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 PDF_delete_textflow( ) is
called with this handle.
If the textflow parameter is -1 (in PHP: 0), a new Textflow will be created and its han-
dle will be returned. Otherwise the handle supplied in the textflow parameter will be re-
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, con-
verts 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 PDF_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 Text-
flow in separate calls. It will add the supplied text and optlist to a new or existing Text-
flow. Options specified in optlist will be evaluated before processing text. Both text and
optlist may be empty.
If textflow=-1 (in PHP: 0) this function is almost equivalent to PDF_create_textflow( ).
However, unlike PDF_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
and UTF-16 text).
This function preprocesses the supplied text and options, but does not create any
output in the generated PDF document, but only prepares the text. Use PDF_fit_
textflow( ), PDF_fit_table( ), or PDF_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 PDF_fit_textflow( ) returns the string _nextpage).
A horizontal tab character (HT) sets a new start position for subsequent text. The de-
tails 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.
Table 5.6 Additional formatting options for PDF_add/create_textflow( ) and inline options in PDF_create_textflow( )
option description
avoid- (Boolean) If true, empty lines at the beginning of a fitbox will be deleted. Default: false
emptybegin
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 PDF_fit_
textflow( ) or the createwrapbox suboption of the matchbox option will be used to wrap the text around
shapes. Default: false
hortabmethod (Keyword) Treatment of horizontal tabs in the text. If the calculated position is to the left of the current
text position, the tab is 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 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.
hortabsize (Float or percentage) Width of a horizontal tab1. The interpretation depends on the hortabmethod op-
tion. Default: 7.5%
lastalignment (Keyword) Formatting for the last line in a paragraph. All keywords of the alignment option are sup-
ported, plus the following (default: auto):
auto Use the value of the alignment option if it is different from justify, else left
leader (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.3 for a list of supported suboptions. Default: no leader
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 is added to leftindent.
Specifying this option within a line will act like a tab. Default: 0
ruler (List of floats or percentages) List of absolute tab positions for hortabmethod=ruler1. The list may con-
tain 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. The list may contain up to
32 entries. if more than 32 horizontal tabs per line occur in the text the list will be extended with the last
value. Each entry in the list defines the alignment for the corresponding entry in the ruler option. De-
fault: 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 tabalign-
char 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.
adjustmethod (Keyword) Method used to adjust a line when a text portion doesnt fit into a line after compressing or
expanding the distance between words subject to the limits specified by the minspacing and max-
spacing 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 doesnt fit in the line the text will be compressed subject to shrinklimit. If it still
doesnt 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.
advanced- (Boolean) Enable advanced line breaking algorithm which is required for complex scripts. This is re-
linebreak quired for line-breaking 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 line-breaking 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 op-
tion.
> 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: tha, de_DE, en_US, en_GB
maxspacing (Float or percentage; only relevant if the line contains at least one space character U+0020 and
minspacing alignment=justify) Maximum or minimum distance between words (in user coordinates, or as a per-
centage of the width of the space character). The calculated word spacing is limited by the provided val-
ues (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 fac-
tor 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 method1; the cal-
culated distance will be added to the value of the charspacing option. Default: 0
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 PDF_info_textflow( ) and the lastmark keyword. This may be useful for de-
termining which portions of text have already been placed on the page.
matchbox (Option list) Option list for creating a matchbox according to Table 6.4
nextline (Boolean) Force a new line; equivalent to one of the characters U+000B or U+2028. The options
alignment=justify and lastalignment dont have any effect on the line containing the nextline op-
tion.
nextparagraph (Boolean) Force a new paragraph; equivalent to one of the characters U+000A, U+000D, U+000D plus
U+000A, U+0085, U+2029 and U+00FF. The alignment of the line containing the nextparagraph op-
tion is determined by the option lastalignment; the option alignment is ignored.
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 first
change of any font-related options which differ from the first setting, and will be ignored otherwise.
restore (Boolean) If true, the values of all text and Textflow options saved by the most recent save command
will be restored. A matchbox created within a save/restore pair will be retained after restore. Default:
false
return (String; must not start with an underscore _ character) Exit PDF_fit_textflow( ) with the supplied string
as return value. A new line will automatically be created.
save (Boolean) If true, the values of all text and Textflow options will be saved, except those of the non-state
options nextline, nextparagraph, resetfont, return, space, and textlen. Save/restore pairs can be
nested to an arbitrary depth. Default: false
space (Float or percentage) The text position will be advanced horizontally by the specified value1.
Table 5.9 Additional text semantics options for PDF_add/create_textflow( ) and inline options in PDF_create_textflow( )
option description
charclass (List of pairs, where the first element in each pair is a keyword, and the second element is either a Uni-
char or a list of Unichars; the Unichars must be < 0xFFFF; will be ignored if advancedlinebreak=true)
The specified Unichars will be classified by the specified keyword to determine the line breaking behav-
ior 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 PDFlibs builtin defaults
Example: charclass={ close open letter {/ : =} punct & }
charmapping (List of pairs, where each pair either contains two Unichars or a Unichar and a list of Unichar and inte-
ger; the Unichars must be < 0xFFFF) 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 CR space }
charmapping={ shy {shy 0} }
charmapping={ hortab {space 4} }
hyphenchar (Unichar < 0xFFFF 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 < 0xFFFF) Character at which decimal tabs will be aligned. Default: U+002E .
Macros for Textflow options. Option lists for Textflows (either in the optlist parameter
of PDF_create_textflow( ) or PDF_add_textflow( ), or inline in the text supplied to PDF_
create_textflow( )) may contain macro definitions and macro calls according to Table
5.10. Macros may be useful for having a central definition of multiply used option val-
ues, 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 fol-
lowing 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 }
}>
macro (List of pairs) Each pair describes the name and definition of a macro as follows (note that there must not
be any equals character = between the macro name and its definition):
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 macros contents, i.e. the suboptlist which has been defined for the macro (with-
out 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.
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 en-
codings, macros (see Macros for Textflow options, page 100), and inline option lists
according to Table 5.6 and Table 5.11 (see also Inline option lists for Textflows, page
102). If text is an empty string, a valid Textflow handle will be returned nevertheless.
len (C language binding only) The length of text in bytes, or 0 for null-terminated
strings.
optlist An option list specifying Textflow options. Options specified in the optlist pa-
rameter 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 Table 2.1)
> All options of PDF_add_textflow( ) (see option list of PDF_add_textflow( ))
> Options for controlling inline option list processing according to Table 5.11:
begoptlistchar, endoptlistchar, fixedtextformat, textlen
Details This function accepts options and text to be prepared for Textflow. Unlike PDF_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 parame-
ter (see Inline option lists for Textflows, page 102).
Table 5.11 Additional options for inline option list processing in PDF_create_textflow( )
option description
begoptlistchar (Unichar < 0xFFFF 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
102). If textlen is not specified, the begoptlistchar character in the text must be encoded in the same
text format and encoding as the preceding text. This means that the Unicode value of begoptlistchar
must be chosen such that it is contained in the encoding of the preceding text. The keyword none can be
used to completely disable the search for option lists. Default: U+003C (<)
endoptlistchar (Unichar < 0xFFFF; U+007D } is not allowed) Character which terminates inline option lists. Default:
U+003E (>)
fixedtext- (Boolean; only relevant for non-Unicode-capable language bindings and forced to true if
format stringformat=utf8; this option doesnt make sense in inline option lists, and can only be used in the
optlist parameter) If true, all text fragments and inline options lists will use the same textformat,
which must be one of utf8, utf16, utf16be, or utf16le. This is useful if text and inline options come
from the same source.
If false, inline option lists including the delimiters must be encoded in textformat=bytes, regardless of
the format used for the actual text. This allows the combination e.g. of UTF-16 text with ASCII-encoded
inline option lists (the text may come from a Unicode database, while inline options are constructed as
ASCII text within the application). Default: false
textlen (Integer or keyword; required for text fragments with fixedtextformat=false and textformat=
utf16xx in non-Unicode aware languages) Number of bytes or (in Unicode-capable languages) charac-
ters before the next inline option list (see Inline option lists for Textflows, page 102). The characters
are counted before character references are resolved, e.g. <textlen=8>①<...>. 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 PDF_
create_textflow( ) (but not PDF_add_textflow( )) may include an arbitrary number of op-
tion lists (inline options) specifying Textflow options according to Table 5.6. All of these
options can alternatively be provided in the optlist parameter of PDF_create_textflow( )
and PDF_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 begoptlist-
char 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 PDF_add_textflow( ) completely sepa-
rates text and options, so the conflict doesnt 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 PDF_create_textflow( ).
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 fol-
lowing methods:
> Replace all occurrences of the < character in the text with the corresponding numeric
or character entity reference (< or <) and start inline option lists with the lit-
eral < character:
A<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 PDF_create_textflow( ) or an
inline option list to a character which is not used in the text (e.g. $), and use this char-
acter 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>
> Specify the begoptlistchar as an escape sequence and set the escapesequence global op-
tion to true. However, escape sequences dont work within inline option lists includ-
ing the endoptlistchar.
Note Consecutive inline option lists without any text between them should be avoided; it is recom-
mended to aggregate all options in a single option list. If an inline option list is provided imme-
diately 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.
C++ Java C# String fit_textflow(int textflow, double llx, double lly, double urx, double ury, String optlist)
Perl PHP string fit_textflow(int textflow, float llx, float lly, float urx, float ury, string optlist)
C const char *PDF_fit_textflow(PDF *p,
int textflow, double llx, double lly, double urx, double ury, const char *optlist)
llx, lly, urx, ury x and y coordinates of the lower left and upper right corners of the tar-
get 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.
optlist An option list specifying processing options. The following options can be
used:
> Textflow options according to Table 5.12:
avoidwordsplitting, blind, createfittext, createlastindent, exchangefillcolors, exchange-
strokecolors, firstlinedist, fitmethod, fontscale, lastlinedist1, linespreadlimit, maxlines,
minfontsize, orientate, returnatmark, rewind, rotate, showborder, showtabs, stamp,
truncatetrailingwhitespace, 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 al-
ways 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). An-
other call to PDF_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 didnt fit
into the fitbox. Another call to PDF_fit_textflow( ) is required for processing the re-
maining text.
> _boxempty: The box doesnt 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 PDF_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 PDF_fit_textline( )). Use fillcolor, strokecolor and other text
appearance options (see Table 4.7) in PDF_create_textflow( ) or PDF_add_textflow( ) to con-
trol the appearance of the text. After returning from this function the text state is un-
changed. However, the textx/texty options are adjusted to point to the end of the gener-
ated text output (unless the blind option has been set to true).
avoidword- (Boolean) If true and fitmethod=auto, Textflow attempts to fit the text completely into the fitbox by de-
splitting creasing the fontsize and avoiding word splitting (see adjustmethod).
blind (Boolean) If true, no output will be generated, but all calculations will be performed and the formatting
results can be checked with PDF_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 re-
trieved with a call to PDF_info_textflow( ) and the keyword fittext. Default: true
createlast- (Option list) Reserve some space at the end of the last line in the fitbox and optionally create a matchbox
indent 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 coordi-
nates or as percentage of the width of the fitbox. The value will be added to the value of the
rightindent option of PDF_add/create_textflow( ) . Default: 0
matchbox (Option list according to Table 6.4) 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.
exchange- (List with an even number of colors) Each pair in the list specifies an original fill color and a replacement
fillcolors 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. The character *
as original color means that all remaining colors will be replaced with the replacement color. Example:
exchangefillcolors={{gray 0} white Orchid DeepPink {rgb 1 0 1} MediumBlue}
exchange- (List with an even number of colors) Each pair in the list specifies an original stroke color and a replace-
strokecolors ment 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. The char-
acter * as original color means that all remaining colors will be replaced with the replacement color.
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 PDF_fit_textflow( ) will repeatedly be called in blind mode with reduced font size and other
font-related 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 (for verticalalign=top), the top of the
fitbox (for verticalalign=bottom), or the bottom and the top of the fitbox (for
verticalalign=center).
fontscale (Positive 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 PDF_fit_
textflow( ).
gstate (Gstate handle) Handle for a graphics state retrieved with PDF_create_gstate( ). The graphics state af-
fects all text placed with this function. If another graphics state has already been supplied to PDF_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 percent-
age 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 is used.
linespread- (Float or percentage; only for verticalalign=justify) Maximum amount in user coordinates or as per-
limit centage 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
PDF_fit_textflow( ) will return the string _boxfull. Default: auto
minfontsize (Float or percentage) Minimum font size allowed when text is scaled down to fit into the fitbox, especial-
ly for fitmethod=auto. The limit is specified in user coordinates or as a percentage of the height of the fit-
box. 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 con-
tours) 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) PDF_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 PDF_fit_
textflow( ) with the same Textflow handle (default: 0):
1 Rewind to the state before the first call to PDF_fit_textflow( ).
0 Dont reset the Textflow.
-1 Rewind to the state before the last call to PDF_fit_textflow( ).
-2 Rewind to the state before the second last call to PDF_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 is stroked (using the current graphics state).
This may be useful for development and debugging. Default: false
showtabs (Keyword) Tab stops and left indents are visualized with vertical lines as a debugging aid. The lines will be
drawn according to the graphics state which was active before calling PDF_fit_textflow( ) (default:
none):
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
stamp (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.
truncate- (Boolean) Control treatment of fitboxes which contain only trailing whitespace, i.e. the text in the fitbox
trailing- starts with whitespace and there is only whitespace until the end of the Textflow. If this option is true,
whitespace trailing whitespace is removed, i.e. the fitbox is treated as empty and the return value is _stop. If this op-
tion is false, the whitespace is processed like regular text, i.e. the function may return a value different
from _stop (depending on the amount of trailing whitespace) and the textendx/y and other keywords
of PDF_info_textflow( ) take the whitespace into account. truncatetrailingwhitespace=false may be
useful if the original text must be processed without any whitespace removal. Default: true
verticalalign1 (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 doesnt fill the
fitbox there may be whitespace below the text.
center The text will be vertically centered in the fitbox. If the text doesnt 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 doesnt 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.
wrap (Option list according to Table 5.13) The text will run around the areas specified with the suboptions listed
in Table 5.13. 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 coor-
dinate will be added to the previous absolute coordinate. Up to 256 values can be supplied as relative val-
ues. 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 sup-
plied 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 dont touch the fitbox.
This effect can almost completely be avoided by supplying wrap elements which touch the fitbox.
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 Bzier curves) Bzier 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.
creatematch- (List of option lists) Create matchboxes from one or more rectangles in the boxes option. Each option list
boxes corresponds to one entry in the boxes option (ordering is relevant), and controls the creation of a match-
box. All relevant matchbox options in Table 6.4 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: even-
odd). See Table 7.1 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}
usematch- (List of string lists) The first element in each list is a name string which specifies a matchbox. The second
boxes element is either an integer specifying the number of the desired rectangle, or the keyword all to speci-
fy 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 subop-
tions:
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 PDF_draw_path( ) can also be used (see Table 6.1 and Table 7.6):
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.
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 options). If the
requested keyword produces text, a string index is returned, and the corresponding
string must be retrieved with PDF_get_string( ).
boundingbox Handle of the path containing the Textflows bounding box in user coordinates or -1 (0 in PHP).
firstlinedist and lastlinedist will be taken into account.
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 the text placed in the previous call to PDF_fit_textflow( ). This can be used to de-
termine 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 Value of fontscale after the most recent call to PDF_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)
leading The current value of the leading option, as determined by the text and options within the Text-
flow
leftlinex1, The x and y coordinates of the line with the leftmost start in the most recently filled fitbox, in cur-
leftliney1 rent user coordinates
maxlinelength Length of the longest text line in the most recently filled fitbox
1
maxliney The y coordinate of the baseline of the longest text line in the most recently filled fitbox, in cur-
rent user coordinates
minlinelength Length of the shortest text line in the most recently filled fitbox
1
minliney The y coordinate of the baseline of the shortest text line in the most recently filled fitbox, in cur-
rent user coordinates
returnreason String index for the return reason of the most recent direct or indirect call to PDF_fit_textflow( ).
The retrieved return reason will be one of the return strings of PDF_fit_textflow( ). This is useful
for querying the result of indirect Textflow calls issued internally by PDF_fill_textblock( ).
rightlinex1, The x and y coordinates of the line with the rightmost end in the most recently filled fitbox, in
rightliney1 current user coordinates
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 ac-
count) in current user coordinates
textwidth Width of the bounding box of the whole text in current user coordinates
x1, y1, ... , x4, y4 Coordinates of the bounding box of the whole text in current user coordinates. firstlinedist
and lastlinedist will be taken into account.
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 PDF_delete_
textflow( ) may significantly slow down the application if many Textflows are generat-
ed.
Scope any
C++ Java C# int add_table_cell(int table, int column, int row, string text, string optlist)
Perl PHP int add_table_cell(int table, int column, int row, string text, string optlist)
C int PDF_add_table_cell(PDF *p,
int table, int column, int row, const char *text, int len, const char *optlist)
table A valid table handle retrieved with another call to PDF_add_table_cell( ), or -1 (in
PHP: 0) to start a new table. The table handle must not yet have been used in a call to
PDF_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 mul-
tiple 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 fill-
ing the cell with PDF_fit_textline( ).
len (C language binding only) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
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 (in PHP: 0) 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, graphics, 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.
PDF/UA Vector graphics and raster images supplied with the path or image options must be
tagged as Artifact or Figure with the tag option.
avoidword- (Boolean; only relevant for Textflow cells) If true, the table formatter will check whether the Textflow re-
splitting quires 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
colscale- (String) Name of a column group to which the column will be added. All columns in a group will be scaled
group1 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.
continue- (Boolean; only relevant for Textflows) If true the contents of the Textflow specified in the textflow op-
textflow tion 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 avoidwordsplitting
option will be ignored. Therefore, a suitable cell size should be defined.
If false the Textflow will be started from the beginning. Default: false
margin (Float or percentage) Left/bottom/right/top cell margins in user coordinates (must be greater than or
marginleft equal to 0) or as a percentage of the cell width or height (must be less than 100%). The specified margins
marginbottom define the inner cell box which serves as the fitbox for the cell contents. Default for margin: 0; Default for
marginright all others: margin
margintop
minrow- (Float or percentage) If a row cannot completely be placed in a table instance, this option specifies
height1 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
repeatcontent (Boolean) Specify whether the contents of a table cell will be repeated if a cell or row is split between sev-
eral table instances. Default: true
Splitting a cell: If the last rows spanned by a cell dont 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 doesnt fit into the fitbox, it will usually not be split but will com-
pletely 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.
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 tables first fitbox (see PDF_fit_table( )). User coordi-
nates 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, graphics and PDF pages in table cells dont have any influence on row
heights. Default: see option rowheightdefault of PDF_fit_table( )
rowscale- (String) Name of a row group to which the row will be added. All rows in a group will be scaled uniformly
group1 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.
rowjoin- (String) Name of a row group to which the row will be added. All rows in the group will be kept together
group1 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.
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 PDF_fit_table( ) is called for placing the first table instance.
Table 5.16 Options for static cell contents in PDF_add_table_cell( ) and suboptions for the caption option of PDF_fit_
table( )
option description
fitgraphics (Option list; only relevant for graphics) Option list for PDF_fit_graphics( ). This option list will be applied
to place the graphics supplied with the graphics option in the cell. The lower left corner of the fitbox will
be used as reference point.
Default: fitmethod=meet position=center. This option list is prepended to the user-specified options.1
fitimage (Option list; only relevant for images and templates) Option list for PDF_fit_image( ). This option list will
be applied to place the image or template supplied with the image option in the cell. The lower left corner
of the fitbox will be used as the reference point.
Default: fitmethod=meet position=center. This option list is prepended to the user-specified options.1
fitpath (Option list; only relevant for path objects) Option list for PDF_draw_path( ). This option list will be ap-
plied to place the path object specified with the path option within its bounding box in the cell. The low-
er left corner of the fitbox will be used as reference point.
Default: fitmethod=meet position=center. This option list is prepended to the user-specified options.1
fitpdipage (Option list; only relevant for PDI pages; only if PDI is available) Option list for PDF_fit_pdi_page( ). This
option list will applied to place the page supplied with the pdipage option in the cell. The lower left cor-
ner of the fitbox will be used as the reference point.
Default: fitmethod=meet position=center. This option list is prepended to the user-specified options.1
fittextflow (Option list; only relevant for Textflows) Option list for PDF_fit_textflow( ). This option list will be applied
to place the Textflow supplied in the textflow option in the cell. The fitbox 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 PDF_fit_textline( ). This option list will be applied
to fit the text supplied with the text parameter into the cell. The lower left corner of the fitbox 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: fitmethod=nofit position=center. This option list is prepended to the user-specified options.1
graphics (Graphics handle) The graphics associated with the handle will be placed in the fitbox.
image (Image handle) The image or template associated with the handle will be placed in the fitbox.
matchbox (Option list) Option list with matchbox details according to Table 6.4.
path (Path handle) The path object within its bounding box will be placed in the fitbox according to the
fitpath option.
pdipage (Page handle) The imported PDF page associated with the handle will be placed in the fitbox.
text (Content string) Text to be placed with PDF_fit_textline( ) according to the option fittextline. In PDF_
add_table_cell( ) the value of this option can alternatively be provided via the function parameter text.
textflow (Textflow handle) The Textflow associated with the handle will be placed in the fitbox. The
continuetextflow option controls the behavior for a Textflow handle which is used in multiple cells. The
Textflow handle must not be used outside the table.
1. The box size is calculated automatically; any boxsize option in the supplied option list will be ignored.
Table 5.17 Options for interactive cell contents for PDF_add_table_cell( ) and suboptions for the caption option (only in
page scope)
option description
annotation- (String) Specifies the type of an annotation to be inserted in the table cell according to Table 12.2.
type
fieldtype (String) Specifies the type of a form field to be inserted in the table cell according to Table 12.4. Form field
groups should be defined outside of tables.
fitannotation (Option list) Annotation options for annotationtype according to Table 12.3.
fitfield (Option list) Form field options for fieldtype according to Table 12.5.
C++ Java C# String fit_table(int table, double llx, double lly, double urx, double ury, String optlist)
Perl PHP string fit_table(int table, float llx, float lly, float urx, float ury, string optlist)
C const char *PDF_fit_table(PDF *p,
int table, double llx, double lly, double urx, double ury, const char *optlist)
llx, lly, urx, ury Coordinates of the lower left and upper right corners of the target rect-
angle for the table instance (the fitbox) in user coordinates. The corners can also be
specified in reverse order.
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 ta-
bles fitbox; another call to PDF_fit_table( ) is required for processing the remaining
rows.
> _error: an error occurred; call PDF_get_errmsg( ) to obtain details about the problem
and set debugshow=true to visualize the problem.
> Any other string: the string supplied to the return option in a call to PDF_add_table_
cell( ).
Details Place the table on the page. The table cells must have been filled with prior calls to PDF_
add_table_cell( ). If the full table doesnt fit in the fitbox, the first table instance will be
placed; more table instances can be placed with subsequent calls to this function de-
pending 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.
> Matchbox filling: areas which are defined by a matchbox definition.
> Contents: the specified cell contents will be placed in the following order: image,
graphics, imported PDF page, graphics, path objects, Textflow, Textline, annotations,
form fields.
> Matchbox ruling: 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 ver-
tical 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 match-
box 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, graphics etc. outside of the table functions.
Automatic table tagging: the tag option can be used to trigger automatic table tagging
(see PDFlib Tutorial).
PDF/UA If automatic table tagging is active the table decoration (ruling and shading) is automat-
ically tagged as Artifact.
blind (Boolean) If true, all calculations will be performed, but no output will be created. The formatting results
can be checked with PDF_info_table( ). Default: false
caption (Option list) Create a fit box for a caption relative to the calculated fit box and fill it with various content
types. The following option can be supplied (default: no caption):
fitbox (List of four floats or percentages with absolute or relative coordinates; required) Coordinates
of two diagonal box corners in user coordinates. If a value is a percentage or a relative value it
indicates the offset from the corresponding corner {llx lly urx ury} of the table instance.
Percentages corresponding to llx or urx are percentages of the table instance width,
percentages corresponding to lly or ury are percentages of the table instance height. The
fitbox is not automatically adjusted to the size of its contents. The specified matchbox will
describe the fitbox; this can be used to draw the caption fitbox or to retrieve the matchbox
with PDF_info_matchbox( ).
Examples for using the fitbox option:
Fit box at the top of the table instance with a height of 20: fitbox={0r 100% 0r 20r}
Fit box to the right of the table instance with width 20 and offset 20% from the bottom:
fitbox={100% 20% 20r 0r}
In addition, the following options are supported:
> Options for static cell contents according to Table 5.16: fitgraphics, fitimage, fitpath, fitpdipage,
fittextflow, fittextline, graphics, image, matchbox, path, pdipage, text, textflow
> Options for interactive cell contents according to Table 5.17 (only in page scope):
annotationtype, fieldname, fieldtype, fitannotation, fitfield
> Option for abbreviated structure element tagging according to Table 14.5: tag. This can be used for in-
serting a parent element of the caption contents, or a grouping element as container for multiple ele-
ments which comprise the caption contents.
colwidth- (Float or keyword; only relevant in the first call to PDF_fit_table( ) for a particular table) Default width
default for columns which do not contain any Textline nor Textflow and for which the colwidth option of PDF_
add_table_cell( ) was not specified. The default width can be specified as an absolute value or as a
keyword. The value 0 (zero) is equivalent to the keyword distribute. The following keywords are
supported (default: auto):
auto Columns with unspecified width which contain only Textline cells will have the width of the
text. The remaining width of the fitbox will be distributed among all rows with Textflow or
other cells. The table covers the full width of the fitbox.
distribute The width of the fitbox will be distributed equally among all columns with unspecified width
and which dont contain any Textline. The table covers the full width of the fitbox unless it
contains only Textlines.
minimum Columns with unspecified width which contain only Textline cells will have the width of the
text, i.e. the smallest possible width to hold the text.
In order to create columns with minimal width you can supply a small value (e.g. 1). The width of all col-
umns which contain Textline or Textflow cells will be adjusted automatically (see PDFlib Tutorial).
debugshow (Boolean) If true, all errors for tables which are too high or too wide, or where the cells get too small are
suppressed and logged instead. The resulting table instance is created as a debugging aid although the
table is damaged. Default: false
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 131):
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 PDF_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 PDF_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.1 can also be used:
fillcolor, shading
Examples:
fill all rows in the table with red: fill = { {area=table fillcolor=red} }
fill odd-numbered rows with green and even-numbered rows with red:
fill = { {area=rowodd fillcolor=green} {area=roweven fillcolor=red} }
Use fillcolor=none to suppress shading for a table area.
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 PDF_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. cur-
rent 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 tables 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 PDF_fit_table( ). Cur-
rently the following values are supported (default: 0):
1 Rewind to the state before the first call to PDF_fit_table( ).
0 Dont reset the table.
-1 Rewind to the state before the last call to PDF_fit_table( ) (the one before the current call)
rowheight- (Float or keyword; only relevant in the first call to PDF_fit_table( ) for a particular table) Default height of
default rows for which the rowheight option of PDF_add_table_cell( ) was not specified. The default height can
be specified as an absolute value or as a keyword. If a float value is specified it is used as default row
height unless it is smaller than the textbox height. The value 0 (zero) is equivalent to the keyword
distribute. The following keywords are supported (default: auto):
auto Rows which contain only Textline cells have a height of two times the height of the textbox.
The remaining height of the fitbox is distributed among all rows with Textflow or other cells.
The table covers the full height of the fitbox.
distribute The height of the fitbox is distributed equally among all rows with unspecified height. The
table covers the full height of the fitbox.
minimum Rows with unspecified height which contain only Textline cells have the height of the textbox,
i.e. the smallest possible height to hold the text. Use the boxsize or margin options to
increase the height of Textline cells.
In order to create rows with minimal height you can supply a small positive value (e.g. 1). The height of
all rows which contain Textline or Textflow cells will be adjusted automatically (see PDFlib Tutorial).
showcells (Boolean) If true, the border of each inner cell box will be stroked using the current graphics state. In
page scope and if PDF/A is not active each cell is additionally decorated with an annotation with details
describing the cell contents which may be helpful for analyzing table-related problems. Default: false
showgrid (Boolean) If true, the vertical and horizontal boundary of all columns and rows are 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.1 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} }
Use strokecolor=none to suppress stroking for a table area.
vertshrink- (Float or percentage) The lower limit for the vertical shrinking factor which will be used when the table is
limit shrunk to fit the tables 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%
Retrieve table information related to the most recently placed table instance.
table A valid table handle retrieved with a call to PDF_add_table_cell( ). The table han-
dle must already have been used in at least one call to PDF_fit_table( ) since the returned
values are meaningful only after placing a table instance on the page.
Returns The value of some table parameter as requested by keyword. This function returns cor-
rect geometry information even in blind mode. If the requested keyword produces text,
a string index is returned, and the corresponding string must be retrieved with PDF_
get_string( ).
firstbodyrow Number of the first body row in the most recently placed table instance
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
rowcount Number of rows in the most recently placed table instance (including headers and footers)
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 neg-
ative value).
vert- Vertical shrinking factor as a percentage of the calculated table height. If the table had to be shrunk ver-
shrinking tically the value will specify the shrinking percentage, otherwise it will be 100.
xvertline# x coordinate of the vertical line with number #. xvertline0 is the left table border.
yhorline# y coordinate of the horizontal line with number #. yhorline0 is the top table border.
Details Tables which have not been deleted with this function will be deleted automatically at
the end of the enclosing document scope.
Scope any
keephandles (Boolean) If false, all handles supplied to the textflow, image, graphics and pdipage options of PDF_
add_table_cell( ) will automatically be deleted. Default: false
Note Since the fitting options for Textflow are slightly different they are not described here, but in
Section 5.2, Multi-Line Text with Textflows, page 95.
Table 6.1 lists fitting options which can be supplied to the fitting functions. Not all op-
tions 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, stamp, showborder, shrinklimit
Object box. In all cases the fitting algorithm calculates the smallest enclosing rectan-
gle of the placed object. This rectangle is called the object box. It can be modified accord-
ing to the type of object:
> Textlines (PDF_fit/info_textline( ), single-line text Blocks, table cells): The width is the
width of the text string (in horizontal writing mode) or the width of the widest glyph
(in vertical writing mode). 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 op-
tion. Character spacing will not be applied after the last glyph.
> Images and templates (PDF_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. If the transform option of PDF_begin_template_
ext( ) has been supplied, the specified transformation is applied to the template.
> Graphics (PDF_fit/info_graphics( )): the suboption clipping of the matchbox option can
be used to define some part of the object as object box. The object box is defined by
the width and height of the SVG graphics or by forcedwidth and forcedheight. If these
values are 0 the following holds: if fitmethod is different from nofit or the fitbox is
not defined, the size of the object box is defined by fallbackwidth and fallbackheight. If
fitmethod=nofit and the fitbox is defined, the size of the object box is defined by the
fitbox.
Reference point. The reference point is used as an anchor for placing the object box. It is
defined as follows:
> In PDF_fit_*( ) and PDF_draw_path( ): the x and y function parameters;
> In PDF_info_*( ): the point (0, 0); PDF_info_path( ) additionally supports the refpoint op-
tion for specifying the reference point.
> PDF_add_table_cell( ), PDF_fit_table( ), and PDF_fill_*block( ): the lower left corner of the
table cell, table instance, or PDFlib Block; PDF_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]) (if topdown=false)
upper right corner = (x + boxsize[0], y - boxsize[1]) (if topdown=true)
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
alignchar (Unichar < 0xFFFF 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 ap-
plied, although the text cannot be placed within the fitbox because of the forced positioning of
alignchar. Default: none
attachment- (String; only for path objects) Name of the attachment point. The path object will be placed so that the
point specified attachment point coincides with the reference point. If fitmethod is different from nofit the
object will first be placed in the fitbox according to the specified method. Default: origin of the path ob-
ject
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 PDF_info_*( ). Default: false
boxsize (List of two floats; not for tables) Width and height of the fitbox, relative to which the object (possibly ro-
tated 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 is 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 Blocks Rect property
Default for all other fitting functions: {0 0}
dpi (List of two floats or keywords; only for images) One or two values specifying the desired image resolu-
tion in pixels per inch in horizontal and vertical direction. This option does not change the number of pix-
els in the image (downsampling). If a single value is supplied it is used for both dimensions. With the val-
ue zero the images internal resolution is 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 is different from the supplied
values. The scale option will be applied in addition to the dpi values.
If the fitmethod option has been supplied with one of the keywords auto, meet, slice, or entire, the dpi
values specify only the images aspect ratio, but not its absolute size. 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 are ignored if no fitbox has been specified.
Default: clip for Textflow and tables; meet for path objects and reference option; and nofit otherwise
margin (List of floats; only for Textlines) One or two float values describing additional horizontal and vertical re-
ductions of the fitbox. Default: 0
matchbox (Option list; not for path objects) Option list for creating a matchbox according to Table 6.4
minfontsize (Float or percentage; only for Textflow) 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 spec-
ified minfontsize as fontsize. Default: 0.1%
orientate (Keyword or float; not for tables) Specifies the desired orientation of the object relative to the current co-
ordinate 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):
north upright (0)
east pointing to the right (270)
south upside down (180)
west pointing to the left (90)
position (List of floats or keywords) One or two values specifying the position of the object box relative to the ref-
erence 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 per-
centage 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 percent-
ages, 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: {0 100} for tables, center for the reference option, otherwise {0 0}. 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 key-
word 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
refpoint (List of floats; only for PDF_fill_*block( ) and PDF_info_path( )) Specifies the reference point in user coordi-
nates for fitting the block contents or path.
Default for PDF_fill_*block( ): lower left corner of the rectangle defined by the Blocks Rect property
Default for PDF_info_path( ): {0 0}
rotate (Float; not for tables and 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 rotat-
ed. The rotation will be reset when the object has been placed. Default: 0
Textline in table cells: if the rotate option was specified with a value different from 0, the table engine
attempts to fit the bounding box of the rotated text into the cell box according to the fitmethod and
position options. If fitmethod is different from auto, the cell will be enlarged appropriately if necessary.
scale (List of floats; not for Textlines and Textflow) 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. Negative values result in mirroring. The absolute value of this option
ignored if the fitmethod option has been supplied with one of the keywords auto, meet, slice, or
entire. Default: {1 1}
stamp (Keyword; only for Textlines; will be ignored if boxsize is not specified) This option can be used to create
a diagonal stamp of maximal size in the rectangle specified with the boxsize option. More specifically,
the text will be placed diagonally in the fitbox. The size of the text box will be chosen so that it covers the
fitbox as much as possible while preserving the aspect ratio of the text box (i.e. the text comprising the
stamp will be as large as possible). The options fontsize, fitmethod, and position will be ignored. The
options orientate=west and =east dont make any sense (only north and south). Supported keywords
(default: none):
ll2ur The stamp runs diagonally from the lower left corner to the upper right corner.
ul2lr The stamp runs diagonally from the upper left corner to the lower right corner.
none No stamp will be created.
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 de-
bugging. 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
auto This method tries to fit the object box into the fitbox automatically:
If the object fits into the fitbox the behavior is identical to the nofit
method, i.e. the object is placed without any scaling. If the object is larger Kraxi Systems
than the fitbox the object is proportionally reduced in size as follows:
> Textlines: a scaling factor is calculated such that the text can 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
Kraxi Systems
reducing the fontsize until the text can be fit or the fontsize 0.001 is
reached.
> PDF_fit_table( ): If the table box is narrower than the fitbox it is en- Kraxi Systems
Kraxi Systems
entire Scale the object box such that it entirely covers the fitbox. Generally this
method will distort the object. The position option doesnt have any ef-
fect.
PDF_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. Gener-
ally at least two edges of the object box meet the corresponding edges of Kraxi Systems
the fitbox.
PDF_fit_table( ): similar to clip. If the table box is smaller than the fit-
box, the cells of the table box (but not their contents) are enlarged uniformly until the horizontal or ver-
tical table edge meets the fitbox.
nofit Position the object only. The scale option is applied to images and
graphics, for images also the dpi option.
PDF_fit_table( ): The table will be calculated for a virtual fitbox with
Kraxi Systems
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.
Kraxi S
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 objects other dimension will extend be-
yond the fitbox, and will therefore be clipped.
PDF_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 op-
tion. The parts of the table box which exceed beyond the fitbox will be clipped graphically at the edges of
the fitbox.
Table 6.3 Common keywords for querying the results of object fitting with PDF_info_image( ), PDF_info_graphics( ), PDF_
info_path( ), PDF_info_pdi_page( ), PDF_info_table( ), PDF_info_textline( )
keyword description
fitscalex, fitscaley Scaling factors which resulted from fitting the object to a box.
objectheight, Raw size of the object after processing all options relevant for loading or creating the object. This
objectwidth size will be used by the fitting algorithm.
x1, y1, x2, y2, Position of the i-th rectangle corner (i=1, 2, 3, 4) of the objects bounding box in user coordinates
x3, y3, x4, y4 according to the supplied options.
Matchboxes are defined with the matchbox option of these functions. It expects an op-
tion list which supports the following suboptions:
> Graphics appearance options according to Table 7.1:
borderwidth, dasharray, dashphase, fillcolor, gstate, linecap, linejoin, shading, strokecolor
> Matchbox controlling options according to Table 6.4;
> Option for abbreviated structure element tagging according to Table 14.5 (only al-
lowed in page scope): tag
A rectangle defined by a matchbox will be filled if the option(s) fillcolor or shading are
specified. The border of a matchbox will be stroked if the option strokecolor is specified
and option bordercolor has a value > 0.
Details of the rectangle(s) corresponding to a matchbox can be queried with PDF_
info_matchbox( ).
boxheight (List with two elements, each being a positive float, a percentage of the fontsize, or a keyword; only for
Textline and Textflow) Vertical extent of the text box. Two values can be specified numerically or via key-
words 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 per-
centage of the width of the fitbox. If this option is supplied, horizontal space of the specified width is in-
serted 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. Note that
with alignment=justify the box width may be compressed the same way as text (see option shrink-
limit). Default: 0
clipping (Rectangle or 4 percentages; only for images, graphics 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, graphics or page specifying which part should be displayed. The specification depends
on the type of object (default: {0% 0% 100% 100%}):
> For images the clipping rectangle can be specified in pixels or as a percentage of the width/height.
> For graphics the clipping rectangle can be specified in user coordinates or as a percentage of the width/
height of the graphics object box.
> For PDF pages the clipping rectangle can be specified in default units or as a percentage of the width/
height of the pages crop box.
create- (Boolean; only for Textflow) If true, the rectangle(s) comprising the matchbox will be inserted as wrap
wrapbox 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)
drawleft (Boolean) If true, the corresponding border of the rectangle will be drawn provided that the
drawbottom borderwidth is set to a value greater than 0. Default: true
drawright
drawtop
end (Boolean; only for Textflow) Specifies the end of the matchbox. If true, all other suboptions for the cur-
rent matchbox definition will be ignored. Matchboxes in Textflows cannot be nested. The width of a Tex-
tflow 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 af-
ter 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 ex-
ceed 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 PDF_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, an addi-
tional rectangle for this matchbox will be created. This means that a matchbox may consist of more than
one rectangle. The name can be used in PDF_info_matchbox( ). Various functions support the option
usematchbox to reference one or more rectangles of a matchbox, e.g. to add an annotation with PDF_
create_annotation( ). Matchbox names can be used until the end of the current page. The name * (as-
terisk character) should not be used as matchbox name. Default: no name
offsetleft (Float or percentage) User-defined offset from the left/right/bottom/top edge of the calculated rectan-
offsetbottom gle and the desired box. The values are specified in user coordinates or as a percentage of the rectangles
offsetright width (for offsetleft/offsetright) or height (for offsetbottom/offsettop). Negative values are al-
offsettop lowed, and can be used to extend the matchbox. Default of offsetleft/offsetbottom: margin; De-
fault of offsetright/offsettop: -margin
openrect (Boolean; only for Textflow and table cells) Textflow: If true and a matchbox rectangle has to be split
(e.g. because of a font change or line break), 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 in-
stance the bottom border of the first part and the top border of the second part will not be drawn. De-
fault: 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 in-
wards, and the tangents will be perpendicular to the line segments of the box. Default: 0 (no rounding)
boxname (Name string) Name of a matchbox which has been created under this name
on the current page. It must have been created with the name suboption of the
matchbox option when the matchbox was defined. Alternatively, the name * (asterisk
character) can be used to query information about all matchboxes on the page. An emp-
ty boxname can be used to query information about all matchbox rectangles on the cur-
rent page.
num Positive number of a matchbox or rectangle (the first has number 1).
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, the
return value is -1 (in PHP: 0) for the keywords boundingbox, name, and rectangle, and 0
for all other keywords. If the requested keyword produces text, a string index is re-
turned, and the corresponding string must be retrieved with PDF_get_string( ).
Depending on the current scope, the function returns information about the match-
boxes on the current page, pattern, template, or glyph description.
Details Named matchboxes within a Textflow can only be queried after calling PDF_fit_
textflow( ). Matchboxes created in blind mode cannot be queried.
Rectangles for the keywords boundingbox, exists, height, name, rectangle, width, x1,
y1,...,x4,y4 are selected as follows:
> If boxname contains the name of a matchbox: select the num-th rectangle of the spec-
ified named matchbox on the current page.
boundingbox Handle of a path object containing the bounding box of the selected rectangle in the current user coordi-
nate system or -1 (in PHP: 0) if the specified rectangle doesnt exist. The bounding box is different from
the rectangle if the matchbox was rotated.
name String index for the name of the matchbox for which the selected rectangle was created. The corre-
sponding string can be retrieved via PDF_get_string( )
rectangle Handle of the path object containing the selected rectangle in user coordinates or -1 (in PHP: 0) if the
rectangle couldnt be found
borderwidth (Float; only for matchboxes) Line width for the rectangles 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. De-
fault: 0
dasharray (List of two non-negative floats or keyword) List of 2-12 alternating values for the lengths of dashes and
gaps for stroked paths (measured in the user coordinate system). The array values must not be negative.
They will be cyclically reused until the complete path is stroked. The keyword none can be used to create
solid lines. Default: none
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 ta-
bles 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 sim-
ple shapes, the result of filling matches intui-
tive expectations. For shapes consisting of mul-
tiple paths the direction of the paths is
relevant.
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 PDF_create_gstate( ). Default: no graphics
state (i.e. current settings will be used)
initgraphics- (Boolean; only for PDF_set_graphics_option( )) If true all graphics appearance options are initialized
state with the default values. The current clipping path is not affected. If false the current graphics state val-
ues are used. Default: false
linecap (Integer or keyword) Shape at the end of a path (default: projecting in PDF_fit_table( ), otherwise
butt):
butt (Equivalent value: 0) Butt end caps: the stroke is squared off at the
endpoint of the path.
miterlimit (Float >= 1) Controls the spike produced by miter joins (default: 10; this cor-
responds to an angle of roughly 11.5 degrees)
Miter
If the linejoin style is set to 0 (miter join), two line segments joining at a length
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 ra-
tio of the miter length and the linewidth exceeds the miter limit.
Line width
shading (Option list according to Table 8.4; only for matchboxes and tables) Specify a shading for the matchboxs
rectangle(s) or table area The following options can be used: antialias, domain, end, endcolor, N, start,
startcolor, type
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
optlist An option list specifying graphics appearance options according to Table 7.1.
The following options can be used:
cliprule, dasharray, dashphase, fillcolor, fillrule, flatness, gstate, initgraphicsstate, linecap,
linejoin, linewidth, miterlimit, strokecolor
Details Graphics appearance options set the graphics state for the following groups of func-
tions:
> explicit drawing functions, e.g. PDF_stroke( ), PDF_fill( )
> implicit drawing functions, e.g. the showborder option of PDF_fit_textline( ), PDF_fit_
textflow( )
> text output created with simple text output functions if no color has been set with
text options, e.g PDF_show( )
All graphics appearance options are reset to their default values at the beginning of a
page, pattern, template, or glyph description, and retain their values until the end of
the current page, pattern, template, or glyph scope. However, the graphics appearance op-
tions can also be reset with the initgraphicsstate option.
A subsequent call to PDF_setcolor( ) overrides the fillcolor and/or strokecolor values. A
subsequent call to PDF_setlinewidth( ) overrides the linewidth value.
Details This function sets the line width in the graphics state (see PDF_set_graphics_option( )) as
well as the stroke width in the text state (see PDF_set_text_option( )). The width is reset to
the default value of 1 at the beginning of each page.
Details The graphics state contains options 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 re-
turn to some specific graphics state later (e.g. a custom coordinate system) without set-
ting all relevant options explicitly again. The following items are subject to save/re-
store:
> graphics appearance options:
clipping path, coordinate system, current point, flatness tolerance, line cap style,
dash pattern, line join style, line width, miter limit;
> color options: fill and stroke colors;
> graphics options which have been set with explicit graphics states in PDF_set_
gstate( );
> text position and the following text appearance options:
charspacing, decorationabove, fakebold, font, fontsize, horizscaling, italicangle, leading,
strokewidth, textrendering, textrise, underlineposition, underlinewidth, wordspacing.
Pairs of PDF_save( ) and PDF_restore( ) may be nested. Although the PDF specification
doesnt 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 Post-
Script output produced by PDF viewers, and to allow for additional save levels required
by PDFlib internally.
Most text options are affected by save/restore; see list above. The following text
options are not subject to save/restore: fillrule, kerning, underline, overline, strikeout.
Scope page, pattern, template, glyph; must always be paired with a matching PDF_restore( ) call.
PDF_save( ) and PDF_restore( ) calls must be balanced on each page, pattern, template,
and glyph description.
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 PDF_save( ) call.
PDF_save( ) and PDF_restore( ) calls must be balanced on each page, pattern, template,
and glyph description.
Returns A graphics state handle that can be used in subsequent calls to PDF_set_gstate( ) during
the enclosing document scope.
Details The option list may contain any number of graphics state options.
alphaisshape (Boolean) Sources of alpha are treated as shape (true) or opacity (false). Default: false
blendmode (Keyword; in PDF/X-1/3 and PDF/A-1 only Normal is allowed) Blend mode for transparency opera-
tions (default: None):
Color, ColorDodge, ColorBurn, Darken, Difference, Exclusion, HardLight, Hue, Lighten,
Luminosity, Multiply, None, Normal, Overlay, Saturation, Screen, SoftLight
See PDFlib Tutorial for descriptions of these blend modes and examples for their use.
opacityfill (Float or percentage; in PDF/A-1 and PDF/X-1/3 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 or percentage; in PDF/A-1 and PDF/X-1/3 it must have the value 1) Opacity for stroke opera-
tions in the range 0..1. The value 0 means fully transparent; 1 means fully opaque.
overprintfill (Boolean) Overprint behavior for all non-stroking operations including image placement: if
false, painting in any color space erases the corresponding areas of unspecified colorants; if true
and the output device supports overprinting, previous markings in other colorants are left un-
changed. Default: false
overprintstroke (Boolean) Overprint for stroke operations: if false, painting in any color space erases the corre-
sponding areas of unspecified colorants; if true and the output device supports overprinting, pre-
vious markings in other colorants are left unchanged. Default: false
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 im-
aging. Supported options and keyword (default: none):
backdropcolor
(List with one, three, or four floats; only for type=luminosity) Color to be used as the
backdrop against which to composite the transparency group template. The color
values are interpreted according to the colorspace suboption of the transparency-
group option used when creating the transparency group template (e.g. 3 for
DeviceRGB). Default: black in the respective colorspace
none (Keyword) No soft mask at all; this is required to disable soft masks which may be in
effect from a previously set graphics state.
template (Template handle; required) Transparency group template which has been created
with PDF_begin_template_ext( ) and the transparencygroup option. If type=
luminosity the template must have been created with the colorspace suboption
and a value different from none.
type (Keyword; required) Method for deriving mask values from the transparency group
template:
alpha The templates alpha value defines the mask.
luminosity The templates color is converted to a luminosity value which defines the
mask.
strokeadjust (Boolean) Whether or not to apply automatic stroke adjustment. Default: false
textknockout (Boolean) With respect to compositing, glyphs in a text object will be treated as separate objects
(false) or as a single object (true). Default: true
Details All options contained in the graphics state object will be set. Graphics state options ac-
cumulate 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.
tx, ty The new origin of the coordinate system is the point (tx, ty), measured in the old
coordinate system.
Details This function scales the coordinate system by sx and sy. It may also be used for achiev-
ing 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 sys-
tem; analogous for y coordinates.
Bindings COM: this function is also available under the name pscale to work around a bug in VB.
Details Angles are measured counterclockwise from the positive x axis of the current coordi-
nate system. The new coordinate axes result from rotating the old coordinate axes by
phi degrees.
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 PDF_rotate( ) with phi=180 / pi * atan2(dy/dx).
Details Skewing (or shearing) distorts the coordinate system by the given angles in x and y di-
rection. alpha is measured counterclockwise from the positive x axis of the current coor-
dinate system, beta is measured clockwise from the positive y axis. Both angles must
not be odd multiples of 90.
Details This function allows for the most general form of transformations. Unless you are fa-
miliar with the use of transformation matrices, the use of PDF_translate( ), PDF_scale( ),
PDF_rotate( ), and PDF_skew( ) is suggested instead of this function. The coordinate sys-
tem 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
a, b, c, d, e, f See PDF_concat( ).
Details This function is similar to PDF_concat( ). However, it disposes of the current transforma-
tion matrix, and replaces it with the new matrix.
PDF/UA Vector graphics must be tagged as Artifact or Figure with a call to PDF_begin_item( ).
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, glyph, path; this function starts path scope.
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 deter-
mined by the value of the linewidth option) will be painted on each side of the line con-
necting both endpoints. The behavior at the endpoints is determined by the linecap op-
tion.
Scope path
C++ Java C# void curveto(double x1, double y1, double x2, double y2, double x3, double y3)
Perl PHP curveto(float x1, float y1, float x2, float y2, float x3, float y3)
C void PDF_curveto(PDF *p, double x1, double y1, double x2, double y2, double x3, double y3)
Draw a Bzier curve from the current point, using three more control points.
x1, y1, x2, y2, x3, y3 The coordinates of three control points.
Details A Bzier 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
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. The circle is created in counterclockwise direction.
Scope page, pattern, template, glyph, path; this function starts path scope.
Bindings COM: this function is also available under the name pcircle to work around a bug in VB 6.
C++ Java C# void arc(double x, double y, double r, double alpha, double beta)
Perl PHP arc(float x, float y, float r, float alpha, float beta)
C void PDF_arc(PDF *p, double x, double y, double r, double alpha, double beta)
Details This function adds a counterclockwise circular arc segment to the current path, extend-
ing from alpha to beta degrees. For both PDF_arc( ) and PDF_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, glyph, path; this function starts path scope.
C++ Java C# void arcn(double x, double y, double r, double alpha, double beta)
Perl PHP arcn(float x, float y, float r, float alpha, float beta)
C void PDF_arcn(PDF *p, double x, double y, double r, double alpha, double beta)
Details Except for the drawing direction, this function behave exactly like PDF_arc( ). In particu-
lar, the angles are still measured counterclockwise from the positive x axis.
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
Details This function adds an ellipse to the current path as a complete subpath. The point
(x + rx, y) becomes the new current point. The ellipse is created in counterclockwise di-
rection.
Scope page, pattern, template, glyph, path; this function starts path scope.
C++ Java C# void elliptical_arc(double x, double y, double rx, double ry, String optlist)
Perl PHP elliptical_arc(float x, float y, double rx, double ry, string optlist)
C void PDF_elliptical_arc(PDF *p, double x, double y, double rx, double ry, const char *optlist)
Draw an elliptical arc segment from the current point.
rx, ry The x and y radii of the ellipse. At least one of these values must be larger than
half the distance between the current point and (x, y).
optlist An option list specifying construction options for the elliptical arc according to
Table 7.3.
Details This function adds an elliptical arc segment to the current path. The arc segment will
start at the current point and end at (x, y). The current point must be set before using
this function. The end point of the arc becomes the new current point. Two of the four
possible arc segments represent an arc segment of 180 (the small arc segments), while
the other two represent an arc segment of 180 (the large arc segments).
clockwise (Boolean) If true one of the clockwise arc segments will be created; otherwise one of the counterclock-
wise arc segments will be created. Default: false
largearc (Boolean) If true one of the large arc segments will be created; otherwise one of the small arc segments
will be created. Default: false
rectify (Boolean) If true radii which are too small will be modified so that the elliptical arc can be constructed;
otherwise an exception will be thrown. Default: false
xrotate (Float) Rotation angle for the ellipse, i.e. the angle of the ellipse x axis relative to the current coordinate
system x axis in degrees. The start and end point of the arc segment remain fixed. Default: 0
Draw a rectangle.
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 are centered around the ideal line, i.e. half of the line-
width (as determined by the value of the linewidth option) is painted on each side of the
line connecting the respective endpoints. The rectangle is created in counterclockwise
orientation. This function implicitly closes the path.
Scope page, pattern, template, glyph, path; this function starts path scope.
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
Stroke the path with the current line width and current stroke color, and clear 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.
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 option). Open paths
are implicitly closed before being filled.
Fill and stroke the path with the current fill and stroke color.
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.
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 val-
ue of the page size at the beginning of each page. The clipping path is subject to PDF_
save( )/PDF_restore( ). It can only be enlarged by means of PDF_save( )/PDF_restore( ). The
clipping area is determined according to the algorithm selected with the cliprule option.
Details This function doesnt have any visible effect on the page. It generates an invisible path
on the page.
C++ Java C# int add_path_point(int path, double x, double y, String type, String optlist)
Perl PHP int add_path_point(int path, float x, float y, string type, string optlist)
C int PDF_add_path_point(PDF *p, int path, double x, double y, const char *type, const char *optlist)
Add a point or path to a new or existing path object.
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=circle, circular, elliptical,
ellipse, move, line, curve, rect.
addpath Add the path definition specified in the svgpath option as a complete subpath, using (x, y) as origin.
circle Add a circle to the path as a complete subpath, using (x, y) as the center and radius for the size.1
circular Add a circular arc from the current point to (x, y) with the previously defined control point as third cir-
cular 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.2
curve Add a Bzier 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 sec-
ond control point for the curve, and the first control point will be constructed as the reflection of the sec-
ond control point at the endpoint of the previous Bzier curve.2
ellipse Add an ellipse to the path as a complete subpath, using (x, y) as the center and the values in the radius
option for the size.1 The ellipse can be rotated with the xrotate option.
elliptical Add an elliptical arc from the current point to (x, y). The size and orientation of the ellipse are defined
by the radius, xrotate, largearc, and clockwise options. If only a single value is provided as radius a
circular arc will be created. In this case an appropriate circular arc point will be created automatically. If
two values are provided in the radius option a set of Bzier curves will be created.2
line Add a line segment from the current point to (x, y).2
move Start a new subpath. Subpaths will be numbered consecutively (1, 2, ...). The first subpath starts at the or-
igin.
pathref Add a reference to the path specified in the path option as a complete subpath, using (x, y) as origin.
Since the path is referenced (and not copied) subsequent changes to path will be reflected when drawing
the path.
rect Add a rectangle to the path as a complete subpath, using (x, y) as the center of the rectangle and width
and height for the size.1 The corners of the rectangle can be rounded before drawing with the round op-
tions. Alternatively, the corners can be rounded with elliptical arcs with the radius option.
1. A new point with type=move and the same coordinates and graphics appearance options is created automatically after the path.
2. Graphics appearance options and path operation options are not allowed for these types.
Returns A path handle which can be used until it is deleted with PDF_delete_path( ).
Details A path object serves as a container for vector graphics. The path object can be populated
with paths and subpaths incrementally, where new path elements can be created by
specifying individual path nodes or by adding path definitions specified via a path han-
dle or an SVG path description. The generated path can later be used with PDF_draw_
path( ) and other functions.
A path object can hold any number of paths. Each path in turn may contain one or
more subpaths which can be selected for drawing in the subpaths option of PDF_draw_
path( ). All paths will be closed, filled, stroked, and rounded separately according to the
specified options.
An operation with any of the types addpath, circle, ellipse, move, rect, or pathref starts a
new subpath. Graphics appearance options and path operation options (e.g. stroke, fill)
can only be changed for type=addpath, circle, ellipse, move, rect, or pathref. In this situation
a new path within the path object will be started automatically. Shapes of type circle,
ellipse, elliptical, and rect are created in counterclockwise direction by default, but this
can be changed with the option clockwise.
Scope any
clockwise (Boolean; only for type=circle, ellipse, elliptical, rect) If true the shape is created in clockwise
direction, otherwise counterclockwise. Default: false
close (Boolean; only for type=move) If true, the subpath will be closed with a straight line. Default: see foot-
note1
fill (Boolean; only for type=move) If true the subpath will be closed and filled. Default: see footnote1
height (Float; only for type=rect; required in this case) Height of the rectangle
largearc (Boolean; only for type=elliptical) If true one of the large elliptical arc segments will be created; oth-
erwise one of the small elliptical arc segments will be created. Default: false
name (String) Name of the point. Default: p<i> (e.g. p1) where i is the consecutive number of supplied points.
path (Path handle; only for type=pathref) The specified path will be added to the current path by reference.
The coordinates of the added path refer to the current point as origin. Graphics appearance options and
the name option will be ignored.
polar (Boolean) If true, the (x, y) parameters are polar coordinates specifying radius r and angle phi, other-
wise 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
radius (One or two floats; required for type=circle, ellipse and elliptical; also allowed for type=rect)
The first value specifies the radius of the circle or the x radius of the ellipse. The second float value, if pres-
ent, specifies the y radius of the ellipse. The first value will be used as default for the second value.
For type=rect the values specify the x and y radii of the elliptical arcs in the rectangle corners. The ellipti-
cal arcs will be created immediately. Default: 0
rectify (Boolean; only for type=ellipse and elliptical) If true radii which are too small will be modified so
that the elliptical arc can be constructed; otherwise an exception will be thrown. 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. The circular arcs will be created when the path is drawn. Default: see footnote1
stroke (Boolean; only for type=move) If true the subpath will be stroked. Default: see footnote1
svgpath (String; only for type=addpath) String containing a path description in SVG syntax according to
www.w3.org/TR/SVG11/paths.html#PathData. The specified path will be added to the current path. The
coordinates of the specified SVG path refer to the current point as origin. Graphics appearance options
can be specified for the SVG path. The option rectify is taken into account for the inserted SVG path. If
the path stems from an SVG file with a topdown coordinate system it must be mirrored (even if PDFlib
operates in topdown mode). This can be achieved with the option scale={1 -1} in PDF_draw_path( )
width (Float; only for type=rect; required in this case) Width of the rectangle
xrotate (Float; only for type=ellipse and elliptical) Rotation angle for the ellipse in current units (see option
radians), i.e. the angle of the ellipse x axis relative to the current coordinate system x axis in degrees.
The start and end point of the arc segment remain fixed. This option will be ignored if only a single value
was supplied as radius. Default: 0
1. The default is specified in PDF_draw_path( ), PDF_info_path( ), the textpath option of PDF_fit_textline( ), the wrap option of PDF_
fit_textflow( ), or the fitpath option of PDF_add_table_cell( ).
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 cur-
rent 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.
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 op-
tions override the default settings, but they do not override any appearance option
which may have been specified for a subpath in PDF_add_path_point( ).
PDF/UA All path objects must be tagged as Artifact or Figure, either with the tag option or with a
preceding call to PDF_begin_item( ).
Table 7.6 Path operation options for PDF_draw_path( ) for controlling all subpaths in a path object
option description
bboxexpand (List of floats; will be ignored if the boundingbox option is specified) One or two floats which indicate the
expansion of the automatically calculated bounding box (the smallest enclosing rectangle of the path
object). Default: {0 0}
bounding- (Rectangle) A rectangle in the coordinate system of the path object which will be used as bounding box
box for fitting the path object into the fitbox. Default: the smallest enclosing rectangle of the path object,
possibly expanded according to the bboxexpand option
clip (Boolean) If true the path will be closed and used as clipping path. 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; overrides clip) 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 round-
ing will be done. Default: the value specified when the path was constructed, or 0 if no value was speci-
fied
stroke (Boolean; overrides clip) 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 first subpath has
number 1. The keyword all specifies all subpaths. Default: all
bboxwidth, Width and height of the bounding box for the path
bboxheight
px, py The x or y coordinate (in the user coordinate system) of the path point specified in the name op-
tion. The option subpaths will be ignored.
type Numerical indicator of the type of a point which has been specified with the option name. Path
components of type elliptical, circle, and ellipse are already converted to Bzier curves,
type rect is converted to lines:
0 move
1 line
2 control
3 curve
4 circular
Scope any
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 PDF_add_path_point( ).
Details Delete the path object and all associated internal data structures. Note that path objects
will not automatically be deleted in PDF_end_document( ).
Scope any
Fill and stroke colors can be set with PDF_setcolor( ) as well as with the options fillcolor,
strokecolor and others. Using options is recommended because this method is more gen-
eral. Section 1.1.4, Color Data Type, page 13, contains a discussion of color options.
C++ Java C# void setcolor(String fstype, String colorspace, double c1, double c2, double c3, double c4)
Perl PHP setcolor(string fstype, string colorspace, float c1, float c2, float c3, float c4)
C void PDF_setcolor(PDF *p,
const char *fstype, const char *colorspace, double c1, double c2, double c3, double c4)
Set the current color space and color for the graphics and text state.
fstype One of fill, stroke, or fillstroke to specify that the color is set for filling, stroking,
or both.
colorspace Specifies the color space 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, devicen, 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 hexa-
decimal digits (e.g. #FFC0CB). The parameters c1, c2, c3, and c4 are ignored in this case.
c1, c2, c3, c4 Color components for the chosen color space. The interpretation of these
values depends on the colorspace parameter (see PDFlib Tutorial for a full discussion of
color spaces and values):
> 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 PDF_makespotcolor( ), and c2 specifies
a tint value between 0 and 1;
> devicen: c1 specifies a DeviceN color space handle returned by PDF_create_devicen( );
c2, c3, and c4 specify up to three tint values between 0 and 1. DeviceN colors with N>3
cannot be specified with this function.
> lab: c1, c2, and c3 specify color values in the CIE L*a*b* color space. c1 specifies the L*
(luminance) value in the range 0 to 100, and c2, c3 specify the a*, b* (chrominance)
values in the range -128 to 127.
> pattern: c1 specifies a tiling pattern handle returned by PDF_begin_pattern_ext( ) or a
shading pattern handle returned by PDF_shading_pattern( ). If a tiling pattern has
been created with the option painttype=uncolored in PDF_begin_pattern_ext( ), the cur-
Details All color values for the gray, rgb, and cmyk color spaces and the tint value for the spot col-
or space must be numbers in the inclusive range 01. Unused parameters should be set
to 0. More information about color spaces and color values can be found in the PDFlib
Tutorial.
The fill and stroke color values for the gray, rgb, and cmyk color spaces are set to a de-
fault value of black at the beginning of each page. There are no defaults for spot and pat-
tern colors.
If the iccbasedgray/rgb/cmyk color spaces are used, a suitable ICC profile must have
been set before using one of the iccprofilegray/rgb/cmyk options.
This function is equivalent to PDF_set_text_option( ) and PDF_set_graphics_option( )
with the fillcolor and/or strokecolor options. PDF_setcolor( ) overrides the values of these
options.
Colors in an iccbased color space and DeviceN colors with N>3 cannot be specified
with this function, but only with color options.
PDF/A colorspace=gray requires an output intent (any type) or the defaultgray option.
colorspace=rgb requires an RGB output intent or the defaultrgb option.
colorspace=cmyk requires a CMYK output intent or the defaultcmyk option.
Scope page, pattern (only if painttype=colored), template, glyph (only if the Type 3 fonts colorized
option is true), document; a pattern color can not be used within its own definition. Set-
ting the color in document scope may be useful for defining spot colors with PDF_
makespotcolor( ).
len (C language binding only) Length of profilename (in bytes). If len = 0 a null-termi-
nated string must be provided.
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 (Only relevant for usage=outputintent) Control embedding or attaching of the output intent ICC pro-
file:
PDF/X-1a/3: If true, embed the ICC profile even if a standard output intent for PDF/X-1a/3 has been sup-
plied as profilename. Default: false
PDF/X-5n: if true, attach the ICC profile to the document as embedded file stream. Default: true
PDF 2.0: If true, embed the ICC profile; otherwise an external reference is created. Default: true
PDF/X-4p, PDF/X-5pg: the option is forced to false, i.e. the profile is referenced externally.
All other cases including PDF/X-4 and PDF/X-5g: the option is forced to true, i.e. the profile is embedded.
metadata (Option list; ignored for usage=outputintent in PDF/X-4p and PDF/X-5pg/5n) Supply metadata for the
profile (see Section 14.2, XMP Metadata, page 261)
urls (List of one or more strings; only for PDF/X-4p, PDF/X-5pg and PDF/X-5n, and required in these cases
except for PDF/X-5n with embedprofile=true) 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 as ICC-based color space for text or graphics, will be applied to an
image, used as default color space or as blending color space for a transparency group.
outputintent
The ICC profile specifies a PDF/A or PDF/X output intent.
Returns A profile handle which can be used in subsequent calls to PDF_load_image( ) or for set-
ting profile-related options. If errorpolicy=return the caller must check for a return value
of -1 (in PHP: 0) since it signals an error. The returned profile handle can not be reused
across multiple PDF documents. Depending on the intended use, the loaded profile
Details The named profile is searched according to the profile search strategy. Depending on
the intended usage ICC profiles must satisfy the conditions listed in the PDFlib Tutorial.
The sRGB profile is always available internally and must not be configured.
PDF/A The output intent can be set using this function or by copying an imported documents
output intent using PDF_process_pdi( ). If only device-independent colors are used in the
document no output intent is required.
PDF/X The output intent must be set either using this function or by copying an imported doc-
uments output intent using PDF_process_pdi( ).
PDF/X-1/3: One of the following standard output condition names can be used with-
out embedding the corresponding ICC profile:
CGATS TR 001, CGATS TR 002, CGATS TR 003, CGATS TR 005, CGATS TR 006,
FOGRA30, FOGRA31, FOGRA32, FOGRA33, FOGRA34, FOGRA35, FOGRA36, FOGRA38, FOGRA39
FOGRA40, FOGRA41, FOGRA42, FOGRA43, FOGRA44, FOGRA45, FOGRA46, FOGRA47,
IFRA26, IFRA30,
EUROSB104, EUROSB204,
JC200103, JC200104, JCN2002, JCW2003
PDF/X-4: an output intent profile must be available when generating the PDF and will
be embedded.
PDF/X-4/5: a CMYK output intent profile (i.e. loaded with usage=outputintent) cannot
be used for an ICCBased color space (i.e. loaded with usage=iccbased) in the same docu-
ment. This requirement is mandated by the PDF/X standard, and applies only to CMYK
profiles, but not to grayscale or RGB profiles. If you have a requirement to use the same
CMYK ICC profile as in the output intent also as ICCBased color (e.g. for tagging an im-
age), you can simply omit the ICC profile since PDF/X implies that the output intent
profile will be used anyway.
If one of the standard output intents listed above is to be used with PDF/X-4 or PDF/
X-5, the corresponding ICC profile must be configured with the ICCProfile resource.
PDF/X-4p/5pg/5n: The profile is not embedded, but a reference to an external profile
is created. The profile must be available when generating the PDF, and it must also be
available to the PDF consumer when viewing or printing the document.
PDF/X-5n: an n-colorant ICC profile (also called xCLR profile) must be supplied for
usage=outputintent. The externally referenced output intent ICC profile can optionally
be included in the document as attachment subject to the embedprofile option.
Scope If usage=outputintent the only allowed scope is document; the output intent should be
set immediately after PDF_begin_document( ).
If usage=iccbased the following scopes are allowed: document, page, pattern, template,
glyph.
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 a custom spot
color to be defined. This name is restricted to a maximum of 63 Unicode characters.
The special spot color name All can be used to apply color to all color separations,
which may be useful for painting registration marks. The spot color name None produc-
es no visible output on any color separation. The colorant names Cyan, Magenta, Yellow
and Black always refer to CMYK process colors.
Returns A spot color handle which can be used in subsequent calls to PDF_setcolor( ) or the
fillcolor and strokecolor options of PDF_set_graphics_option( ) and other functions. Spot
color handles can be reused across all pages, but not across documents.
Details If spotname is known in the internal color tables of PANTONE and HKS colors, and the
global spotcolorlookup option is true (which is default), the specified spot color name and
corresponding internal Lab alternate color values are used. Otherwise the color values of
the current fill color are used to define the appearance of a new spot color.
If spotname has already been used in a previous call to PDF_makespotcolor( ), the re-
turn value is the same as in the earlier call and does not use the current fill color as al-
ternate color.
This function can usually be avoided by supplying options of type Color directly. This
way definition and use of a spot color can be achieved in a single option list without the
need for passing spot color handles (see Table 1.2 for examples).
Table 8.2 lists relevant global options which affect the behavior of this function (see
Section 2.3, Global Options, page 25).
Scope page, pattern, template, glyph, document; the current fill color must not be a spot color,
DeviceN color, or pattern if a custom spot color is defined.
preserveold- (Boolean; deprecated) If false, old-style Pantone spot color names with the suffixes CV, CVV, CVU,
pantonenames CVC and CVP are converted to the corresponding new color names, otherwise they are preserved.
Default: false
spotcolorlookup (Boolean) If false, PDFlib does 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
Returns A DeviceN color space handle which can be used with the fillcolor and strokecolor options
of PDF_set_graphics_option( ) and other functions. The DeviceN color space handle can be
used until the end of the enclosing document scope.
By default, this function thrown an exception in case of an error. However, this be-
havior can be changed to an error return value of -1 (in PHP: 0) with the errorpolicy op-
tion.
PDF/A PDF/A-1/2/3: The color space supplied in the alternate option must adhere to the follow-
ing restrictions:
alternate=devicegray requires a grayscale, RGB or CMYK output intent or the
defaultgray option.
alternate=devicergb requires an RGB output intent or the defaultrgb option.
alternate=devicecmyk requires a CMYK output intent or the defaultcmyk option.
PDF/A-2/3: PDF_makespotcolor( ) must be called before PDF_create_devicen( ) for all
custom spot colors used in the DeviceN color space.
PDF/X The color space supplied in the alternate option must adhere to the following restric-
tions:
PDF/X-1a: Only alternate=devicecmyk or devicegray are allowed.
PDF/X-3: alternate=iccbased and lab require a grayscale, RGB or CMYK output intent.
PDF/X-3/4/5: alternate=devicegray requires a grayscale or CMYK output intent or the
defaultgray option.
alternate=devicergb requires an RGB output intent or the defaultrgb option.
alternate=devicecmyk requires a CMYK output intent or the defaultcmyk option.
PDF/X-4 and PDF/X-5g/pg: the colorspace suboption of the process option must match
the PDF/X output intent.
PDF/X-4/5: PDF_makespotcolor( ) must be called before PDF_create_devicen( ) for all
custom spot colors used in the DeviceN color space. In PDF/X-5n spot colors found in
the colorant list of the output intent are excluded from this requirement.
PDF/X-5n: The options subtype=nchannel and process are not allowed.
alternate (Keyword or option list; restrictions apply to PDF/A and PDF/X; required) Alternate color space for the De-
viceN color space. The following keywords can be supplied: devicegray, devicergb, devicecmyk, lab. Al-
ternatively, an option list with the following suboption can be supplied:
iccbased (Keyword or ICC profile handle) ICC profile specified by a handle or the keyword srgb. The ICC
profile must have been loaded with usage=iccbased.
names (List of name strings; required) List containing up to 32 colorant names (PDF 1.4: up to 8 colorant names).
All names must be different from each other except None which may appear more than once. The colo-
rant name All is not allowed. The colorant names Cyan, Magenta, Yellow and Black always refer to
CMYK process colors.
If subtype=nchannel the colorant name None is not allowed and the names of all spot colors used in the
DeviceN color space must be known to PDFlib, i.e. they must be included in the internal spot color data-
base or PDF_makespotcolor( ) must have been called earlier.
process (Option list; PDF 1.6 or above; required if subtype=nchannel and the names option includes one or more
process colors; not allowed for PDF/X-5n). Supported suboptions:
colorspace (Keyword; required) Process color space: devicegray, devicergb, or devicecmyk. PDF/X-4
and PDF/X-5g/pg: the color space must match the PDF/X output intent.
components
(List of strings; required) Names of all components of the process color space specified in the
colorspace suboption. The list of component names must not include the component name
None or built-in or custom spot color names. If the names option includes one or more process
colors these must match the names supplied here, but the names may differ from the usual
names (e.g. Process Cyan may be used instead of Cyan for colorspace=devicecmyk)
subtype (Keyword; PDF 1.6) Preferred treatment of the colorspace (default: devicen):
devicen The color space is treated as plain DeviceN color space.
nchannel (Not allowed for PDF/X-5n) The color space is treated as NChannel color space. In this case the
names option is subject to certain restrictions.
transform (String; required) PostScript code for the transform function of the DeviceN color space. The transform
function must convert N tint values in the range 0..1 to values in the alternate color space. The number of
output values must correspond to the number of components of the alternate color space. Since the Post-
Script code must be enclosed with brace characters { and }, and the option list string also requires sur-
rounding brace characters if it contains whitespace, the option value generally is enclosed by two pairs of
brace characters.
C++ Java C# int shading(String type, double x0, double y0, double x1, double y1,
double c1, double c2, double c3, double c4, String optlist)
Perl PHP int shading(string type, float x0, float y0, float x1, float y1,
float c1, float c2, float c3, float c4, string optlist)
C int PDF_shading(PDF *p, const char *type, double x0, double y0, double x1, double y1,
double c1, double c2, double c3, double c4, const char *optlist)
type The type of the shading; must be axial for linear shadings or radial for circle-like
shadings.
x0, y0 Starting point (for type=axial), or center of the starting circle (for type=radial).
x1, y1 Ending point (for type=axial), or center of the ending circle (for type=radial).
c1, c2, c3, c4 Color values of the shadings end color, interpreted in the color space of
the shadings start color. If the current fill color space is a spot color space c1 is ignored,
and c2 contains the tint value. The parameters c1, c2, c3, and c4 are ignored if the endcolor
or stopcolors option is supplied. Also, they cannot be used for shadings in a DeviceN col-
or space with N>4.
optlist Option list describing aspects of the shading according to Table 8.4. The follow-
ing options can be used:
antialias, boundingbox, end, endcolor, extend0, extend1, N, r0, r1, startcolor, stopcolors, type
Returns A shading handle that can be used in subsequent calls to PDF_shading_pattern( ) and
PDF_shfill( ) during the enclosing document scope.
Details This function creates a shading between the colors supplied in the startcolor and
endcolor options. If the option stopcolors is supplied, a shading is created between all en-
tries in the specified color list. All colors must be from the same color space and must
not use pattern color space. If spot colors are used the names of all spot colors must be
identical (see PDFlib Tutorial regarding the use of DeviceN color spaces for constructing
gradients between different spot colors).
As an alternative to the startcolor option the current fill color can be used. As an alter-
native to the endcolor option the values c1, c2, c3, and c4 can be used. As an alternative to
the combination of the startcolor and endcolor options the option stopcolors can be used.
In this case at least two colors must be specified.
antialias (Boolean) Specifies whether to activate antialiasing for the shading. Default: false
boundingbox (Rectangle) A rectangle defining the shadings 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 PDF_clip( ).
Default for PDF_shading( ): no clipping
Default for the shading graphics appearance option: the matchbox or table cell rectangle
end (List of 2 floats or percentages; not for PDF_shading( )) Coordinates of the ending point (for type=axial)
or a point on the ending circle (for type=radial), specified as percentages of the rectangles width and
height or in user coordinate. Default: {100% 100%}
endcolor (Color; ignored if stopcolors is supplied; one of the options endcolor and stopcolors is required for the
shading graphics appearance option) The shadings end color. Default for PDF_shading( ): the last color
provided in the stopcolors option if specified, otherwise the values supplied in the parameters c1, c2, c3,
and c4
extend0 (Boolean) Specifies whether to extend the shading beyond the starting point or circle. Default: false
extend1 (Boolean) Specifies whether to extend the shading beyond the ending point or circle. Default: false
N (Positive Float) Exponent for the color transition function. Default: 1
r1 (Float; only for type=radial) Radius of the ending circle. Default for PDF_shading( ): 0. Default for the
shading graphics appearance option: distance between start and end
start (List of 2 floats or percentages; not for PDF_shading( )) Coordinates of the starting point (type=axial) or
the center of the starting circle (type=radial), specified as percentages of the rectangles width and
height or in user coordinates. Default: {0% 0%}
startcolor (Color; ignored if stopcolors is supplied) The shadings start color. Default: the first color provided in the
stopcolors option if specified, otherwise the color specified in the option fillcolor for the matchbox or
table cell
stopcolors (List of pairs; one of the options endcolor and stopcolors is required for the shading graphics appear-
ance option) List of two or more colors for the shading. Each pair contains a float value or a percentage
for the position of an intermediate shading color in the inclusive interval 0...1 and the corresponding col-
or value. All color values must use the same color space. The positions must be sorted in ascending order,
but adjacent position values may be identical. If no value for position 0 is present the first list entry is
used; if no value for position 1 is present the last list entry is used. If this option is supplied the options
startcolor and endcolor, the parameters c1,...,c4 and the current fill color are ignored. Examples:
stopcolors={0 red 0.4 magenta 0.75 green 1 black}
stopcolors={0% {cmyk 1 0 0 0} 33% {cmyk 0 0.4 0.3 0}} 100% {cmyk 0 0 0.2 0.8}}
stopcolors={0% {spotname {PANTONE 123 U} 1} 100% {spotname {PANTONE 123 U} 1} }
type (Keyword) Shading type: axial for a linear shading or radial for a circle-like shading. Default: value of
the parameter type if present (only for PDF_shading( )), otherwise: axial
Returns A pattern handle that can be used in subsequent calls to PDF_setcolor( ) and for the op-
tions fillcolor and strokecolor during the enclosing document scope.
Details This function allows shadings to be used without involving PDF_shading_pattern( ) and
PDF_setcolor( ) or the options fillcolor and strokecolor. However, it works only for simple
shapes where the geometry of the object to be filled is the same as that of the shading it-
self. Since the current clip area will be shaded (subject to the extend0 and extend1 op-
tions of the shading) this function will generally be used in combination with PDF_
clip( ).
page, pattern (only if painttype=colored), template, glyph (only if the Type 3 fonts colorized
option is true)
width, height The dimensions of the patterns bounding box in the pattern coordinate
system.
Returns A pattern handle that can be used in subsequent calls to PDF_setcolor( ) and for the op-
tions fillcolor and strokecolor during the enclosing document scope.
Details This function starts the definition of a tiling pattern. It resets all text, graphics, and col-
or state parameters to their default values. The transform option defines the mapping of
the pattern coordinate system to the coordinate system of the page, template or glyph
description where the pattern is used. All text and graphics operations can be used on a
pattern description, but hypertext functions and functions for opening images, PDF
pages or graphics must be avoided. Color operations can be used depending on the
painttype option.
Bindings any except object; this function starts pattern scope, and must always be paired with a
matching PDF_end_pattern( ) call.
Table 8.5 Options for PDF_begin_pattern_ext( ); some options can also be used with PDF_begin_template_ext( ).
option description
boundingbox (Rectangle) Coordinates of the left, bottom, right, and top edges of the pattern cells bounding box. The
bounding box can be used to clip the pattern cell or template, or to create white space around the pat-
tern cell or template. Default: {0 0 width height}
painttype (Keyword) Indicates whether the pattern contains color specifications on its own or is used as a stencil
which will be colored with the current fill or stroke color when the pattern is used for filling or stroking
(default: colored):
colored The pattern is colored with one or more calls to PDF_setcolor( ) or the options fillcolor/
strokecolor. The pattern description may place images, PDF pages or graphics.
uncolored 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, but
not any images, placed PDF pages or graphics. Before using the pattern, PDF_setcolor( ) or the
options fillcolor/strokecolor must be called to set the current color with a color space
which is not based on a pattern.
tilingtype (Keyword) Controls adjustments to the spacing of pattern tiles (default: constantspacing):
constantspacing
Pattern cells will be spaced consistently, i.e. by a multiple of a device pixel. The PDF consumer
may need to distort the pattern cell slightly by making small adjustments to xstep, ystep,
and the transformation matrix.
nodistortion
The pattern cell will not be distorted, but the spacing between pattern cells may vary by as
much as one device pixel, both horizontally and vertically, when the pattern is painted. This
achieves the requested spacing on average but not necessarily for each individual pattern cell.
fastertiling
Pattern cells will be spaced consistently as with constanttiling but with additional
distortion permitted to enable a more efficient implementation.
topdown (Boolean) If true, the origin of the coordinate system at the beginning of the pattern or template defini-
tion is assumed in the top left corner of the bounding box and y coordinates increase downwards; other-
wise the coordinate system is used directly. Default: false
xstep (Float) Horizontal spacing between pattern cells in pattern coordinates. Default: width
ystep (Float) Vertical spacing between pattern cells in pattern coordinates. Default: height
Scope pattern; this function terminates pattern scope, and must always be paired with a
matching PDF_begin_pattern_ext( ) call.
9 Image, SVG and Template Functions
9.1 Images
Cookbook A full code sample can be found in the Cookbook topic images/starter_image.
imagetype The string auto instructs PDFlib to automatically detect the image file type
(not possible for CCITT and raw images which must always be loaded with the proper
image type). Explicitly specifying the image format with one of the strings bmp, ccitt, gif,
jbig2, jpeg, jpeg2000 (PDF 1.5 and above), png, raw, or tiff offers slight performance advan-
tages. Details of the image formats are discussed in the PDFlib Tutorial.
filename (Name string; will be interpreted according to the global filenamehandling op-
tion, see Table 2.3) 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 tries
to determine the appropriate file name suffix automatically; it appends all suffixes
from the following list (in both lowercase and uppercase) to the specified filename and
tries to locate a file with that name in the directories specified in the search path:
.bmp, .ccitt, .g3, .g4, .fax, .gif, .jbig2, .jb2, .jpg, .jpeg, .jpx, .jp2, .jpf, .j2k,
.png, .raw, .tif, .tiff
len (C language binding only) Length of filename (in bytes). If len = 0 a null-terminated
string must be provided.
optlist An option list specifying image-related properties according to Table 9.1. The
following options can be used:
> General options: errorpolicy (see Table 2.1) and hypertextencoding (see Table 2.3)
> 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: createtemplate, interpolate
> The following common XObject options can be used (see Table 9.11):
associatedfiles, georeference, iconname, layer, metadata, pdfvt, reference
> Option for analyzing the image without writing PDF output: infomode
> Options for processing the image data:
cascadedflate, ignoreorientation, page, passthrough
> Options for CCITT, JBIG2 and raw images according to Table 9.2:
bitreverse, bpc, components, copyglobals, height, imagehandle, inline, K, width
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,
PDF_fit_image( ) must be used. Opening the same image more than once per generated
document is not recommended because the actual image data will be copied to the out-
put document more than once. If the application cannot prevent this situation you can
remove redundant image data with the optimize option of PDF_begin_document( ).
PDFlib opens the image file with the provided filename, processes the contents, and
closes the file before returning from this call. Although images can be placed multiply
within a document with PDF_fit_image( ), the actual image file will not be kept open af-
ter this call.
PDF/VT This call may fail if the usestransparency=false option was specified in PDF_begin_
document( ), but the imported image contains transparency nevertheless.
Scope any except object; should be paired with a matching call to PDF_close_image( ).
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
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
clipping- (String; only for imagetype=tiff and jpeg; will be ignored if honorclippingpath=false) Read the path
pathname 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 Photo-
shop. Default: name of the path which is provided as clipping path in the image file
colorize (Spot or DeviceN color handle, or color defining a spot color; spot colors are ignored if the iccprofile op-
tion is provided) Colorize the image with a spot or DeviceN color. Colorizing an image with a spot color
works only with black and white or grayscale images. Colorizing an image with a spot color reverses the
polarity interpretation of the color values, i.e. color value zero results in the maximum amount of spot
color. You can compensate this effect with the invert option.
Colorizing an image with a DeviceN color works only with raw images. The number of image compo-
nents must match the number N of color components in the DeviceN color space. DeviceN color spaces
are always subtractive, i.e. color value 0 results in white.
create- (Boolean) If true, generate a PDF Image XObject embedded in a Form XObject (called template in PDFlib)
template instead of a plain Image XObject. This can be useful for creating templates for form field icons which con-
sist of an image only. A handle for the generated template is returned. Default: false
honor- (Boolean; only for imagetype=tiff and jpeg) Read the clipping path from the image file if available,
clippingpath and apply it to the image. Default: true
honor- (Boolean; only for imagetype=jpeg, jpeg2000, png, and tiff; forced to false if the colorize option is
iccprofile specified) Honor an ICC profile which may be attached to the image, either directly by embedding or indi-
rectly (e.g. via a reference in the Exif marker) and apply it to the image. Default: true
iccprofile (ICC handle or keyword) ICC profile which is applied to the image. The keyword srgb selects the sRGB col-
or space. Default: an embedded profile (or equivalent Exif information in the image file) if present in the
image and honoriccprofile=true.
ignoremask (Boolean; must be set to true in PDF/X-1/3 and PDF/A-1 for images with an internal alpha channel) Ignore
transparency information and alpha channels in the image. Default: false
ignore- (Boolean; only for imagetype=tiff and jpeg) Ignores any orientation information in the image. This
orientation may be useful for compensating incorrect orientation info in the image data. Default: false
infomode (Boolean) If true the image is loaded, but no pixel data is written to the output. Image properties can be
queried with PDF_info_image( ), but the image cannot be placed on a page with PDF_fit_image( ) or oth-
er functions. This option may be useful to check images without any side effects on the PDF output. If
false the pixel data is written to the PDF output immediately. 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) Invert the image (swap light and dark colors).
This can be used as a workaround for images which are interpreted differently by applications. Default:
false
mask (Boolean; only for bitmap images, i.e. one bit per pixel; forces ignoremask=true). Prepare the image for
use as a stencil mask. If the image itself is placed on the page black pixels are painted with the current fill
color while white pixels are ignored, i.e. the background remains unchanged. If the image is used to mask
another base image with the masked option the contents of the base image are shown where the mask is
black and ignored where the mask is white.
masked (Image handle; PDF/A-1 and PDF/X-1/3: only allowed with 1-bit masks; ignored if the image contains an
internal alpha channel and ignoremask=false) Handle for a grayscale image which is applied as alpha
channel to the current image. Bitmap masks must have been loaded with the mask option.
page (Integer; only for imagetype=gif, jbig2, and tiff; must be 1 if used with other formats) Extract the im-
age 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 image data.
TIFF images (default: true): If true, compressed TIFF image data is 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 images (default: false): If false, PDFlib transcodes JPEG image data for compatibility with Acro-
bat. If true, JPEG image data is directly copied to the PDF output. This option is ignored for multiscan
and certain CMYK JPEG images. Setting this option to true may speed up processing, but certain rare
JPEG flavors wont display correctly in Acrobat.
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, 8
or 16 (in PDF 1.4 the value 16 is not allowed)
components (Integer; only for imagetype=raw; required in this case unless the colorize option is provided) Number of
image components (channels); must be 1, 3, or 4. This option is ignored if the colorize option is supplied
since the number of components is determined from the color space.
copyglobals (Keyword; only for imagetype=jbig2) Specify which global segments in a JBIG2 stream will be copied to
the PDF. If the JBIG2 stream doesnt contain any global segments this option will not have any effect (de-
fault: 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.
height (Integer; only for imagetype=raw and ccitt; required in this case) Image height in pixels.
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 copy-
globals=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 han-
dle, 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; not allowed if one of the options iccprofile or
colorize is provided) If true, the image is written directly into the content stream of a page, pattern,
template, or glyph description. This option will implicitly call PDF_fit_image( ) and PDF_close _image( )
(see PDFlib Tutorial). Using this option is recommended only for bitmap glyphs of Type 3 fonts, and
should not be used in other situations. If this option is supplied PDF_close_image( ) must not be called.
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)
width (Integer; only for imagetype=raw and ccitt; required in this case) Image width in pixels
Details This function only affects PDFlibs 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 al-
ready been closed at the end of the corresponding PDF_load_image( ) call. An image han-
dle cannot be used any more after it has been closed with this function.
Scope any except object; must always be paired with a matching call to PDF_load_image( )
(unless the inline option has been used) or or PDF_begin_template_ext( ).
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.3:
adjustpage, gstate, ignoreclippingpath, ignoreorientation
> Option for abbreviated structure element tagging according to Table 14.5 (only al-
lowed in page scope): tag
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.
PDF/UA All raster images must be tagged as Artifact or Figure, either with the tag option or with a
preceding call to PDF_begin_item( ).
Scope page, pattern (only if the pattern's painttype is colored or the image is a mask), template,
glyph (only if the Type 3 fonts 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 PDF_close_image( ).
Table 9.3 Options for image, graphics, PDF page and template processing with PDF_fit_image( ), PDF_fit_graphics( ), PDF_
fit_pdi_page( ), PDF_fill_imageblock( ), PDF_fill_graphicsblock( ) and PDF_fill_pdfblock( )
option description
adjustpage (Boolean; only effective in page scope; not allowed if the topdown option has been supplied in PDF_be-
gin_page_ext( ); not for PDF_fill_*block( )) 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 PDF_create_gstate( ). The graphics state af-
fects all graphical elements created with this function. Default: no gstate (i.e. current settings will be
used)
ignore- (Boolean; only for TIFF and JPEG images) A clipping path which may be present in the image file will be
clippingpath ignored. Default: false, i.e. the clipping path will be applied
ignore- (Boolean; only for TIFF and JPEG images) Ignore any orientation information in the image. This may be
orientation useful for compensating wrong orientation info. Default: the value of the ignoreorientation option in
PDF_load_image( )
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 returns a handle to the object, or -1 (in PHP: 0) if the ob-
ject is not available. If the requested keyword produces text, a string index is returned,
and the corresponding string must be retrieved with PDF_get_string( ).
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 refer-
ence point is assumed to be {0 0}.
clippingpath Path handle of the images clipping path, or -1 (in PHP: 0) if no clipping path is present
checkcolorspace 1 if the image or template can safely be placed on the current page without risking a color-related
violation of PDF/A or PDF/X; 0 otherwise. This check takes into account the pages default color
space which is not checked when loading the image.
filename String index for the name of the image file (including a searchpath directory if applicable), or -1
for templates
iccprofile Handle for the ICC profile embedded in the image or -1 (in PHP: 0) if no profile is present
infomode 1 if the image has been loaded with the infomode option, 0 otherwise
mirroringx, Horizontal or vertical mirroring of the image (expressed as 1 or -1) according to the supplied op-
mirroringy tions
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 dont have any absolute
meaning.
strips Number of image strips (can be different from 1 only for certain multi-strip TIFF images)
transparent 1 if the image contains transparency (alpha channel with > 1 bit), otherwise 0. Transparency is as-
sumed to be present if an alpha channel was read from the original image file, or the image has
been loaded with the mask option.
xid (Only for PDF/VT) String index for the GTS_XID entry of the image or template, or -1 if no GTS_XID
value has been assigned. The GTS_XID string can be used in the CIP4/Summary/Content/
Referenced metadata property for DPM.
useembedded- (Boolean; ignored if createtemplate=false) If true the information of the image embedded in the tem-
image plate will be queried, otherwise the information of the template. If useembeddedimage=true some key-
words (e.g. dpi) are relevant only for the original image, but not for the generated template. In particu-
lar, the values should not be used for fitting the template created for the image. Default: false
type Type of vector graphics file. The keyword auto automatically determines the file
type. It is equivalent to svg which specifies SVG graphics.
filename (Name string; will be interpreted according to the global filenamehandling
global option, see Table 2.3) Name of the graphics file to be opened. This must be the
name of a disk-based or virtual file; PDFlib will not pull graphics from URLs.
If a file with the specified file name cannot be found PDFlib will try to determine the
appropriate file name suffix automatically; it will append all suffixes from the follow-
ing 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:
.svg, .svgz
len (C language binding only) Length of filename (in bytes). If len = 0 a null-terminated
string must be provided.
optlist An option list specifying graphics-related properties. The following options can
be used:
> General options: errorpolicy (see Table 2.1) and hypertextencoding (see Table 2.3)
> Font-related options according to Table 9.6:
defaultfontfamily, defaultfontoptions, fallbackfontfamily, fallbackfontoptions
> Size options according to Table 9.6:
fallbackheight, fallbackwidth, forcedheight, forcedwidth
> Image-related option according to Table 9.6: defaultimageoptions, fallbackimage
> Other SVG processing options according to Table 9.6: errorconditions, lang
> Special PDF features according to Table 9.6: devicencolors, templateoptions
Returns A graphics handle which can be used in subsequent graphics-related calls. If errorpolicy=
return the caller must check for a return value of -1 (in PHP: 0) since it signals an error.
The returned graphics handle can be reused across multiple PDF documents. If the func-
tion call fails you can request the reason of the failure with PDF_get_errmsg( ).
Details This function opens and analyzes a vector graphics file in one of the supported formats
as determined by the type parameter. The graphics data will be stored in memory until
the graphic is closed with PDF_close_graphics( ) or at the end of the PDFlib objects life-
time. This function does not have any visible effect on the PDF output. In order to actu-
ally place the imported graphics somewhere in the generated document, PDF_fit_
graphics( ) must be used. Opening the same graphics more than once per generated doc-
ument is not recommended because the graphics data will be copied to the output doc-
ument multiply.
PDF/A All required fonts must be embedded. If colors are specified as device-gray, device-rgb, or
device-cmyk these are subject to the PDF/A color space requirements (see PDF_set_
color( )).
PDF/A-1: graphics with transparency are not allowed.
PDF/A-2a/3a: if the graphics contain text with PUA characters, the tag option with the
ActualText suboption must be provided.
PDF/X All required fonts must be embedded. If colors are specified as device-gray, device-rgb, or
device-cmyk these are subject to the PDF/X color space requirements (see PDF_set_
color( )).
PDF/X-1a: this function must not be called.
PDF/X-3: graphics with transparency are not allowed.
PDF/VT This call may fail if the usestransparency=false option was specified in PDF_begin_
document( ), but the imported graphics contains transparency nevertheless.
PDF/UA Graphics should be tagged as Figure or Artifact. All required fonts must be embedded (see
above). If the graphics contain text with PUA characters, the tag option with the
ActualText suboption must be provided.
defaultfont- (Option list) Font loading options according to Table 4.2. When a font is required for text in a graphics file
options and this font has not already been loaded earlier, the options specified here are supplied to PDF_load_
font( ). Default: {subsetting embedding skipembedding={latincore standardcjk} }
defaultimage- (Option list) Image loading options according to Table 9.1. When an embedded or external image is pro-
options cessed, the options specified here are supplied to PDF_load_image( ). Default: { }
devicencolors (List of DeviceN color handles) Supply handles to DeviceN color spaces for use in the loaded SVG graphics.
The specified DeviceN color spaces are applied to device-nchannel colors in the SVG graphics according
to the number of colorants.
error- (Option list) List of conditions which trigger an error (default: empty):
conditions attributes (List of strings) An error occurs if one of the specified SVG attributes is present, but is not
supported in PDFlib (see PDFlib Tutorial for a list of unsupported attributes). By default,
unsupported attributes are ignored.
elements (List of strings) An error occurs if one of the specified SVG elements is present, but is not
supported in PDFlib (see PDFlib Tutorial for a list of unsupported elements). By default,
unsupported elements are ignored.
references (List of keywords) An error occurs if one of the following types of reference cannot be resolved
or executed (by default all types except image are silently ignored and a warning is emitted):
image reference to an image or graphics file; see option fallbackimage for default be-
havior
internal internal reference to an SVG element
external reference to files other than image or graphics
fontfamily reference to a font family
font reference to a full font name specified via font family, weight and style
fallback- (Name string) Name of the font family which is used to create a fallback font for each font, in addition to
fontfamily the fallback fonts which may have been specified in the graphics file. Default: empty
fallback- (Option list) Options which will be applied to the fallback fonts created via the fallbackfontfamily op-
fontoptions tion. The following options according to Table 4.3, page 69, can be used: fontsize, forcechars,
textrise. Default: empty
fallback- (Float; ignored if forcedheight is supplied) Height of the SVG graphics (in user coordinates) for the fitting
height process. Default: height provided in the SVG viewBox attribute if present, otherwise 1000
fallback- (Option list) Specify how to visualize the space reserved for the fitbox of a graphics or image element if
image the element is not available. If this option is supplied without any suboptions a gray semi-transparent
checkerboard is painted (default: no fallback display)
fillcolor (sRGB Color or keyword) Color used to fill the area with a checkerboard pattern (if gridsize >
0) where half of the squares are painted with the specified color and the other half of the
squares is transparent, or color used to fill the area with solid color if gridsize=0. The
keyword none means that the area will not be filled. Default: LightGrey
gridsize (Float or percentage) Width of a square in the checkerboard pattern in default coordinates or
as a percentage of the width of the fitbox. Percentages are rounded so that an integer num-
ber of squares fits into the area. gridsize=0 means that the area is filled with solid color
instead of a checkerboard pattern. Default: 10
image (Image or template handle) Image or template which will be placed with fitmethod=entire
into the fitbox. Default: no image or template
opacity (Float in the range 0..1 or percentage) Opacity of the checkerboard squares or the interior of
the area. Default: 0.5
strokecolor (sRGB color or keyword) Color used to stroke the border area and a cross inside the area. The
keyword none means that the border and cross is not stroked. Default: Red
fallback- (Float; ignored if forcedwidth is supplied) Width of the SVG graphics (in user coordinates) for the fitting
width process. Default: width provided in the SVG viewBox attribute if present, otherwise 1000
forcedheight (Float) The height of the SVG graphics (if present) is ignored and the specified value in the default coordi-
nate system is applied instead. Default: height of the graphics
forcedwidth (Float) The width of the SVG graphics (if present) is ignored and the specified value in the default coordi-
nate system is applied instead. Default: width of the graphics
lang (String) Natural language for the graphics file which can be used e.g. in an SVG switch element. The for-
mat of the language specification is identical to the lang option of PDF_begin_document( ) (see Table
3.3). Default: the language identifier found in the LANG environment variable.
template- (Option list) Create a template (PDF Form XObject) according to the supplied option list. This option is
options recommended if the graphics will be placed more than once, or if specific template features are required
(e.g. for PDF/VT). The supplied option list (which may be empty) is used for PDF_begin_template_ext( ).
The following common XObject options can be used (see Table 9.11): associatedfiles, iconname, layer,
metadata, pdfvt, transparencygroup.
Width and height of the template are determined based on the size of the graphics. The template is writ-
ten to the PDF output in PDF_close_graphics( ) or at the end of the document (the latter only if PDF_fit_
graphics( ) was called at least once for this graphics file).
Details PDFlibs associated internal graphics structure will be deleted. If the templateoptions op-
tion was specified in PDF_load_graphics( ) the corresponding PDF template will be creat-
ed before closing the graphic. If the graphic has been opened from file, the actual graph-
ics file is not affected by this call since it has already been closed at the end of the
corresponding PDF_load_graphics( ) call. A graphics handle cannot be used any more af-
ter it has been closed with this function.
Scope any; object scope is not allowed if templateoptions was specified in the corresponding
call to PDF_load_graphics( ) and the graphics was placed at least once; must always be
paired with a matching call to PDF_load_graphics( ).
x, y The coordinates of the reference point in the user coordinate system where the
graphic will be placed.
optlist An option list specifying graphics fitting and processing options. The following
options are supported:
> Fitting options according to Table 6.1:
boxsize, fitmethod, matchbox, orientate, position, refpoint, rotate, scale, showborder
> Options for graphics processing according to Table 9.3:
adjustpage, gstate
> Option for processing interactive links in the graphics according to Table 9.7:
convertlinks
> Option for abbreviated structure element tagging according to Table 14.5 (only al-
lowed in page scope): tag
PDF/UA Graphics containing vector graphics or raster images must be tagged as Figure or Arti-
fact.
Scope page, pattern (only if the patterns painttype is 1), template, glyph (only if the Type 3 fonts
colorized option is true); this function can be called an arbitrary number of times on
arbitrary pages as long as the graphics handle has not been closed with PDF_close_
graphics( ).
convertlinks (Boolean) If true, interactive links in the graphics file are converted to interactive Link annotations in
PDF. Regardless of this setting links are not created in the following situations (default: true):
> this function is called in a scope other than page
> the templateoptions option was supplied in PDF_load_graphics( )
> Tagged PDF mode: the currently active structure item is an Artifact;
> PDF/X: the link annotation is located inside the BleedBox (or TrimBox/ArtBox if no BleedBox is present).
optlist An option list specifying options for PDF_fit_graphics( ). Options which are not
relevant for determining the value of the requested keyword will be ignored.
Returns The value of some graphics property as requested by keyword. If a geometrical property
is requested outside of a page, this function returns -1 (in PHP: 0). If an object handle is
requested this function returns a handle to the object, or -1 (in PHP: 0) if the object is not
available. If the requested keyword produces text, a string index is returned, and the
corresponding string must be retrieved with PDF_get_string( ).
Scope any
description String index for the contents of the desc element of the outermost svg element if present, or of
the outermost g element if present, or -1 otherwise. The string may contain markup.
filename String index for the name of the graphics file (including a searchpath directory if applicable)
fittingpossible Check whether the graphics could be placed with PDF_fit_graphics( ) in the current context. The
value 1 is returned if the graphics can be placed. The value 0 is returned if fitting fails (i.e. PDF_fit_
graphics( ) would throw an exception) for one of the following reasons:
> An internal problem in the graphics file.
> A conflict with current standards requirements (e.g. transparency not allowed, font must be
embedded but no font file available)
If 0 is returned the nature of the problem can be queried with PDF_get_errmsg( ). Since the result
is valid only for the current context this check should be applied immediately before attempting
to place a page.
graphicswidth, Width and height of the graphic in the default coordinate system according to the information in
graphicsheight the graphics file. If no values are available in the graphics file, 0 will be returned.
metadata String index for the contents of the metadata element of the outermost svg element, or -1 if this
element is not present. The string may contain markup.
title String index for the contents of the title element of the outermost svg element if present, or of
the outermost g element if present, or -1 otherwise. The string may contain markup.
type String index for the type (format) of the graphics: always svg
xid (Only for PDF/VT) String index for the GTS_XID entry of the template created for graphic, or -1 if
no template was created or no GTS_XID value has been assigned to the template. The GTS_XID
string can be used in the CIP4/Summary/Content/Referenced metadata property for DPM.
width, height The dimensions of the templates bounding box in points. The width
and height parameters can be 0. In this case they must be supplied in PDF_end_template_
ext( ) or with the boundingbox option. Ultimately both values must be different from 0
unless the postscript or watermark option is specified.
Returns A template handle which can be used in subsequent calls to PDF_fit_image( ), PDF_info_
image( ), and various options of other functions, or -1 (in PHP: 0) in case of an error.
Details This function resets all text, graphics, and color state parameters to their default values,
and establishes a coordinate system according to the topdown option. Hypertext
functions must not be used during a template definition, but all text, image, graphics,
and color functions can be used.
Template size: in the simplest case width and height are supplied in PDF_begin_
template_ext( ). However, if they are not yet known they can also be specified as zero. In
this case they must be supplied in the corresponding call to PDF_end_template_ext( ).
If the reference option has been supplied the size is determined automatically from
the size of the target PDF page, and no values must be specified. However, if width and
height are specified nevertheless they will be used, but are automatically adjusted to the
same aspect ratio as the target page.
If the watermark option is supplied, the template defines a watermark which can be
edited or removed in Acrobat. In this case only PDF_fit_textline( ) can be used in the tem-
plate, as well as functions which are allowed in document or object scope. The bounding
box of the Textline defines the width and height of the template; the width and height
parameters and the options boundingbox and transform are ignored. The bounding box
of a watermarks Textline is calculated from its rotation angle and size, especially the
option boxheight. A Textline used as watermark has a default boxheight of {ascender
descender} instead of {capheight 0} (see Table 6.4, page 131). The parameters x and y of PDF_
fit_textline( ) are ignored.
The following rules must be obeyed regarding the watermark templates contents:
> PDF_fit_textline( ) must be called exactly once, and its text parameter must not be
empty.
> Only the following color spaces can be used for the fillcolor and strokecolor options:
gray, iccbasedgray, iccbased with a grayscale or RGB profile, rgb (or an HTML color
name or hexadecimal RGB value), iccbasedrgb
Scope any except object; this function starts template scope, and must always be paired with a
matching PDF_end_template_ext( ) call.
watermark (Option list; can only be used once per document) Create an editable watermark according to the options
in Table 9.10
width, height The dimensions of the templates bounding box in points. If width or
height is 0, the value supplied in PDF_begin_template_ext( ) are used. Otherwise the val-
ues supplied in the boundingbox option and the width and height parameters of PDF_
begin_template_ext( ) are overridden. However, if the reference or watermark option has
been specified in the corresponding call to PDF_begin_template_ext( ), the values sup-
plied to PDF_end_template_ext( ) are ignored.
endpage (Integer or keyword) Number of the last page with a watermark, or the keyword last for the final page.
Default: last
fixedprint (Boolean) Keep position and size of the watermark constant when printing on different page sizes. De-
fault: false
horizalign (Keyword) One of keywords left/center/right to specify the relative horizontal position of the water-
marks bounding box on the page1. Default: center
horizshift (Float) Shift from the relative horizontal position in points. Default: 0
location (Keyword) Specify whether the watermark appears behind or on top of other page contents (default:
ontop):
behind The watermark appears behind the page contents. If location=behind is supplied all future
calls to PDF_begin_page_ext( ) in the same document must supply a value different from 0
for the width and height parameters.
ontop The watermark appears on top of the page contents.
onprint (Boolean; requires PDF 1.5; the value false is not allowed in PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) If true,
the watermark is shown when printing the page. Default: true
onscreen (Boolean; requires PDF 1.5; the value false is not allowed in PDF/A-2/3, PDF/X-4/5, and PDF/UA-1) If true,
the watermark is shown when displaying the page on screen. Default: true
opacity (Float or percentage; must have the value 1 in PDF/A-1 and PDF/X-1/3) Opacity value for painting the wa-
termark on the page. Default: 1
pagessubset (Keyword) Select a subset of the pages in the range specified by startpage and endpage (default: all):
all Select all pages in the range.
even Select all pages in the range with an even number.
odd Select all pages in the range with an odd number.
scale (Float, percentage, or keyword) Scaling factor of the watermarks bounding box relative to the target
page. Scaling preserves the aspect ratio of the Textlines bounding box (default: 1). Supported keyword:
none No scaling
startpage (Integer) Number of the first page with a watermark (the first page has number 1). If the next page, i.e.
the page created with the next call to PDF_begin_page_ext( ), has a higher number than the one speci-
fied in startpage, the value is increased to the next page. Default: the next page
vertalign (Keyword) One of keywords bottom/center/top to specify the relative vertical position of the water-
marks bounding box on the page1. Default: center
vertshift (Float) Shift from the relative vertical position in points. Default: 0
1. The page size is defined by the CropBox if present, otherwise the MediaBox.
Scope template; this function terminates template scope, and must always be paired with a
matching PDF_begin_template_ext( ) call.
The following XObject options are available (see Table 9.11 for details):
associatedfiles, defaultcmyk, defaultgray, defaultrgb, georeference, iconname, layer, metadata,
pdfvt, reference, transparencygroup
PDF/X Some options are restricted. The reference option is relevant for PDF/X-5g/5pg.
PDF/VT The pdfvt option is relevant for PDF/VT.
Table 9.11 Common XObject options for PDF_load_image( ), PDF_open_pdi_page( ), and PDF_begin_template_ext( ) as
well as PDF_load_graphics( ) with the templateoptions option
option description
associatedfiles (List of asset handles; only for PDF 2.0 and PDF/A-3) Asset handles for associated files. The files must have
been loaded with PDF_load_asset( ) and type=attachment.
defaultgray (ICC handle or keyword; not for PDF_load_image( ) and PDF_open_pdi_page( ); not for PDF/X-1a) Set a
defaultrgb default gray, RGB, or CMYK color space for the template according to the supplied ICC profile handle. The
defaultcmyk option defaultrgb also supports the keyword srgb. The specified color space is used to map device-de-
pendent gray, RGB, or CMYK colors on the template (but not on nested templates).
georeference (Option list; PDF 1.7ext3; only for PDF_load_image( )) Description of an earth-based coordinate system
associated with the XObject to use for geospatial measuring; see Section 12.7, Geospatial Features,
page 243, for details.
iconname (Hypertext string) Attach a name to the XObject so that it can be referenced via JavaScript, e.g. to use the
XObject as an icon for form fields.
PDF_load_image( ): this option will be ignored if inline=true; forces createtemplate=true
layer (Layer handle; PDF 1.5) Layer to which the XObject will belong unless another layer has been activated
with PDF_begin_layer( ) prior to placing the object. Calling PDF_begin_layer( ) to activate a layer before
placing the XObject overrides the objects layer option. Call PDF_end_layer( ) before placing the object to
make sure that the objects layer option will not be overridden.
metadata (Option list) Metadata for the XObject (see Section 14.2, XMP Metadata, page 261).
pdfvt (Option list; only for PDF/VT) PDF/VT suboptions for the XObject according to Table 9.14
reference (Option list; not for PDF_load_image( ); not allowed in PDF/A, PDF/X-1a/3/4, PDF/X-5n, PDF/VT-1, and
PDF/UA-1; not available in PDFlib source code packages) Reference a page in an external PDF (the tar-
get document). The page opened with PDF_open_pdi_page( ) or the template created with PDF_begin_
template_ext( ) or the graphics loaded with PDF_load_graphics( ) will be used as proxy for this reference.
Depending on viewer configuration and availability of the target PDF either the internal proxy or the ex-
ternal target will be displayed and printed. See Table 9.13 for available suboptions.
PDF_open_pdi_page( ): The target PDF 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 is determined according to the pdiusebox suboption of the reference op-
tion. It can be retrieved with the imagewidth/imageheight keywords of PDF_info_image( ). 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 can be placed at the same location on
the page.
PDF_begin_template_ext( ): If width and height have been supplied with the value 0 the template size
can be retrieved with the imagewidth/imageheight keywords of PDF_info_image( ). If width and height
have been supplied with values different from 0, the following suboptions can also be used (see Table
6.1): fitmethod, position.
PDF_load_graphics( ): the graphic will be adjusted to the size of the target page; the following subop-
tions can also be used (see Table 6.1): fitmethod, position.
PDF/X-5g/5pg: the target must conform to one of the following standards: PDF/X-1a:2003, PDF/X-3:2003,
PDF/X-4, PDF/X-4p, PDF/X-5g, or PDF/X-5pg, and must have been prepared for the same output intent.
PDF/VT-2: the target must conform to one of the following standards: PDF/X-1a:2003, PDF/X-3:2003,
PDF/X-4, PDF/X-4p, or PDF/VT-1 and must have been prepared for the same output intent.
See the PDFlib Tutorial regarding the required Acrobat configuration for viewing referenced pages.
transform (Transformation list according to Table 9.12; ignored if the cloneboxes option of PDF_open_pdi_page( )
has been supplied for the page; not for PDF_load_image( )) A list which defines the transformation that
maps the page, pattern, or template coordinate system to the default coordinate system of the target
page, template or glyph description where the page/pattern/template is used. The concatenation of the
page, pattern or template matrix with that of the target page, template or glyph description establishes
the coordinate system within which all graphics objects in the page, pattern or template are interpreted.
The list contains pairs of a keyword and a float list according to Table 9.12 where each pair defines a
transformation. The interpretation and length of the number list depends on the transformation. The
transformations are applied in the specified order. The elements within a pair may be separated with
equals signs =. Default: no transformations are applied.
Example: transform={rotate=45 translate={100 0}}
transparency (Option list or keyword; not for PDF_load_image( ); not for PDF/A-1 and PDF/X-1a/3; restrictions apply to
group PDF/A-2/3 and PDF/X-4/5) Create a transparency group for the imported page or graphics or the generat-
ed template. The following keywords are supported (default: auto):
auto If an imported page contains a transparency group it is copied to the generated Form XOb-
ject. However, if it conflicts with a CMYK ICC profile in a PDF/X-4 output intent it is ignored (in
this case a transparency group isnt required anyway).
For graphics and templates no transparency group is created.
none Dont create any transparency group, even for imported pages which already contain one.
The following suboptions can be used to explicitly create a transparency group:
colorspace (Keyword or ICC profile handle; required with a value different from none if the template is
used for the softmask option of PDF_create_gstate( ) with type=luminosity) Blending color
space; see Table 3.9 (option transparencygroup) for supported keywords and restrictions
(default: none).
isolated (Boolean) Specifies whether the transparency group is isolated. Default: false
knockout (Boolean) Specifies whether the transparency group is a knockout group. Default: false
align Rotate by the direction vector {dx dy}. The vector {0 0} implies no rotation.
matrix Specify a non-degenerate transformation matrix with six values {a b c d e f}.
rotate Rotate by {phi}, where the angle phi is measured in degrees counterclockwise from the positive x axis
of the pattern, page or template coordinate system.
skew Skew (shear) by {alpha beta}, where alpha is measured in degrees counterclockwise from the positive x
axis of the pattern coordinate system and beta is measured clockwise from the positive y axis. Both an-
gles must not be odd multiples of 90.
translate Translate by {tx ty}. Since translations are compensated when placing the page, this translation
doesnt have any visible effect for imported PDF pages.
Table 9.13 Suboptions for the reference option in PDF_begin_template_ext( ), PDF_open_pdi_page( ) as well as PDF_
load_graphics( ) with the templateoptions option
option description
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.
hypertext- (Keyword) Specifies the encoding for the pagelabel option. An empty string is equivalent to unicode. De-
encoding fault: value of the global hypertextencoding option
pagelabel (Hypertext string; must not be combined with pagenumber) Page label of the page to be referenced
pagenumber (Integer) 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; forced to media in PDF/X-5g/5pg) Specifies which box dimensions will be used for determining
the size of the target page. Default: media in PDF/X-5g/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; forced to true in PDF/X-5g/5pg) If true, PDFlib will use the targets 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 iden-
tical page boxes and rotation entries. Default: true
target (PDF document handle) Handle to the target document retrieved with PDF_open_pdi_document( ). The
target PDF must have been opened with the repair=none option and without the password option. Sup-
plying 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.
environment (Hypertext string; required if scope=stream or scope=global) Specifies a PDF/VT environment context,
i.e. an identifier that can be used by a PDF/VT processor to provide a management interface for manag-
ing related XObjects. For example, the customer name or job name could be used to identify the environ-
ment.
scope (Keyword) PDF/VT scope (not related to PDFlib function scope) of the XObject (default: unknown):
unknown The scope of the XObject is not known.
singleuse The XObject is referenced only once in the PDF/VT file.
record (Only allowed if the recordlevel option for PDF_begin_document( ) has been specified) The
XObject is referenced more than once in the pages belonging to a single record, but is not
referenced within other records.
file The XObject is referenced more than once in the PDF/VT file. If the recordlevel option has
been supplied, scope=file should only be used if the XObject is used in more than one record
(and scope=record otherwise).
stream (Requires the environment option; only allowed for documents which will be included in a
PDF/VT-2s stream) The XObject or an equivalent XObject is referenced more than once in the
PDF/VT-2s stream containing the PDF/VT file.
global (Requires the environment option) The XObject or an equivalent XObject is referenced in more
than one PDF/VT file or PDF/VT-2s stream.
xid (String; only for PDF_begin_template_ext( ) since identifiers will automatically be created for all other
types of XObjects) Unique identifier for the Form XObject created for the template. It is strongly recom-
mended to provide this identifier in the format suggested in ISO 16612-2:2010, section 6.7.2, i.e. a URI with
the uuid scheme and 128-bit number according to RFC 4122. The identifiers should be identical for tem-
plate definitions which create equivalent PDF Form XObjects according to PDF/VT (i.e. templates which
create the same visual output). Templates which are not equivalent must have different identifiers or no
identifier at all.
It is strongly recommended to supply the xid option for templates with scope=stream or scope=global
to allow caching of Form XObjects across documents.
Example xid in the recommended format: uuid:1228c416-48f2-e817-ad69-8206e41dca2d
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 op-
tion, see Table 2.3) Name of the PDF file.
len (C language binding only) Length of filename (in bytes). If len = 0 a null-terminated
string must be provided.
Returns A PDI document handle which can be used for processing individual pages of the docu-
ment or for querying document properties. A return value of -1 (in PHP: 0) indicates that
the PDF document couldnt 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
PDF_get_errmsg( ).
The error behavior can be changed with the errorpolicy option.
Details By default, the document is rejected if at least one of the following conditions is true:
> The document is damaged and couldnt be repaired (or repair=none was specified).
> The document is encrypted, but the corresponding master password has not been
supplied in the password option. The shrug option can be used to enable page import
from protected documents under certain conditions (see PDFlib Tutorial).
Except for the first reason, the infomode option can be used to open the document nev-
ertheless. This may be useful to query information about the PDF using the PDF_pcos_
get_*( ) functions, such as encryption, document info fields, etc.
Scope any; in object scope a PDI document handle can only be used in the PDF_pcos_get_*( )
functions.
checktags (Keyword) Specifies whether the structure element nesting rules (see PDFlib Tutorial) are checked in PDF_
open_pdi_page( ) for imported structure elements. Supported keywords (default: none):
none Tag nesting rules are not enforced. This setting is default since many real-world documents
violate structure element nesting rules, and couldnt otherwise be imported.
relaxed Similar to strict except that a few rules are not enforced (see PDFlib Tutorial).
strict If an imported tag violates the nesting rules the call to PDF_open_pdi_page( ) will fail.
checkoutput- (Boolean, only relevant for PDF/A and PDF/X) If true, the number of color components of an output in-
intentprofile tent is checked against the number of components in the associated ICC profile. This guards against in-
consistent input documents. Setting this option to false reduces memory requirements, but should be
used only if the input documents are known to contain consistent output intent profiles. Default: true
infomode (Boolean) If true, the document will be opened such that information can be queried with the pCOS in-
terface, but the pages can not be imported into the current output document with PDF_open_pdi_
page( ). The following documents can be opened when infomode=true: encrypted PDFs where the pass-
word is not known (exception: PDF 1.6 and above documents created with the Distiller setting Object
Level Compression: Maximum). 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 z/OS) at the expense of memory usage. If
false, individual parts of the document will be read from disk as needed. Default: false
parentlayer (Layer handle; ignored if the input document doesn't contain any layers or uselayers=false) Insert all
layer definitions imported from the document as children of the specified layer. If the specified layer has
been activated anywhere in the output document it is used as parent; otherwise it is used as title (separa-
tor) only. Default: no parent layer
parenttitle (Hypertext string; ignored if the input document doesn't contain any layers or uselayers=false) Add a
title layer which does not directly control the visibility of page contents, but serves as a hierarchical sep-
arator for the imported layer definitions. Default: no parent title
password (String) 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. The shrug option can be used to import pages from protected documents under cer-
tain conditions (see PDFlib Tutorial).
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):
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.
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
shrug (Boolean) If true, the shrug feature will be activated to enable page import from protected documents
under certain conditions (see PDFlib Tutorial). By using the shrug option you assert that you honor the
PDF document authors rights. Default: false
uselayers (Boolean; only relevant if the input contains layers) If true, all layer definitions used on any of the im-
ported pages are imported. This option affects only layer definitions, but not the actual layer contents
since PDI always imports the contents of all layers on a page. Default: true
usetags (Boolean; only relevant for tagged PDF input and output; must be true in PDF/UA-1 mode) If true, the
structure hierarchy of the imported document is read so that structure element tags can later be import-
ed along with the pages. Default: true
Open a PDF document from a custom data source and prepare it for later use.
opaque A pointer to some user data that might be associated with the input PDF docu-
ment. This pointer will be passed as the first parameter of the callback functions, and
can be used in any way. PDI will not use the opaque pointer in any other way.
readproc A callback function which copies size bytes to the memory pointed to by
buffer. If the end of the document is reached it may copy less data than requested. The
function must return the number of bytes copied.
seekproc A callback function which sets the current read position in the document.
offset denotes the position from the beginning of the document (0 meaning the first
byte). If successful, this function must return 0, otherwise -1.
optlist An option list specifying PDF open options; all options of PDF_open_pdi_
document( ) are supported.
Returns A PDI document handle which can be used for processing individual pages of the docu-
ment or for querying document properties. A return value of -1 indicates that the PDF
document couldnt 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 PDF_get_
errmsg( ).
Details This is a specialized interface for applications which retrieve arbitrary chunks of PDF
data from some data source instead of providing the PDF document in a disk file or in
memory.
Close all open PDI page handles, and close the input PDF 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
pagenumber The number of the page to be opened. The first page has page number 1.
Returns A PDI page handle which can be used for placing pages with PDF_fit_pdi_page( ). A return
value of -1 (in PHP: 0) indicates that the page couldnt be opened. If the function call fails
you can request the reason of the failure with PDF_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 PDF_open_pdi_document( ), the handle
can not be used with PDF_open_pdi_page( ).
The error behavior can be changed with the errorpolicy option.
Details This function copies all data comprising the imported page to the output document,
but does not have any visible effect on the output. In order to actually place the import-
ed page somewhere in the generated output document, PDF_fit_pdi_page( ) must be
used. This function fails in the following cases:
> The document uses a PDF version which is incompatible to the current PDF docu-
ment. For PDF versions up to PDF 1.6 all versions up to and including the same ver-
sion are compatible. PDF 1.7, PDF 1.7ext3, PDF 1.7ext8 and PDF 2.0 are all compatible to
each other as far as page import with PDI is concerned. However, in PDF/A mode the
input PDF version number is ignored since PDF version headers must be ignored in
PDF/A.
> The document is not compatible to the current PDF/A, PDF/X, PDF/VT or PDF/UA
output conformance level, or uses an incompatible output intent.
> If the document contains an inconsistent PDF/A or PDF/X output intent no pages
can be imported.
In order to get more detailed information about a problem related to PDF import (bad
PDF data, etc.) you can call PDF_get_errmsg( ).
If the imported page contains referenced XObjects, PDF_open_pdi_page( ) copies 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 ex-
actly once.
PDF/X The imported document must be compatible to the current PDF/X output conformance
level (see PDFlib Tutorial for details), and must use the same output intent as the gener-
ated document.
PDF/X-4/5: the imported page is rejected if it uses a CMYK ICC profile which is identi-
cal to the generated documents output intent profile.
PDF/VT The imported document must be compatible to the current PDF/VT output level (see
PDFlib Tutorial for details), and must use the same output intent as the generated docu-
ment. Document Part Metadata (DPM) in the imported document is not imported. This
call may fail if the usestransparency=false option was specified in PDF_begin_document( ) ,
but the imported page contains transparency nevertheless.
PDF/UA The imported document must conform to PDF/UA. The rolemap of the imported docu-
ment must be compatible with the mapping provided by the rolemap option of PDF_
begin_document( ) (see PDFlib Tutorial for details). This means that custom element
types must not be mapped to different standard types by the rolemap option (or previ-
ously imported documents) and the rolemap of the imported document.
The heading structure of the imported page must be compatible with the structure
type of the generated document, i.e. if structuretype=weak only H1, H2, etc. (but not H)
must be used on the page; if structuretype=strong only H (but not H1, H2, etc.) must be
used on the imported page. Pages with both numbered and unnumbered headings are
rejected.
checktrans- (Boolean, only relevant for PDF/A and PDF/X) If true and the imported page contains a transparency
groupprofile group, its color space is checked for consistency and compatibility with the generated output document.
This guards against inconsistent input documents and color space conflicts which could lead to non-con-
forming PDF/X or PDF/A output. Setting this option to false reduces memory requirements, but should
be used only if the imported page is known to contain a conforming transparency group (if any). Default:
true
clippingarea (Keyword) Specify which of the page boxes of the imported page will be used for clipping. Content out-
side the specified area will not be visible after placing the imported page on a new page. Supported key-
words (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 boxexpand, forcebox, or pdiusebox is supplied; must match the cloneboxes op-
tion in PDF_fit_pdi_page( )) If true, the page will be prepared for box cloning with the cloneboxes op-
tion of PDF_fit_pdi_page( ). Default: false
forcebox (Rectangle) Force the page box to the specified values. This option overrides the pdiusebox and
boxexpand options. It may be used to place content which is located outside of all page boxes of the im-
ported page. The values must be chosen carefully if the imported page contains a /Rotate key. The
boxexpand option is preferable since it works regardless of any /Rotate key. Default: the box selected
with the pdiusebox option
ignore- (Boolean) If true, the PDF version number of the input PDF document is ignored, i.e. pages from docu-
pdfversion ments with a higher PDF version than the current PDF output document can be imported. This may be
useful for PDF documents with a higher PDF version which are nevertheless fully compatible to PDF 1.7.
The user is responsible for making sure that the imported pages do not violate the PDF output compati-
bility level. Default: false in general, but true in PDF/A and PDF/X mode
pdiusebox (Keyword; not allowed if cloneboxes is supplied) Specifies which box dimensions will be used for deter-
mining an imported pages size. The box size will be used for scaling operations in PDF_fit_pdi_page( ).
This box will also determine the visible contents of the page unless modified with the clippingarea op-
tion. Default: crop.
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
usetags (Boolean; only relevant for tagged PDF input and output and if the document has been opened with
usetags=true) If true, the structure tags of the imported page will be copied to the structure hierarchy
of the generated output document. In this case PDF_fit_pdi_page( ) can only be called in page scope. De-
fault: true
page A valid PDF page handle (not a page number!) retrieved with PDF_open_pdi_
page( ).
Details This function closes the page associated with the page handle identified by page, and re-
leases all related resources. page must not be used after this call.
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 PDF_open_pdi_
page( ). The infomode option must have been false when opening the document. The
page handle must not have been closed.
x, y The coordinates of the reference point in the user coordinate system where the
page will be located, subject to various options.
Details This function is similar to PDF_fit_image( ), but operates on imported PDF pages instead.
A tagged page (i.e. tagged PDF is created and the page is imported with usetags=true
from a tagged PDF) cannot be placed more than once.
In Tagged PDF mode it is recommended to use PDF_info_pdi_page( ) with the fitting-
possible keyword before calling PDF_fit_pdi_page( ) to check whether PDF_fit_pdi_page( )
will succeed (and avoid an exception in case of a failure).
Scope page, pattern, template, glyph; however, if a page from a Tagged PDF document has been
loaded with usetags=true this function can only be called in page scope.
cloneboxes (Boolean; not allowed if the topdown option has been supplied in PDF_begin_page_ext( ); must match
the cloneboxes option in PDF_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 posi-
tion 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 PDF_fit_pdi_page( ).
> Page boxes created by the cloneboxes option override the artbox, bleedbox, cropbox, trimbox,
mediabox, and rotate options as well as the width and height parameters of PDF_begin_page_ext( ).
Perform formatting calculations for a PDI page and query the resulting metrics.
Returns The value of some page property as requested by keyword. If the requested property is
not available for the page, the function returns 0. If an object handle is requested (e.g.
clippingpath) this function will return a handle to the object, or -1 (in PHP: 0) if the object
is not available. If the requested keyword produces text, a string index is returned, and
the corresponding string must be retrieved with PDF_get_string( ).
Details This function performs all calculations required for placing the imported page accord-
ing to the supplied options, but will not actually create any output on the page. The ref-
erence point for placing the page is assumed to be {0 0}. If the cloneboxes option of PDF_
open_pdi_page( ) has been supplied, the page will be placed on the same location (rela-
tive to the page boxes) as in the original page.
fittingpossible (Only relevant for Tagged PDF output) 0 if the page cannot be placed (i.e. PDF_fit_pdi_page( )
would throw an exception) for one of the following reasons:
> One of the pages top-level tags is not allowed under the currently active tag according to the
nesting rules for structure elements.
> The non-empty page is untagged or contains no structure elements, and direct content is not
allowed as child of the currently active tag.
> The page has already been placed.
> PDF/UA-1 with weak document structure: there is a gap in the heading level numbers between
the current structure element and its parents, and the imported structure sub-hierarchy.
The value 1 is returned if the page can be placed in the current context. The tag option of PDF_fit_
pdi_page( ) can be supplied and is taken into account for the result. Only the tagname suboption
of the tag option is evaluated; no other suboptions should be supplied.
Since the result is valid only for the current context this keyword should be used immediately be-
fore attempting to place a page.
lang String index for the Lang attribute of one of the imported pages top-level structure elements, or
-1 if no Lang attribute could be determined. The index option can be used to select one of the top-
level elements if there is more than one.
mirroringx, Horizontal or vertical mirroring of the page (expressed as 1 or -1) according to the supplied op-
mirroringy tions
rotate If cloneboxes=true: the rotation angle of the imported page in degrees, i.e. the value of the
pages Rotate key. Possible values are 0, 90, 180, and 270).
If cloneboxes=false: always 0
topleveltag String index for the name of one of the imported pages top-level structure elements if the page
has been opened with usetags=true and contains marked content associated with a structure el-
ement, otherwise -1 (e.g., for a page representing an Artifact). The index option can be used to
select one of the top-level elements if there is more than one. If the tag is a custom element
which is rolemapped in the imported documents rolemap, the corresponding standard element
name is reported, and not the custom element name.
topleveltagcount Number of structure elements at the top level of the imported pages structure hierarchy. The
lang and topleveltag keywords can be used to retrieve information about these elements, using
the index option to select one. 0 is returned if no structure elements are imported, either because
the page is untagged or contained no marked content corresponding to a structure element.
xid (Only for PDF/VT) String index for the GTS_XID entry of the page, or -1 if no GTS_XID value has
been assigned. The GTS_XID string can be used in the CIP4/Summary/Content/Referenced meta-
data property for DPM.
index (Integer; only relevant for the lang and topleveltag keywords) Selects one of the pages top-level
structure elements whose attribute is retrieved. The value must be in the range
0..(toplevelcount-1). Default: 0
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 PDF_open_pdi_page( ). The page handle must
not have been closed. If optlist does not require any page handle, page must be -1 (in PHP:
0).
Returns The value 1 if the function succeeded, or an error code of -1 (in PHP: 0) if the function call
failed. If errorpolicy=exception this function will throw an exception in case of an error. If
no Blocks were found on the input page for action=copyallblocks the function returns 1.
PDF/A The output intent can be set using this function with the copyoutputintent option or
with PDF_load_iccprofile( ). If only device-independent colors are used in the document
no output intent is required.
PDF/X The output intent must be set using this function with the copyoutputintent option or
with PDF_load_iccprofile( ).
action (Keyword; required; this option does not require a page handle) Specifies the kind of PDF processing:
copyoutputintent
(Doesnt do anything if the output document neither conforms to PDF/X nor PDF/A) 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 are ignored. If the document
contains more than one output intent the first one is 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/5n the reference to the
external output intent ICC profile is copied. If a referenced profile is embedded the attached
profile is also copied. The option action=copyoutputintent is not allowed if the input
conforms to PDF/X-4p/5pg/5n, but not the output.
copyallblocks
(Only available in PPS) Copy all PDFlib Blocks from a page of the input document to the
current output page according to the block option.
copyblock (Only available in PPS) Copy a PDFlib Block from a page of the input document to the current
output page according to the block option.
block (Option list; required for action=copyallblocks and action=copyblock) Specify details of the Block
copying process. The following suboptions are supported:
blockname
(Name string; only for action=copyblock and required in this case) Name of the Block
outputblockname
(Name string; only for action=copyblock) Name under which the Block will be stored in the
output page. Default: value of the blockname option
pagenumber
(Integer; required) The 1-based number of the page in the input document on which the Block
is located.
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.
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
Get the value of a pCOS path with type name, number, string, or boolean.
Details This function raises an exception if pCOS does not run in full mode and the type of the
object is string. However, some objects can nevertheless be retrieved in restricted mode
under certain conditions; see pCOS Path Reference for details.
This function assumes that strings retrieved from the PDF document are text strings.
String objects which contain binary data should be retrieved with PDF_pcos_get_
stream( ) instead which does not modify the data in any way.
Scope any
Bindings C language binding: The string will be returned in UTF-8 format (on zSeries and i5/
iSeries: EBCDIC-UTF-8) without BOM. The returned strings will be stored in a ring buffer
with up to 10 entries. If more than 10 strings are queried, buffers will be reused, which
means that clients must copy the strings if they want to access more than 10 strings in
parallel. For example, up to 10 calls to this function can be used as parameters for a
printf( ) statement since the return strings are guaranteed to be independent if no more
than 10 strings are used at the same time.
C++ language binding: The string will be returned as wstring in the default wstring con-
figuration of the C++ wrapper. In string compatibility mode on zSeries and i5/iSeries the
result will be returned in EBCDIC-UTF-8 without BOM.
Bindings COM: the result will be provided as Unicode string in UTF-16 format. If no text is avail-
able an empty string will be returned.
Java, .NET, and Python: the result will be provided as Unicode string. If no text is avail-
able a null object will be returned.
Perl and PHP language bindings: the result will be provided as UTF-8 string. If no text is
available a null object will be returned.
C++ Java C# const unsigned char *pcos_get_stream(int doc, int *length, string optlist, string path)
Perl PHP string pcos_get_stream(long doc, string optlist, string path)
C const unsigned char *PDF_pcos_get_stream(PDF *p, int doc, int *length, const char *optlist,
const char *path, ...)
Get the contents of a pCOS path with type stream, fstream, or string.
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.
Returns The unencrypted data contained in the stream or string. The returned data will be emp-
ty (in C: NULL) if the stream or string is empty, or if the contents of encrypted attach-
ments in an unencrypted document are queried and the attachment password has not
been supplied.
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 excep-
tion, 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. Un-
like PDF_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 can-
not 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. Java-
Script with COM does not allow to retrieve the length of the returned variant array (but
it does work with other languages and COM).
C and C++ language bindings: The returned data buffer can be used until the next call to
this function.
Python: the result will be returned as 8-bit string (Python 3: bytes).
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 vendors 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.
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):
none Treat the contents as binary data without any conversion.
unicode Treat the contents as textual data (i.e. exactly as in PDF_pcos_get_string( )), and
normalize it to Unicode. In non-Unicode-capable 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).
keepfilter (Boolean; recommended only for image data streams; will be ignored for streams which are com-
pressed with unsupported filters) If true, the stream data will be compressed with the filter
which is specified in the images filterinfo pseudo object. If false, the stream data will be un-
compressed. Default: true for all unsupported filters, false otherwise
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 interactively. Alternatively, Blocks can be created with PPS itself.
Cookbook A full code sample for filling Blocks with PPS can be found in the Cookbook topic blocks/
starter_block.
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 contents have been provided. This may be useful to make sure that the
Blocks 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 Blocks 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 hide
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
C++ Java C# int fill_textblock(int page, String blockname, String text, String optlist)
Perl PHP int fill_textblock(int page, string blockname, string text, string optlist)
C int PDF_fill_textblock(PDF *p,
int page, const char *blockname, const char *text, int len, const char *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 PDF_fit_pdi_
page( ), indirectly in a table cell with PDF_fit_table( ), or as contents of a PDF Block with
PDF_fill_pdfblock( ).
text (Content string) The text to be filled into the Block, or an empty string if the de-
fault 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.
len (C language binding only) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
optlist An option list specifying text Block filling options. The following options are
supported:
> General option: errorpolicy (see Table 2.1)
> 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 123)
> Textline Blocks, i.e. the textflow property or option is false:
all Textline options (see Section 5.1, Single-Line Text with Textlines, page 89)
> Textflow Blocks, i.e. the textflow property or option is true:
all options for PDF_add/create_textflow( ) (see Section 5.2, Multi-Line Text with Text-
flows, page 95) and all options for PDF_fit_textflow( ) (see Table 5.12)
> Text Block options according to Table 11.2: textflow, textflowhandle
> Option for default contents: defaulttext (see PDFlib Tutorial)
Returns -1 (in PHP: 0) if the named Block doesnt exist on the page, the Block cannot be filled (e.g.
due to font problems), the Block has wrong type, or the Block requires a newer PPS ver-
sion for processing; 1 if the Block could be processed successfully. If the textflowhandle
option is supplied a valid Textflow handle is returned which can be used in subsequent
calls. If the property Status has the value ignore, a handle to an empty Textflow is re-
turned if textflowhandle=-1, otherwise the supplied Textflow handle is returned without
modifying the Textflow (since no output is created).
If the PDF document is found to be corrupt, this function will either throw an excep-
tion or return -1 subject to the errorpolicy option.
Details The supplied text will be formatted into the Block, subject to the Blocks properties. If
text is empty the function will use the Blocks 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.
This process can be repeated an arbitrary number of times. The user is responsible for
deleting the Textflow handle with PDF_delete_textflow( ) at the end.
PDF/UA Block decoration, i.e. ruling and shading created according to the backgroundcolor,
bordercolor, linewidth properties is automatically tagged as Artifact.
textflow- (Textflow handle; only for PDF_fill_textblock( ) with textflow=true) This option can be used for Text-
handle flow Block chaining. For the first Block in a chain of Blocks a value of -1 (in PHP: 0) 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. Note that all properties in the Text
Preparation, Text Formatting and Appearance property groups of the Block will be ignored if textflow-
handle is supplied since the corresponding values used for creating the Textflow will be applied.
C++ Java C# int fill_imageblock(int page, String blockname, int image, String optlist)
Perl PHP int fill_imageblock(int page, string blockname, int image, string optlist)
C int PDF_fill_imageblock(PDF *p, int page, const char *blockname, int image, const char *optlist)
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 PDF_fit_pdi_
page( ), indirectly in a table cell with PDF_fit_table( ), or as contents of a PDF Block with
PDF_fill_pdfblock( ).
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 image Block filling options. The following options are
supported:
> General option: errorpolicy (see Table 2.1)
> 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 123)
> Options for image processing according to Table 9.3
> Option for default contents: defaultimage (see PDFlib Tutorial)
Returns -1 (in PHP: 0) if the named Block doesnt exist on the page, the Block cannot be filled, the
Block has wrong type, or the Block requires a newer PPS version for processing; 1 if the
Block could be processed successfully. Use PDF_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 Blocks properties. If image is -1 (in PHP: 0) the function will use the Blocks 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 excep-
tion or return -1 subject to the errorpolicy option.
PDF/UA All raster images must be tagged as Artifact or Figure with a preceding call to PDF_begin_
item( ).
Block decoration, i.e. ruling and shading created according to the backgroundcolor,
bordercolor, linewidth properties is automatically tagged as Artifact.
C++ Java C# int fill_pdfblock(int page, String blockname, int contents, String optlist)
Perl PHP int fill_pdfblock(int page, string blockname, int contents, string optlist)
C int PDF_fill_pdfblock(PDF *p, int page, const char *blockname, int contents, const char *optlist)
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 PDF_fit_pdi_
page( ), indirectly in a table cell with PDF_fit_table( ), or as contents of a PDF Block with
PDF_fill_pdfblock( ).
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 Table 2.1))
> 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 123)
> Options for page processing according to Table 9.3
> Options for default contents: defaultpdf, defaultpdfpage (see PDFlib Tutorial)
Returns -1 (in PHP: 0) if the named Block doesnt exist on the page, the Block cannot be filled, the
Block has wrong type, or the Block requires a newer PPS version for processing; 1 if the
Block could be processed successfully. Use PDF_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 Blocks properties. If contents is -1 (in PHP: 0) the function will use
the Blocks 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 excep-
tion or return -1 subject to the errorpolicy option.
PDF/UA Block decoration, i.e. ruling and shading created according to the backgroundcolor,
bordercolor, linewidth properties is automatically tagged as Artifact.
C++ Java C# int fill_graphicsblock(int page, String blockname, int contents, String optlist)
Perl PHP int fill_graphicsblock(int page, string blockname, int contents, string optlist)
C int PDF_fill_graphicsblock(PDF *p, int page, const char *blockname, int contents, const char *optlist)
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 PDF_fit_pdi_
page( ), indirectly in a table cell with PDF_fit_table( ), or as contents of a PDF Block with
PDF_fill_pdfblock( ).
graphics A valid graphics handle for the graphics to be filled into the Block, or -1 if the
default graphics (as defined by Block properties) is to be used.
optlist An option list specifying graphics Block filling options. The following options
are supported:
> General option: errorpolicy (see Table 2.1)
> 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 123)
> Options for graphics processing according to Table 9.3
> Option for default contents: defaultgraphics (see PDFlib Tutorial)
Returns -1 (in PHP: 0) if the named Block doesnt exist on the page, the Block cannot be filled, the
Block has wrong type, or the Block requires a newer PPS version for processing; 1 if the
Block could be processed successfully. Use PDF_get_errmsg( ) to get more information
about the nature of the problem.
Details The graphics referred to by the supplied graphics handle will be placed in the Block, sub-
ject to the Blocks properties. If graphics is -1 (in PHP: 0) the function will use the Blocks
default graphics if available (unless Status=ignoredefault), and silently return otherwise.
If the PDF document is found to be corrupt, this function will either throw an excep-
tion or return -1 subject to the errorpolicy option.
PDF/UA Block decoration, i.e. ruling and shading created according to the backgroundcolor,
bordercolor, linewidth properties is automatically tagged as Artifact.
len (C language binding only) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
optlist An option list specifying the bookmarks properties. The following options can
be used:
> General options: errorpolicy (see Table 2.1), hypertextencoding and hypertextformat (see
Table 2.3)
> Bookmark control options according to Table 12.1:
action, destination, destname, fontstyle, index, item, open, parent, textcolor
Returns A handle for the generated bookmark, which may be used with the parent option in sub-
sequent calls.
Details This function adds a PDF bookmark with the supplied text. Unless the destination option
is specified the bookmark points to the current page (or the least recently generated
page if used in document scope, or the first page if used before the first page).
Creating bookmarks sets the openmode option of PDF_begin/end_document( ) to
bookmarks unless another mode has explicitly been set.
action (Action list) List of bookmark actions for the following event (default: GoTo action with the target speci-
fied 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.10. 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 PDF_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 wont have any action. This may be useful for separator bookmark.
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 par-
ent. The value -1 can be used to insert the bookmark as the last one on the current level. Default: -1. How-
ever, for inserted or resumed pages bookmarks will be placed as if all pages had been generated in their
physical order (i.e. the bookmarks reflect the page order).
item (Item handle or keyword; the handle must not refer to an active structure element, but not to an inline or
pseudo element; only for Tagged PDF) Handle for a structure item which will be associated with the
bookmark. The value 0 always refers to the structure tree root. The value -1 and the equivalent keyword
current refer to the currently active element.
open (Boolean) If false, subordinate bookmarks will not be visible. If true, all children will be folded out. De-
fault: false
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)
C++ Java C# void create_annotation(double llx, double lly, double urx, double ury, String type, String optlist)
Perl PHP create_annotation(float llx, float lly, float urx, float ury, string type, string optlist)
C void PDF_create_annotation(PDF *p,
double llx, double lly, double urx, double ury, const char *type, const char *optlist)
llx, lly, urx, ury x and y coordinates of the lower left and upper right corners of the an-
notation rectangle in default coordinates (if the usercoordinates 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 PDF_rect( )
function. While PDF_create_annotation( ) expects parameters for two corners directly,
PDF_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.2. Markup annotations are marked in
the table since certain options apply only to markup annotations.
Movie (Movie annotation; deprecated in PDF 2.0; use type=RichMedia instead) attachment, 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
Details In tagged PDF mode this function automatically creates a suitable OBJR element for the
generated annotation. The user must create a corresponding Link or Annot container ele-
ment (see PDFlib Tutorial) before calling this function.
PDF/X Annotations are only allowed if they are positioned completely outside of the BleedBox
(or TrimBox/ArtBox if no BleedBox is present).
PDF/X-1a/3: the annotation type FileAttachment is not allowed.
PDF/UA A non-grouping structure element must be created with PDF_begin_item( ) or the tag op-
tion when this function is called to create a visible annotation.
The option contents or the option tag with the suboption ActualText must be supplied
for visible annotations.
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 annotations icon when closed, the title bar of the annotations
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. Default: white for type=Square, Circle, otherwise none
PDF/A-1: this option can only be used if an RGB output intent has been specified, and gray or rgb color
must be used.
attachment (Asset handle; only for type=FileAttachment and Movie; required) File attachment which has been load-
ed with PDF_load_asset( ) and type=attachment. Supported suboptions: see Table 13.6.
For type=FileAttachment: the file associated with the annotation
For type=Movie: the media file in one of the following formats: AVI or QuickTime movie, WAV or AIFF
sound. Note that the attachment must have been loaded with type=Attachment and external=true in
PDF_load_asset( ).
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 coor-
dinates of the line. The coordinates will be interpreted in default coordinates (if the usercoordinates op-
tion 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 op-
tion.
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 in-
dicating 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
caption- (Keyword; only for type=Line; PDF 1.7) The annotations caption position. This option will be ignored if
position 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; PDF/UA-1:
required if no ActualText is supplied in the tag option, and always required for type=Link) 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. PDF/A-1a/2a/3a: recommended for annotations which do not display text.
createdate (Boolean; PDF 1.5) If true, a date/time entry is created for the annotation. Default: true for Markup an-
notations, false otherwise
createrich- (Option list; only for markup annotations; option contents must be empty; PDF 1.5) Create rich text con-
text tents from a Textflow. This may be useful to generate formatted text for annotations. Supported subop-
tions:
textflow (Textflow handle) A Textflow which will be attached to the annotation as rich text. Color
specifications in the Textflow must use only grayscale or RGB colors. If the Textflow handle
has been supplied to PDF_fit_textflow/table( ) before the call to PDF_create_annotation( )
only the remaining text is used for the annotation. If no more text is available the Textflow is
restarted from the beginning. Using a Textflow for an annotation does not affect subsequent
calls to PDF_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 are honored when creating rich text; all others are ignored:
nextline, alignment, fillcolor, underline, strikeout, font, fontsize, textrise, text formatting op-
tions
Note: setting font and alignment doesnt 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 pri-
vate entries in the annotation dictionary, which may be useful for specialized applications such as insert-
ing processing instructions for digital printing machines. Using this option requires knowledge of the PDF
file format and the target application. 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 two non-negative floats; only for borderstyle=dashed). The lengths of dashes and gaps for a
dashed border in default units (see Table 7.1). Default: 3 3
datestring (String; forces createdate=true) PDF date string with the desired creation date for the annotation. The
date string is written unmodified to the annotation dictionary. It is an error to supply an invalid date
string. Default (only relevant if createdate=true: the current date
destination (Option list; only for type=Link; will be ignored if an activate action has been specified) Option list ac-
cording to Table 12.10 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 PDF_add_nameddest( ). Actions created with the
destination or destname options of PDF_create_action( ) are dominant over this option.
display (Keyword; will be forced to visible in PDF/A) 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 end-
ing 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 Deprecated, use attachment
fillcolor (Color; only for type=FreeText) Fill color of the text. Supported color spaces are none, gray, rgb, and (in
PDF 1.6) cmyk. Default: {gray 0} (=black)
PDF/A-1: this option can only be used if an RGB output intent has been specified, and gray or rgb color
must be used.
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. The value 0 or keyword auto means that Acrobat adjusts 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 anno-
tation (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 dont work reliably in Adobe Reader; the template option is recom-
mended 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
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.
interiorcolor (Color; only for type=Line, PolyLine, Square, Circle) The color for the annotations line endings, rectan-
gle, or ellipse, respectively. Supported color spaces are none, gray, rgb, and (in PDF 1.6) cmyk. Default: none
PDF/A-1: this option can only be used if an RGB output intent has been specified, and gray or rgb color
must be used.
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). Leader lines are auxiliary lines which are drawn from each endpoint of the line perpendicu-
lar to the line itself. 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 di-
rection.
The second value, which can be omitted, represents the length of leader line extension which is drawn on
the opposite side of the line. A positive value is 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). De-
fault: 0
line (Line; only for type=Line; required) A list of four numbers x1, y1, x2, y2 specifying the start and end points
of the line in default coordinates (if the usercoordinates option 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
locked (Boolean) If true, the annotation properties (e.g. position and size) cannot be edited in Acrobat. How-
ever, the contents can still be modified. Default: false
locked- (Boolean; PDF 1.7) If true, the annotation contents cannot be edited in Acrobat. However, the annotation
contents can still be deleted or properties changed (e.g. position and size) Default: false
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; not for PDF/A-1) 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 popup annotation. If this option is
supplied, the options contents, annotcolor and title of the parent annotation override the corre-
sponding values of the popup 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 dis-
played or printed, but should not respond to mouse clicks or change its appearance in response to mouse
motions. Default: false
rectdiff (Rectangle; only for type=Caret) Four non-negative numbers which describe the difference between the
annotation rectangle and the boundaries of the underlying caret.
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):
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.
richmedia (Option list; required for type=RichMedia) Rich media options according to Table 13.7
rotate (Boolean; must not be set to true for text annotations in PDF/A) If true, rotate the annotation to match
the rotation of the page. Otherwise the annotations rotation will remain fixed. This option will be ig-
nored for the icons of text annotations. Default: false for text annotations in PDF/A, otherwise true
showcaption (Boolean; only for type=Line; PDF 1.6) If true, the text specified in the contents or createrichtext op-
tions 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 dis-
played. 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 an-
notation. Default: none
symbol (Keyword; only for type=Caret) Type of the caret symbol (default: none):
paragraph paragraph symbol
none no symbol
template (Option list) Visual appearance of the annotation for one or more states. This may be useful e.g. for cus-
tom stamps. Supported suboptions:
normal/rollover/down
(Template handle or keyword) Template which will be used for the annotations 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 en-
tirely 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 templates
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 annotations 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 are ignored and the named matchbox is used instead.
The first element in the option list is a name string which specifies a matchbox. The second element is ei-
ther an integer specifying the number of the desired rectangle, or the keyword all to specify all rectan-
gles 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 silently
returns without creating any annotation. When using matchboxes to create annotations in a table cell
PDF_create_annotation( ) must be called after PDF_fit_table( ) to make sure that the matchbox size has
already been calculated.
user- (Boolean) If false, annotation coordinates and font size will be expected in the default coordinate sys-
coordinates tem; otherwise the current user coordinate system will be used. Default: the value of the global
usercoordinates option
window- (List of 2 floats or keywords; only for type=Movie) For floating movie windows, the relative position of
position 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}
windowscale (Float or keyword; only for type=Movie) The zoom factor at which to play the movie in a floating win-
dow. If the option is absent, the movie will be played in the annotation rectangle. The value of this op-
tion 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) If true, scale the annotation to match
the magnification of the page. Otherwise the annotations size will remain fixed. This option will be ig-
nored for the icons of text annotations. Default: false for text annotations in PDF/A, otherwise true
C++ Java C# void create_field(double llx, double lly, double urx, double ury,
String name, String type, String optlist)
Perl PHP create_field(float llx, float lly, float urx, float ury, string name, string type, string optlist)
C void PDF_create_field(PDF *p, double llx, double lly, double urx, double ury,
const char *name, int len, const char *type, const char *optlist)
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 option is false) or user coor-
dinates (if it is true).
Note that form field coordinates are different from the parameters of the PDF_rect( )
function. While PDF_create_field( ) expects coordinates for two corners directly, PDF_
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 PDF_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.
len (C language binding only) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
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 PDF_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 PDF_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 standard, but implemented with custom Java-
Script. 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 (see
PDFlib Tutorial).
In tagged PDF mode this function automatically creates a suitable OBJR element for
the generated form field. The user must create the corresponding Form container ele-
ment (see PDFlib Tutorial) before calling this function.
Fonts and the associated encodings for use in form fields must be selected with care
to work around restrictions in Acrobat. Some recommendations:
> The font should be installed on the viewing machine if possible.
> Type 1 fonts except core fonts should be loaded with an 8-bit encoding; encoding=
unicode should be avoided.
> TrueType and OpenType fonts should be loaded with an 8-bit encoding and the op-
tion simplefont; encoding= unicode should be avoided. encoding=builtin can be used for
symbol fonts.
> If Unicode encoding is required, a Unicode CMap should be used if possible (e.g.
UniGB-UTF16-H). If embedding=false the option keepnative should be set.
> The encodings pdfdoc and macroman should be avoided.
PDF/X Form fields are only allowed if they are positioned completely outside of the BleedBox
(or TrimBox/ArtBox if no BleedBox is present).
PDF/UA A structure element of type Form must be created with PDF_begin_item( ) or the tag op-
tion when this function is called. The tooltip option is required.
Scope page
name (Hypertext string) The name of the form field group, which may in turn be pre-
fixed 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.
len (C language binding only) Length of text (in bytes). If len = 0 a null-terminated
string must be provided.
optlist An option list with field options for PDF_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 PDF_
create_field( ), the new field becomes part of this group. All field property options pro-
vided in the optlist for a group are inherited by all fields belonging to this group.
PDF/UA The tooltip option is required. The ZapfDingbats font is required for type=radiobutton and
checkbox. Since all fonts must be embedded in PDF/UA, an embeddable font outline file
for ZapfDingbats must be configured.
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 fields area.
enter Actions to be performed when the mouse enters the fields area.
exit Actions to be performed when the mouse exits the fields 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 fields 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.
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 fields area (this is
typically used to activate a field).
validate JavaScript actions to be performed when the fields 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.
alignment (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:
color none
bordercolor
barcode (Option list; only for type=textfield; implies readonly; PDF 1.7ext3) Create a barcode field according to
the options in Table 12.6. The field should provide the action option with a calculate event script which
determines the barcode contents based on the contents of other fields or supplies a static value:
action={calculate=...}.
The barcode is rendered only in Acrobat, but not Adobe Reader. Acrobat X crashes if the first field on a
page is a barcode field. In order to work around this problem you must create another field before adding
the barcode field. The first field may be as simple as a dummy text field with zero width and height to
prevent the crash.
borderstyle (Keyword) Style of the field border, which is one of solid, beveled, dashed, inset, underline. Default:
solid
button- (Keyword; only for type=pushbutton) The position of the button caption relative to the button icon, pro-
layout vided 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 or-
der 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 is visible when the button doesnt have input focus. It is displayed with
the font supplied in the font option. An empty string (i.e. caption {}) produces neither caption nor icon.
Default: none
caption- (Content string; only for type=pushbutton; requires highlight=push) The caption text which will be vis-
down ible when the button is activated. It will be displayed with the font supplied in the font option. Default:
none
caption- (Content string; only for type=pushbutton; requires highlight=push) The caption text which will be vis-
rollover ible when the button has input focus. It will be displayed with the font supplied in the font option. De-
fault: none
charspacing (Float; not for type=radiobutton, checkbox) The character spacing for text in the field in units of the
current user coordinate system. Default: 0
comb (Boolean; only for type=textfield; PDF 1.5) If true and the multiline, fileselect, and password op-
tions 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. De-
fault: false
commit- (Boolean; only for type=listbox, combobox; PDF 1.5) If true, an item selected in the list will be committed
onselect immediately upon selection. If false, the item will only be committed upon exiting the field. Default:
false
currentvalue (Not for type=pushbutton, signature) The fields 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 (List of integers) Indices of the selected items within itemtextlist. Default: none
dasharray (List of two non-negative floats; only for borderstyle=dashed). The lengths of dashes and gaps for a
dashed border in default units (see Table 7.1). Default: 3 3
defaultvalue The fields value after a ResetForm action. Types and defaults are the same as for the currentvalue op-
tion. 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 PDF_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 PDF_create_fieldgroup( ), and not in the options of PDF_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
font (Font handle). Font to be used for the field; see Details section above regarding font and encoding restric-
tions and recommendations. Acrobat can display characters even if they are not included in the fonts en-
coding. For example, you can use encoding=winansi and supply Unicode characters outside winansi.
Font usage depends on the field type:
> Fields with type=listbox, combobox, or textfield: this option is required.
> For type=pushbutton this option is required if one or more of the caption, captionrollover, or cap-
tiondown options are specified.
> Fields with type=radiobutton or checkbox always use ZapfDingbats and encoding=builtin.
fontsize (Fontsize) Font size in user coordinates. The value 0 or keyword auto which means that Acrobat will ad-
just 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 doesnt have input focus. De-
fault: none
icondown (Template handle1; only for type=pushbutton; requires highlight=push) Handle for a template which
will be visible when the button is activated. Default: none
iconrollover (Template handle1; only for type=pushbutton; requires highlight=push) 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. De-
fault: field name
item- (Hypertext string; only for type=listbox, combobox) Export values of the list items. Multiple items may
namelist 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 correspond-
ing layer is visible.
linewidth (Integer) Line width of the field border in default coordinates. 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 in-
put. Default: false
position (List of floats or keywords; only for type=pushbutton) One or two values specifying the position of a tem-
plate 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 rect-
angles 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 key-
word 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 doesnt 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. De-
fault: 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 PDF_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 de-
activating by clicking another button. Default: false
tooltip2 (Hypertext string; non-empty value required in PDF/UA-1) The text visible in the fields tooltip, also used
by screen readers. For radio buttons and groups Acrobat uses the tooltip of the first button in the group,
others are 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 PDF_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
user- (Boolean) If false, field coordinates are expected in the default coordinate system; otherwise the current
coordinates user coordinate system will be used. Default: the value of the usercoordinates global option
1. Templates for icons can be created with the PDF_begin_template_ext( ) function; if the icon consists of an image only you can create
the template by supplying the template option to PDF_load_image( ).
2. For type=radiobutton this option should not be used with PDF_create_field( ), but only with PDF_create_fieldgroup( ).
Table 12.6 Suboptions for the barcode option of PDF_create_field( ) and PDF_create_fieldgroup( )
option description
caption (Hypertext string) Caption which will be rendered below the barcode. By default, Acrobat creates the
file: URL for the document as caption.
xsymheight (Integer; only for symbology=PDF417, and required in this case) Vertical distance between two barcode
modules in pixels. The ratio xsymheight/xsymwidth must be an integer value. The allowed range for this
ratio is 1-4.
xsymwidth (Integer; required) Horizontal distance between two barcode modules in pixels
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: destination, destname, filename, newwindow,
targetpath
Movie (Deprecated in PDF 2.0; use type=RichMediaExecute instead) Play an external sound or movie file in a
floating window or within the rectangle of a movie annotation: operation, target
ResetForm Set some or all form fields to their default values: exclude
RichMedia- (PDF 1.7ext3) Send a command to a RichMedia annotation: functionname, instance, richmediaargs,
Execute target
SubmitForm Send data to a uniform resource locator, i.e. an Internet address (submits which require basic authentica-
tion dont work in Acrobat): canonicaldate, exclude, exportmethod, submitemptyfields, url
Trans (PDF 1.5) Update the display using some visual effect. This can be useful to control the display during a se-
quence of multiple actions: duration, transition
URI Resolve a uniform resource identifier, i.e. jump to an Internet address: ismap, url
Details This function creates a single action. Various objects (e.g. pages, form field events, book-
marks) can be provided with one or more actions, but each action must be generated
with a separate call to PDF_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 op-
tions has already been created earlier.
Scope any except object. The returned handle can be used until the next call to PDF_end_
document( ).
3Dview (Keyword or 3D view handle; GoTo3DView; required) Selects the view of a 3D annotation; One of the key-
words first, last, next, previous (referring to the respective entries in the annotations views option),
or default (referring to the annotations defaultview option), or a 3D view handle created with PDF_
create_3dview( ).
canonical- (Boolean; SubmitForm) If true, any submitted field values representing dates are converted to a standard
date 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.10
defining the destination to jump to.
destname (Hypertext string) GoTo (required unless destination is supplied): name of a destination which has been
defined with PDF_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 embed-
ded 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 doc-
ument 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 in-
clude in resetting. All members of specified field groups will be reset as well. Default: false
export- (Keyword list; SubmitForm) Controls how the field names and values are submitted. Default: fdf.
method 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 fields 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.
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.
functionname (Hypertext string; RichMediaExecute; required) String specifying the script command as a primitive Ac-
tionScript or JavaScript function name (not a full script). If the target instance specified by the instance
option contains Flash content, the command string represents an ActionScript ExternalInterface call
to the script engine context specific to the target instance. If the target instance is a 3D model, the call is
made in the global context of the annotations instance of the 3D JavaScript engine.
hide (Boolean; Hide) Indicates whether to hide (true) or show (false) annotations. Default: true
instance (Integer; RichMediaExecute) Index of the option list (starting with 1) in the instances suboption of the
configuration suboption of the richmedia option of PDF_create_annotation( ) to specify a Flash or 3D
instance of the RichMedia annotation for which to execute the script. Default: 1
ismap (Boolean; URI; true not allowed for PDF/UA-1) If true, the coordinates of the mouse position will be add-
ed 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 han-
dle. 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 only 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 hid-
den 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 ex-
clude, 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.
operation (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 annotations 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 char-
acter, but individual parameters must not contain any space characters. This option should be omitted if
filename designates a document. Default: none
preserve- (Boolean; SetOCGState) If true, preserve the radio-button state relationship between layers. Default:
radio true
richmediaargs (POCA container handle; RichMediaExecute) Handle for an array container which specifies an arbitrary
number of arguments for the command. Valid arguments are objects of type string, integer, float, or
Boolean. The array must have been created with the option usage=richmediaargs. Default: no argu-
ments
script (Hypertext string; JavaScript; required) A string containing the JavaScript code to be executed. In order to
pass arbitrary strings with this option the option list syntax described in Unquoted string values, page
10, may be useful.
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. Document-level JavaScript will be executed after loading
the document in Acrobat. This may be useful for scripts which are used in form fields.
submit- (Boolean; SubmitForm) If true, all fields characterized by the namelist and exclude options are submit-
emptyfields ted, regardless of whether they have a value. For fields without a value, only the field name is transmit-
ted. If false, fields without a value are not submitted. Default: false
target (String; GoTo3DView, Movie; RichMediaExecute; required) Name of the target 3D, movie, or rich media
annotation for which to execute the script as specified in the name option of PDF_create_annotation( ).
targetpath (Option list; GoToE; required unless filename is specified) A target option list (see Table 12.9) 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.9 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://).
destname (Hypertext string; required unless pagenumber is supplied and relation=child and the target is associat-
ed with a file attachment annotation) Specifies a named destination for a page in the current document
which contains the targets file attachment annotation. This option will be ignored if pagenumber is spec-
ified.
name (Hypertext string; required if relation=child and the target is located in the attachments list; other-
wise it must be absent; will be ignored if annotation is specified) Name of the target in the attachments
list of PDF_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 targets file attachment annotation.
relation (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.
targetpath (Option list) A target option list according to Table 12.9 specifying additional path information to the tar-
get document. If this option is absent the current document is the target file containing the destination.
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 docu-
ment. If the same name is supplied more than once for a document only the last defini-
tion is used, the others are silently ignored.
len (C language binding only) Length of name (in bytes). If len = 0 a null-terminated
string must be provided.
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 PDF_create_action( ), PDF_create_annotation( ), PDF_create_bookmark( ), and PDF_
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 PDF_add_nameddest( ) is not required in this case.
Table 12.10 Destination options for PDF_add_nameddest( ), as well as for the destination option in PDF_create_action( ),
PDF_create_annotation( ), PDF_create_bookmark( ), and PDF_begin/end_document( ).
option description
bottom (Float; only for type=fitrect) The y coordinate of the page in default coordinates 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 in
default coordinates 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 page scope, and page 1 if in document scope. Default: 0
right (Float; only for type=fitrect) The x coordinate of the page in default coordinates 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 in de-
fault coordinates which will positioned at the top edge of the window. Default: 1000
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 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.
zoom (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 acti-
vated will be retained.
parent The parent folder, specified by a folder handle returned by an earlier call to
PDF_add_portfolio_folder( ), or -1 (in PHP: 0) 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.
len (C language binding only) Length of foldername (in bytes). If len=0 a null-terminat-
ed string must be provided.
optlist An option list specifying portfolio properties. The following options can be
used:
> General options: errorpolicy (see Table 2.1), hypertextencoding and hypertextformat (see
Table 2.3)
> Options for folder properties according to Table 13.6: description, thumbnail
> Metadata option according to Table 12.11: fieldlist
Details The generated folder structure will be used to create a PDF portfolio for the current doc-
ument. The folder structure will be deleted after PDF_end_document( ). This function
must not be used if the attachments option has been supplied to PDF_begin_document( ).
Scope any except object
fieldlist (List of option lists) Specify metadata fields for the file or folder. Each list refers to a field in the schema
suboption of the portfolio option of PDF_end_document( ). Supported suboptions are listed in Table
12.12.
filename (Name string; will be interpreted according to the filenamehandling global op-
tion, see Table 2.3) Name of a disk-based or virtual file which will be attached to the spec-
ified folder of the PDF portfolio. With the createpvf option of PDF_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.
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 suf-
fix cannot be used due to external restrictions you can create a PVF file (which supports
arbitrary file names) instead.
len (C language binding only) Length of filename (in bytes). If len=0 a null-terminated
string must be provided.
Returns The value 1 if the file could be added successfully, or an error code of -1 (in PHP: 0) 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 doc-
ument 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 PDF_begin_document( ).
key (String; required) Name of the field, which must refer to a key in the schema suboption of the portfolio
option list of PDF_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):
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.
value (Hypertext string; required) Specifies the value of a field in the schema suboption of the portfolio option
list of PDF_end_document( ). The data type must be specified in the type option and must match the cor-
responding type suboption of the schema suboption of the portfolio option.
coversheet- (Folder handle) The name of the folder within the portfolio which contains the file specified in the
folder 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):
custom (PDF 1.7ext3; requires the navigator option; deprecated in PDF 2.0) The portfolio is presented
by a custom Flash-based navigator.
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).
hidden The portfolio is initially hidden, without preventing the user from obtaining a file list via
explicit action (Acrobat: Minimize view).
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).
navigator (Option list; PDF 1.7ext3; Deprecated in PDF 2.0; required for initialview=custom) Embed a custom
Flash-based navigator in the portfolio. In order to actually use the custom navigator when the document
is opened use view=custom; otherwise the navigator can be used for editing the portfolio, but will not be
active upon opening the document. Supported suboptions are listed in Table 12.14.
The values of category, description, icon, and name will be used to present the navigator in the list of
available portfolio layouts when the portfolio is edited in Acrobat.
schema (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.
sort (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 (optional). 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 contrib-
ute 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 sort-
ing until a unique order is determined or until the field names are exhausted. Default: no sorting
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 indi-
cates vertical orientation. No splitter is used if initalview=hidden. Supported suboptions:
direction (Keyword) Orientation of the splitter bar. Supported keywords:
horizontal Split the window horizontally.
vertical Split the window vertically.
none Dont 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
apiversion (String; required) Version of the navigator API required by the navigator SWF file, specified as a string of
the form m[.n[.p[.q]]], where m, n, p, and q are non-negative integers. If not present, n, p, and q default
to 0. The following entries are recommended for use with Acrobat X and above: 9.5.0.0
assets (List of option lists, required) Assets that are used to implement the navigator, e.g. a Flash file, an icon
and other resources such as images or XML files. Supported suboptions:
asset (Asset handle; required) Handle for an asset loaded with PDF_load_asset( ).
name (Hypertext string with 1-255 characters; the characters : * " < > | must not be used; the last
character must not be a period .; required) Name of the asset which can be used to identify it
in Flash code.
category (Hypertext string) Category in which the navigator will be presented
flash (Hypertext string; required) Name of an asset in the assets option list with type=Flash, containing the
SWF code which implements the portfolio layout.
icon (Hypertext string) Name of an asset in the assets option list with type=JPEG or PNG, containing an icon
for the navigator. However, the use of PNG images is recommended since JPEG images dont seem to
work consistently in Acrobat. A size of 42x42 pixels is recommended for best results in Acrobat.
id (String; required if version is specified) String representing a unique ID for the navigator, expressed as a
URI. If a versioning scheme is to be implemented, it is necessary to provide the same id across all versions
of the navigator. If no id is specified, PDFlib will generate a URN based on a machine-generated GUID.
loadtype (Keyword) Method used to load the navigator SWF. Supported keywords (default is the keyword
default):
module The navigator SWF is loaded as Adobe Flex 2 module.
default The navigator SWF is loaded as an ordinary SWF file.
locale (String) String with a locale according to Unicode Technical Standard #35. Examples: en_GB, de_DE, zh_
Hans
strings (List of pairs of hypertext strings) Localized strings for the navigator. Each pair consists of an identifier for
the localized string and the localized string itself.
version (String; requires the id option) Version of the navigator, specified as a string of the form m[.n[.p[.q]]],
where m, n, p, and q are non-negative integers. If not present, n, p, and q default to 0.
Table 12.15 and subsequent tables specify the options for geospatial features in detail.
bounding- (Rectangle; required) A rectangle in default coordinates specifying the location of the viewport on the
box page.
georeference (Option list; required) Description of a world coordinate system associated with the viewport to use for
geospatial measuring; see Table 12.16 for supported options.
hypertext- (Keyword) Specifies the encoding for the name option. An empty string is equivalent to unicode. Default:
encoding the value of the hypertextencoding global option
name (Hypertext string) A descriptive title of the viewport (map name). However, Acrobat does not display the
viewport name in the user interface.
Table 12.16 Suboptions for the georeference option of PDF_load_image( ), PDF_open_pdi_page( ), PDF_load_graphics( ),
PDF_begin_template_ext( ) and the georeference suboption of the viewports option of PDF_begin/end_page_ext( )
option description
angularunit (Keyword) Specifies the preferred angular display unit (default: deg):
degree degrees
grad grad (1/400 of the full circle, or 0.9 degrees)
areaunit (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 transforma-
tions 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 template or image. Default: {0 0 0 1 1 1 1
0}, i.e. the full viewport, template or image area will be used for the map.
displaysystem (Option list) Specifies a coordinate system according to Table 12.17 for the user-visible display of position
values, such as latitude and longitude. This entry can be used to display the coordinates in another sys-
tem than the one supplied in the coords option to specify the map.
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, graphics, tem-
plate or PDI page, or image which contains the georeference option list. The mappoints list must con-
tain 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
12.17.
Table 12.17 Suboptions for the mapsystem and displaysystem suboptions of the georeference option of PDF_load_
image( ), PDF_open_pdi_page( ), PDF_load_graphics( ), PDF_begin_template_ext( ) and the georeference suboption of
the viewports option of PDF_begin/end_page_ext( )
option description
epsg (Integer; exactly one of epsg or wkt must be supplied) Specifies the coordinate system as an EPSG refer-
ence code. Note that Acrobat does not support EPSG codes for type=geographic; use wkt in this case.
wkt (String with up to 1024 ASCII characters; exactly one of epsg or wkt must be supplied) Specifies the coordi-
nate system as a string of Well Known Text (WKT). WKT is recommended for custom coordinate sys-
tems without any EPSG code.
filename (Name string; will be interpreted according to the filenamehandling global op-
tion, see Table 2.3) Name of a disk-based or virtual file containing a 3D model.
len (C language binding only) Length of filename (in bytes). If len = 0 a null-terminated
string must be provided.
Scope any except object. The returned handle can be used until the next call to PDF_end_
document( ).
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 PDF_
create_3dview( ). Default: first
script (Hypertext string) String containing JavaScript code to be executed when the 3D model is instantiated.
Default: no script
views (List of 3D view handles) List of predefined views for the 3D model. Each list element is a 3D view handle
created with PDF_create_3dview( ). The type option used when creating the views with PDF_create_
3dview( ) must match the type option in PDF_load_3ddata( ). Default: empty list
len (C language binding only) Length of username (in bytes). If len = 0 a null-terminat-
ed string must be provided.
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 (in PHP: 0) since it signals
an error.
Details The 3D view handle can be attached to 3D models with the views option in PDF_load_
3ddata( ) or can be used to create 3D annotations with PDF_create_annotation( ) or 3D-
related actions with PDF_create_action( ).
Scope any except object. The returned handle can be used until the next call to PDF_end_
document( ).
camera2world (List of 12 floats) 3D transformation matrix specifying position and orientation of the camera in world co-
ordinates (see description below). Default: the initial view defined internally in the 3D model
camera- (Float; must not be negative; will be ignored if camera2world is not specified) Distance between the cam-
distance era 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.
type (Keyword; required if the view will be used in PDF_load_3ddata( ) with type=PRC) Specify the type of 3D
data (default: U3D):
PRC The view will be used in PDF_load_3ddata( ) with type=PRC.
U3D The view will be used in PDF_load_3ddata( ) with type=U3D.
U3Dpath (Hypertext string; will be ignored if the camera2world option is specified; only for type=U3D) A View
Node name used to access a view node within the 3D artwork.
Camera position. The position of the camera can be specified with the camera2world
option. Alternatively, JavaScript code can be attached to position and align the camera
towards the model. The PDFlib Cookbook contains sample code for attaching such Java-
Script code to a 3D model.
The following values can be supplied to the camera2world option for common cam-
era positions. x, y, and z are suitable values which describe the position of the camera.
These values should satisfy the stated conditions (see below):
View from the front:
{-1 0 0 0 0 1 0 1 0 x y z} x small, y large negative, z small
Isometric view, i.e. the direction of projection intersects all three axes at the same angle.
There are exactly eight such views, one in each octant:
{0.707107 -0.707107 0 -0.5 -0.5 0.707107 -0.5 -0.5 -0.707107 x y z}
x, y, z large positive
The x, y, z values should be selected depending on the position and size of the model.
Large means the values should be significantly larger than the size of the model in or-
der to provide a large enough distance between the camera and the model. If the value
is too large the model will appear very small and will quickly get out of sight when ro-
tating the view. If the value is too small the model may not completely fit into the view.
Small means the absolute value should be small compared to the large value and
should not exceed the size of the model very much.
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 or percentage) Opacity for some render modes. Default: 0.5
rendercolor (RGB color) Auxiliary color. This color will be used by several render modes. Default: black
type (Keyword; PDF 1.7) Render mode for displaying the 3D artwork (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.
IllustrationDisplays 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.
3Dactivate (Option list; only for type=3D) Specifies when the 3D annotation should be activated and its state upon
activation/deactivation. Supported suboptions:
enable (Keyword) Specifies when the animation should be enabled (default: click):
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.
enablestate (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.
disable (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.
disablestate (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)
3Ddata (3D handle; only for type=3D; required) 3D handle created with PDF_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 indi-
rectly. Multiple 3D annotations which 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 PDF_load_3ddata( )), or default (referring to
the models defaultview option), or a 3D view handle created with PDF_create_3dview( ). Default:
default
Assets loaded with PDF_load_asset( ) can also be used with PDF_create_annotation( ) and
type=FileAttachment or Movie.
Load a rich media asset or file attachment from a disk-based or virtual file.
type Keyword designating the type of the loaded asset according to Table 13.5.
1. type=Attachment is implicitly assumed for PDF_add_portfolio_folder/file( ), and for use as suboptions for the attachments option
of PDF_begin/end_document( )
2. in ISO 8859-1 encoding or UTF-16 LE or BE with BOM
len (C language binding only) Length of filename (in bytes). If len = 0 a null-terminated
string must be provided.
Returns An asset handle for rich media or file attachments which can be used with the functions
listed in Table 13.5 until the end of the enclosing document scope. The returned asset
handle cannot be reused across multiple PDF documents.
If errorpolicy=return the caller must check for a return value of -1 (in PHP: 0) since it
signals an error. If the function call fails you can request the reason of the failure with
PDF_get_errmsg( ).
Details This function can be used with all PDF compatibility levels if type=Attachment, and re-
quires PDF 1.7ext3 for all other types.
Table 13.6 Options for PDF_load_asset( ) with type=Attachment, for PDF_add_portfolio_folder/file( ), and for use as
suboptions for the attachments option of PDF_begin/end_document( )
option description
description (Hypertext string; PDF 1.6; recommended for PDF/A-2/3 and PDF/UA-1) Descriptive text associated with
the file.
document- (Boolean; only for PDF/A-3 and PDF 2.0 and only if the relationship option is specified; not for PDF_
attachment add_portfolio_file/folder( )) Save the associated file also as a document-level attachment (embedded
file). This may be useful for listing the attachments in the user interface of PDF viewers which are not
aware of associated files data structures (this includes Acrobat X/XI/DC). Default: false
external (Boolean; must be false for PDF/A; not for the attachments option and PDF_add_portfolio_file/folder( ))
If true, the contents of the file will not be embedded in the PDF, but only a reference to an external file
will be created. The option external=true is required for movies to make sure that Acrobat will be able
to play the movie. Default: false
filename (Name string) Name of the file. The contents must conform to the requirements listed in Table 13.5
according to the specified type. Unicode file names are supported, but require PDF 1.7 for correct display
in Acrobat. This option can alternatively be provided via the function parameter filename of PDF_load_
asset( ) and PDF_add_portfolio_file/folder( ), but is required if used with the attachments option of PDF_
begin/end_document( ). Only the base part of the filename without any directory components will be
written to the PDF output.
mimetype (String; required for PDF/A-3; not for PDF_add_portfolio_folder( )) MIME type of the file. If the MIME type
is unknown, the string application/octet-stream must be used in PDF/A-3.
name (Hypertext string; not for PDF_add_portfolio_folder( )) Name of the attachment. Default: filename
without any path component
password (String with up to 127 characters; not for PDF/A-2; only if PDI is available; not for PDF_add_portfolio_
folder( )) PDF master password required to open a protected PDF document for fetching its date entries.
relationship (Hypertext string; only for PDF 2.0 and PDF/A-3; required for PDF/A-3; not for PDF_add_portfolio_
folder( )) Relationship of the file to the part of the document with which it is associated. The value may
be an arbitrary string, but the following predefined keywords are listed in the PDF/A-3 standard:
Alternative
The file is an alternative representation (e.g. audio).
Data The file represents information used to derive a visual presentation (e.g. CSV data for a table
or graph).
Source The file is the original source material (e.g. word processor document associated with the
document; spreadsheet associated with an image).
Supplement
The file represents a supplemental representation of the original source or data which may be
more easily consumable (e.g. MathML representation of an equation in an image).
Unspecified
The relationship is not known or cannot be described with the other keywords.
thumbnail (Image handle) Image to be used as thumbnail for the file. The handle must have been created with PDF_
load_image( ) and the image must be a grayscale or RGB image with max. 106x106 pixels. Acrobat ig-
nores the thumbnail for attachments.
activate (Option list) Option list according to Table 13.8 which specifies the style of presentation, default script be-
havior, default view information, and animation style when the annotation is activated.
assets (List of option lists; required) Named asset which can be referenced from Flash content:
asset (Asset handle; required) Handle for an asset loaded with PDF_load_asset( ).
name (Hypertext string with 1-255 characters; the characters : * " < > | must not be used; the last
character must not be a period .; required) Name of the asset which can be used to identify it
in Flash code.
configuration (Option list, required) The configuration option list may contain one or more instance option lists. The
type option helps to describe the behavior for the collection of those instances. For example, a FLV video
file may require a SWF file to view it. Though the primary instance in the configuration may be a SWF
file, the annotation is intended for video playback and thus should have a type of Video. Setting the type
suggests the authors intended use of the assets, which better informs the choices when presenting con-
tent-specific user interfaces during the authoring or editing process. Supported options:
instances (List of option lists; required) Each list specifies a single instance of an asset with settings to
populate the artwork of an annotation. Supported options:
asset (Hypertext string; required) A rich media asset name specified in the assets op-
tion. Only names of rich media assets of type 3D, Flash, Sound, Video may be spec-
ified here.
params (Option list; only for type=Flash) Parameters related to a Flash asset according to
Table 13.10
name (Hypertext string) Unique name of the configuration
type (Keyword) Primary content type for the configuration. Valid keywords are 3D, Flash, Sound,
and Video. Default: the scene type is determined by referring to the type of the file specified
in the first element of the instances option list.
views (List of 3D view handles) 3D view handles returned by PDF_create_3dview( ). If no views are specified, de-
fault values are used for the components of a 3D view, including rendering/lighting modes, background
color, and camera data. Default: empty list
animation (Option list) Preferred method to drive keyframe animations present in the artwork. Supported options:
playcount (Integer) A nonnegative number represents the number of times the animation is played. A
negative integer indicates that the animation is infinitely repeated. Default: -1
speed (Positive Float) A value greater than one shortens the time it takes to play the animation, or
effectively speeds up the animation. This allows authors to change the desired speed of
animations without re-authoring the content. Default: 1
style (Keyword) Specifies the animation style (default: none):
none Keyframe animations should not be driven directly by the viewer application. This
value is used by documents that are intended to drive animations through alter-
nate means such as JavaScript. The remaining suboptions of the animation op-
tion will be ignored.
linear Keyframe animations are driven linearly from begin to end. This results in a repet-
itive playthrough of the animation, such as in a walking motion.
oscillating Keyframe animations should oscillate along their time range. This results in a
back-and-forth playing of the animation, such as exploding or collapsing parts.
condition (Keyword) Specifies when the annotation will be activated (default: clicked):
clicked The annotation is explicitly activated by a user action or script.
opened The annotation is activated as soon as the page that contains the annotation receives the
focus as current page.
visible The annotation is activated as soon as any part of the page that contains the annotation
becomes visible.
presentation (Option list) Specifies how the annotation and user interface elements will be laid out and drawn: Sup-
ported options are listed in Table 13.9.
scripts (List of hypertext strings) List containing the names of rich media assets of type=JavaScript which have
been embedded with PDF_load_asset( ) and specified in the assets suboption of the richmedia option.
An empty list means that no script is executed. Default: empty list
view (Keyword or 3D view handle) Specifies the activation view of 3D rich media. The handle must also be con-
tained in the views suboption of the richmedia option list. If the views option was not specified default
values for the components of a 3D view will be used. Supported keyword (default: first):
first The first element in the views suboption of the richmedia option list
navigation- (Boolean) Default behavior of the navigation pane user interface element. If true the navigation pane is
pane visible when the content is initially activated. Default: false
passcontext- (Boolean) Indicates whether a context click on the rich media annotation is passed to the media player
click runtime or is handled by the PDF viewer. If false the PDF viewer handles the context click. If true, the
PDF viewers context menu is not visible, and the user sees the context menu and any custom items gen-
erated by the media player runtime. Default: false
style (Keyword) Specifies how the rich media will be presented (default: embedded):
embedded embedded within the PDF page
windowed in a separate window specified by the window option list
toolbar (Boolean) Default behavior of an interactive toolbar associated with this annotation. If true a toolbar is
displayed when the annotation is activated and given focus. Default: true for type=3D, false otherwise
transparent (Boolean) Indicates whether the page content is displayed through the transparent areas of the rich me-
dia content. If true the rich media artwork is composited over the page content using an alpha channel.
If false the rich media artwork is drawn over an opaque background prior to composition over the page
content. Default: false
window (Option list) Size and position of the floating window for style=windowed. Coordinates are expressed in
user or default coordinates depending on the usercoordinates option. The behavior is similar to when
the annotation options zoom and rotate are set to false. Supported suboptions:
heightdefault
(Float) Default height of the window. Default: 216 (in default coordinates)
widthdefault
(Float) Default width of the window. Default: 288 (in default coordinates)
/DC
binding (Keyword) Specifies to which entity the Flash content is bound (default: none):
background
The Flash content is bound to the background and is rendered behind any 3D model content
or Flash foreground elements in the active annotation. For a given RichMedia annotation
there can be one active instance that has a params option list with binding=background. If
more than one is specified, the last instance specified for the background is used.
foreground
The Flash content is bound to the foreground and is rendered in front of the 3D model and the
background Flash content in the active annotation. If more than one instance has
binding=foreground, the Flash content is rendered in order from back to front, each instance
composited over prior instances using its alpha channel.
material The Flash content is bound to a material that is part of 3D content. If that material is applied
to geometry within a 3D scene, the Flash object appears to be playing upon this object as if
conforming to the surface of the object.
none The Flash content is unbound and is not visible at playback time.
cuepoints (List of option lists) A video can contain cue points that are encoded in the video stream or may be creat-
ed by an associated ActionScript within the Flash content. Each option list specifies a state that relates
the cue point to an action that may be passed to the application or may be used to change the appear-
ance. Cue points in the Flash content are matched to the cue points declared in the PDF file by the values
specified by the name or time options. Supported options:
action (Action list) Action that is executed if this cue point is triggered, meaning that the Flash
content reached the matching cue point during its playback. Supported action trigger:
activate Actions to be performed if this cue point is triggered, meaning that the Flash con-
tent reached the matching cue point during its playback.
name (Text string; required) Name of the cue point to match against the cue point within the Flash
content and for display purposes.
time (Float; required) The time value of the cue point in milliseconds to match against the cue
point within the Flash content and for display purposes. A dummy value can be provided.
type (Keyword) Type of the cue point:
Event An event is a generic cue point of no specific significance other than that a corre-
sponding action is triggered.
Navigation
A navigation cue point is an event encoded in a Flash movie (FLV). A chapter stop
may be encoded so that when the user requests to go to or skip a chapter, a navi-
gation cue point is used to indicate the location of the chapter.
flashvars (Hypertext string) Formatted name value pairs passed to the Flash player context when activated. For
the format specifics see the document Using FlashVars to pass variables to a SWF, TechNote tn_16417,
available at www.adobe.com/go/tn_16417. Default: no data is sent to the Flash player
materialname (Hypertext string; required if binding=material) The material name that content is to be bound to.
settings (Hypertext string) A text string used to store settings information associated with a Flash instance. This
value is passed by the ActionScript ExternalInterface command multimedia_loadSettingsString.
Default: undefined
key (Name string) The name of the document info field, which may be any of the stan-
dard names, or an arbitrary custom name (see Table 14.1). There is no limit for the num-
ber 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 im-
poses a maximum length of value of 255 bytes.
len (Only for PDF_set_info2( ), and only for the C language binding) Length of value (in
bytes). If len = 0 a null-terminated string must be provided.
Details The supplied info value will only be used for the current document, but not for all docu-
ments generated within the same object scope. If the autoxmp option has been supplied
to PDF_begin/end_document( ) PDFlib will automatically create synchronized XMP docu-
ment metadata from the info fields supplied to PDF_set_info( ).
Document info fields override corresponding properties in XMP document metada-
ta supplied to the metadata option of PDF_begin/end_document( ).
PDF/X Info fields with key=Title and key=Creator must be supplied with non-empty values. Al-
ternatively in PDF/X-4 and PDF/X-5 the metadata option of PDF_begin_document( ) with
the dc:title and xmp:CreatorTool XMP properties can be supplied.
Only the values True and False are allowed for the Trapped info field.
PDF/UA An info field with key=Title must be supplied with a non-empty value. Alternatively, the
metadata option of PDF_begin_document( ) with the dc:title XMP property can be sup-
plied.
Scope any; if used in object scope the supplied values will only be used for the next document.
1. See dublincore.org
Creator Software used to create the document (as opposed to the Producer of the PDF out-
put, which is always PDFlib). Acrobat displays this entry as Application.
Trapped Indicates whether trapping has been applied to the document. Allowed values are
True, False, and Unknown.
any other name User-defined document information field. PDFlib supports an arbitrary number of
fields. A custom field name should only be supplied once. See also moddate option
of PDF_begin/end_document( ).
Custom document info fields must not contain any of the following characters if
XMP metadata is created (via the autoxmp or metadata options): & \ < > " space
Fields which are used for standard identification are not allowed.
Table 14.2 Suboptions for the metadata option in PDF_begin/end_document( ), PDF_begin/end_page_ext( ), PDF_load_
font( ), PDF_load_iccprofile( ), PDF_load_image( ), PDF_begin_template_ext( ), PDF_open_pdi_page( ) and the
templateoptions option of PDF_load_graphics( )
option description
compress (Boolean; not for PDF_begin/end_document( )) Compress the XMP metadata stream in the PDF output. If
the option is only supplied in PDF_begin_page_ext( ) but not in PDF_end_page_ext( ), its value takes pre-
cedence over the default. Default: false
PDF/A-1 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 PDF_load_image( ) and PDF_load_graphics( ); can not be combined with filename)
XMP metadata present in an image or graphics file 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 as well as in
SVG graphics. If no XMP metadata is found in the image or graphics file this option doesnt have any ef-
fect. Default: false
filename (Name string; required unless keepxmp is supplied) The name of a file containing well-formed XMP meta-
data. It will be interpreted according to the filenamehandling global option, see Table 2.3.
strict (Boolean) If false, certain XMP violations are not reported as errors, but are silently fixed. If true, such
violations trigger an exception. Default: false
PDF/A The XMP identification properties for PDF/A are created automatically.
PDFlib synchronizes relevant entries in user-supplied XMP streams to standard doc-
ument info fields (similar to autoxmp mode which synchronizes document info fields to
XMP). However, PDFlib does not synchronize other XMP entries to custom document
info fields. Additional PDF/A requirements for XMP document metadata are discussed
in the PDFlib Tutorial. The following validation is applied to XMP metadata:
> PDF/A-1: document-level XMP must conform to XMP 2004 or include an extension
schema description. The schema description for document-level XMP can be sup-
plied in PDF_begin_document( ) or PDF_end_document( ).
> PDF/A-2/3: document-level and component-level (e.g. page) XMP must conform to
XMP 2005 or include an extension schema description. The schema description for
component-level XMP can be supplied with the respective component-level XMP
(e.g. in PDF_begin_page_ext( )) or with the document-level XMP in PDF_begin_
document( ).
PDF/X The XMP identification properties for PDF/X-4/5 are created automatically.
PDF/VT The XMP identification properties for PDF/VT are created automatically.
PDF/UA The XMP identification properties for PDF/UA are created automatically.
Cookbook A full code sample can be found in the Cookbook topic interchange/starter_pdfua1.
tagname Name of the items element structure type. The following groups of element
types are supported according to Table 14.3 (see PDFlib Tutorial for details):
> standard element types (a detailed description of standard element types can be
found in the PDFlib Tutorial)
> pseudo element types which are not structure elements
> The tag name Plib_custom_tag implies use of a custom element type (this is equiva-
lent to customtag=true); the actual tag name must be supplied in the tagname option.
Custom element types require the rolemap document option.
The tag name can alternatively be provided via the tagname option which overrides this
parameter.
optlist An option list specifying details of the item. All inheritable settings will be in-
herited 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:
> General option: hypertextencoding (see Table 2.3)
> Tag control and accessibility options according to Table 14.4:
ActualText, Alt, customtag, E, inline, Lang, tagname, Placement, Title
> Options related to Artifacts according to Table 14.4:
artifactsubtype, artifacttype, Attached
> Table-related options according to Table 14.4:
ColSpan, Headers, id, RowSpan, Scope, Summary
> Geometry options according to Table 14.4:
BBox, Height, usercoordinates, Width
> Options for the relationship of elements according to Table 14.4: index, parent
> Option for attaching a bookmark according to Table 14.4: bookmark
> Option for specifying a list property according to Table 14.4: ListNumbering
> Option for inserting a nested structure element according to Table 14.4: tag
Details Start a new structure element or Artifact (collectively called item). By default, the new el-
ement is inserted as a child of the currently active item. However, another position in
the structure tree can be specified with the parent and index options. Structure elements
can be nested to an arbitrary level. Except for pseudo and inline types structure ele-
heading and P, H, H1, H2, H3, H4, H5, H6, H7, H8 etc. (BLSEs)
paragraph
Japanese Ruby1 (grouping), RB1, RT1, RP1, Warichu1 (grouping), WT1, WP1
deprecated The following standard element types are deprecated in PDF 2.0 and should not be used:
Art, BlockQuote, TOC, TOCI, Index, NonStruct, Private, Quote, BibEntry, Code
user-defined The tag name Plib_custom_tag must be supplied in the tagname parameter. The actual tag name which
elements will be written to PDF must be supplied in the tagname option. Custom element types require the rolemap
document option.
ments are not bound to the page where they have been opened, but can be continued
on an arbitrary number of pages. It is recommended to avoid empty structure elements.
Structure elements and Alt/ActualText attributes must be properly nested according
to the rules in the PDFlib Tutorial. Some decorative elements are automatically tagged
as Artifact; see PDFlib Tutorial for details.
PDF/A Although Tagging is required for PDF/A-1a/2a/3a, there are no specific requirements for
tag usage or nesting. We recommend to obey PDF/UA requirements.
Scope page; for grouping elements also document; must always be paired with a matching PDF_
end_item( ) call. This function is only allowed in Tagged PDF mode.
ActualText (Hypertext string; not for pseudo tags except in PDF 1.5 with ASpan; if used in PDF 1.4 the inline option
must be set to false) Equivalent replacement text for the content item and its kids.
Alt (Hypertext string; not for pseudo tags except in PDF 1.5 with ASpan; if used in PDF 1.4 the inline option
must be set to false) Word or phrase as alternate description for the content item and its children. It
should be provided for figures, images, etc. which cannot be recognized as text.
artifact- (Keyword; only for tagname=Artifact and artifacttype=Pagination; PDF 1.7) Subtype of the artifact:
subtype Header, Footer, Watermark
artifacttype (Keyword; only for tagname=Artifact) Identifies the artifact type of the content item:
Pagination Ancillary page features such as running heads or page numbers
Layout Typographic or design elements such as footnote rules or table shading
Page Production aids such as cut marks and color bars
Background (PDF 1.7) Images or colored blocks that run the entire length and/or width of the page or a
structural element.
Attached (Keyword list; only for tagname=Artifact and artifacttype=Pagination or Background with full-page
background artifacts) Specify the edges of the page, if any, to which the artifact is logically attached. The
list contains one to four of the keywords Top, Bottom, Left, and Right. Including both Left and Right or
both Top and Bottom indicates a full-width or full-height artifact, respectively.
BBox (Rectangle; only for tagname=Artifact, Figure, Form, Table; required for artifacttype=Background,
otherwise optional, but recommended for Reflow) The elements bounding box in default coordinates (if
usercoordinates=false) or user coordinates (if usercoordinates=true). PDFlib automatically creates
the BBox for placed images, graphics, PDF pages (with tagname=Figure or Artifact), form fields (with
tagname=Form or Artifact) and tables created by the table engine (with tagname=Table or Artifact).
bookmark (Bookmark handle; not for inline and pseudo tags) Handle for a bookmark which will be associated with
the structure element.
ColSpan (Integer; only for tagname=TH and TD) Number of table columns spanned by a cell. Default: 1
contents (String; only for PDF_begin_mc( )) Content string describing the marked content sequence.
customtag (Boolean; requires the rolemap document option) If true, the element type name supplied in the
tagname option is a custom element type which must be mapped to a standard element type via the
rolemap document option. Default: false
Setting this option to true is equivalent to providing the parameter tagname=Plib_custom_tag.
E (Hypertext string; not for pseudo tags except ASpan; requires PDF 1.5 for structure tags) Abbreviation ex-
pansion for the content item. It should be provided for explaining abbreviations and acronyms. Acrobats
Read Aloud feature considers the expansion text as a separate word even in the absence of explicit word
breaks.
Headers (List of strings; only for tagname=TH and TD; PDF 1.5) Each string in the list is the identifier of a table head-
er cell (TH element) which is associated with the cell. The identifier(s) must have been assigned to the tar-
get cell with the id option. If multiple header cells are referenced, row headers should be listed before col-
umn headers. Within these groups headers should be ordered from most specific to most general.
Height (Float; only for tagname=Figure, Form, Formula, Table, TD, TH) Height of the element in default coordi-
nates (if usercoordinates=false) or user coordinates (if usercoordinates=true)
id (String; not for pseudo elements and inline elements except Note) Assign an identifier to the element.
The string must be unique among all structure elements.
index (Integer; not for pseudo tags) The zero-based index at which to insert the element within the parent.
Starting at this position, existing descendants of the parent are shifted upwards. Values between 0 and
the current number of children can be supplied. The value -1 adds the element at the end, i.e. as the new
last item. This is identical to supplying the current number of elements as index. Default: -1
inline (Boolean; only for tagname=Code, BibEntry, Note, Quote, Reference, Span) If true, the content item is
written inline and no structure element is created. Default: true
Lang (String; not for pseudo tags except ASpan) Language identifier for the content item in the format de-
scribed in Table 3.3 for the lang option. This can be used to override the documents dominant language
for individual content items.
PDF/UA-1: the natural language must be specified with this option or with the lang option of PDF_be-
gin_document( ).
List- (Keyword; only for tagname=L; required in PDF/UA-1; must be None in PDF/UA-1 for lists where no LI child
Numbering contains any Lbl element) Numbering system used for the contents of the Lbl elements in a numbered
list or the symbol which precedes each item in an unnumbered list (default: None):
Circle Open circular bullet
Decimal Decimal arabic numerals (19, 1099, ...)
Disc Solid circular bullet
LowerAlpha Lowercase letters (a, b, c, ...)
LowerRoman
Lowercase roman numerals (i, ii, iii, iv, ...)
None No autonumbering; Lbl elements (if present) contain arbitrary text without numbering. In
this case any graphics representing the lists labels should be marked as Artifact.
Square Solid square bullet
UpperAlpha Uppercase letters (A, B, C, ...)
UpperRoman
Uppercase roman numerals (I, II, III, IV, ...)
parent (Item handle; not for pseudo tags) The elements parent as returned by an earlier call to PDF_begin_
item( ) or the activeitemid keyword of PDF_get_option( ). The value 0 refers to the structure tree root. -
1 refers to the currently active element. In other words, parent=-1 opens a child of the current element.
Pseudo and inline element types are not allowed as parent. Default: -1
Placement (Keyword; not for pseudo elements and the inline elements Span,Quote, Note, Reference, BibEntry,
and Code) Specifies positioning of the element with respect to the enclosing reference area. This is rele-
vant when the document is reformatted or exported to other formats. The option Placement=Block is
recommended for Figure, Formula, Form, Link, Annot elements if they are created as children of group-
ing elements (default: Inline):
Before Placed so that the before edge of the elements allocation rectangle coincides with that of
the nearest enclosing reference area.
Block Stacked in the block progression direction within an enclosing reference area or parent BLSE.
End Placed so that the end edge of the elements allocation rectangle coincides with that of the
nearest enclosing reference area.
Inline Packed in the inline progression direction within an enclosing BLSE.
Start Placed so that the start edge of the elements allocation rectangle coincides with that of
the nearest enclosing reference area.
RowSpan (Integer; only for tagname=TH and TD) The number of table rows spanned by a cell. Default: 1
Scope (Keyword; only for tagname=TH; PDF 1.5; recommended for PDF/UA-1) One of the keywords Row, Column, or
Both indicating whether the table 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.
Summary (Hypertext string; only for tagname=Table; PDF 1.7) Summary of the tables purpose and structure
tag (Option list) Additional structure element which will be inserted as a child of the current element. All op-
tions according to Table 14.4 are supported as suboptions. Tags can be nested to an arbitrary level.
tagname (Name string; except in PDF_add_table_cell( ) this option is required for abbreviated tagging with the
tag option) Name of a standard element type or a pseudo element type according to Table 14.3, or name
of a custom tag. The value of this option can alternatively be provided via the function parameter
tagname.
Specify the option customtag=true or the parameter tagname=Plib_custom_tag to supply custom tag
names. In this case the tagname option contains an arbitrary name of a custom tag for which a mapping
to a standard element type must have been defined with the rolemap option of PDF_begin_document( ).
Custom element type names are restricted to 127 winansi characters or a sequence of Unicode characters
which expands to a maximum of 127 UTF-8 bytes. Custom element type names must not start with the
reserved prefix Plib.
Title (Hypertext string; not for inline and pseudo tags; recommended for headings in PDF/UA-1) Title of the
structure element. The title may be useful for viewing or manipulating the structure tree in Acrobat.
user- (Boolean) If false, BBox, Width and Height are expected in default coordinates; otherwise user coordi-
coordinates nates will be used. Default: the value of the usercoordinates global option
Width (Float; only for tagname=Figure, Form, Formula, Table, TD, TH) Width of the element in default coordi-
nates (if usercoordinates=false) or user coordinates (if usercoordinates=true)
id The items handle, which must have been retrieved with PDF_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. An item can only be closed if all of its chil-
dren have been closed before. After closing an item its parent becomes the active item.
Scope page for inline items; for grouping items also document; must always be paired with a
matching PDF_begin_item( ) call. This function is only allowed in Tagged PDF mode.
Abbreviated tagging. Structure elements and artifacts can be created with PDF_begin/
end_item( ) pairs. As an alternative, abbreviated tagging is available with the tag option
of the following functions (see Table 14.5):
> PDF_add_table_cell( ) and the corresponding options in PDF_add_table_cell( ):
fitgraphics, fitimage, fitpath, fitpdipage, fittextline, fittextflow, fitannotation, fitfield
> PDF_begin_document( ): abbreviated tagging can be used to create the root element of
the structure hierarchy
> PDF_create_annotation( )
> PDF_create_field( )
> PDF_draw_path( )
Abbreviated tagging cannot be used to create grouping elements except when used
with PDF_begin_document( ) (since all other functions create direct content, which is not
allowed for grouping elements). A detailed description of abbreviated tagging can be
found in the PDFlib Tutorial.
Table 14.5 Option for abbreviated tagging in PDF_add_table_cell( ) and the corresponding fit* options in PDF_add_
table_cell( ), PDF_create_annotation( ), PDF_create_field( ), PDF_draw_path( ), PDF_fit_graphics( ), PDF_fit_image( ), PDF_
fit_pdi_page( ), PDF_fit_table( ), PDF_fit_textflow( ), PDF_fit_textline( ), and the matchbox option of various functions
option description
tag (Option list) Create a structure element or artifact for the placed content. The suboptions listed in Table
14.4 can be used.
id The items handle, which must have been retrieved with PDF_begin_item( ), and
must not yet have been closed. Pseudo and inline items can not be activated.
Details Suspending a structure element and activating it later gives additional flexibility for ef-
ficiently 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.
While the parent and index tagging options (see Table 14.4) can be used to insert struc-
ture elements at a specific location in the structure tree, PDF_activate_item( ) can be used
to add more content to a previously created structure element.
In order to work around problems in Acrobat, no direct content should be added im-
mediately after calling PDF_activate_item( ), but only other structure elements.
Scope document, page; this function is only allowed in Tagged PDF mode.
tagname The name of the marked content sequence. The following tags are support-
ed:
> All inline and pseudo tags in Table 14.3.
> The tag name Plib_custom can be used for custom entries with user-defined proper-
ties.
> The tag name Plib is reserved.
optlist The following options for marked content sequences are supported:
> General option: hypertextencoding (see Table 2.3)
> Options for standard properties of the marked content sequence; the following sub-
set of tagging options in Table 14.4 can be used:
ActualText, Alt, artifactsubtype, artifacttype, contents, customtag, E, Lang, ListNumbering,
Placement, tagname
> The tags Plib_custom and Plib additionally support the properties option in Table 14.6.
Details A marked content sequence with the specified tag and properties is started. If no op-
tions are provided a sequence without any properties is created. Marked content se-
quences can be nested to an arbitrary level. The user is responsible for creating properly
nested sequences of PDF_begin/end_item( ) and PDF_begin/end_mc( ).
Scope page, pattern, template, glyph; must always be paired with a matching PDF_end_mc( ) call
in the same scope.
Table 14.6 Option for user-defined properties of tags with PDF_begin_mc( ) and PDF_mc_point( )
option description
properties (List of option lists; only for tagname=Plib and tagname=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
Details All marked content sequences must be closed before calling PDF_end_page_ext( ).
Scope page, pattern, template, glyph; must always be paired with a matching PDF_begin_mc( )
call in the same scope.
tagname The name of the marked content point. The following tags are supported:
> All inline and pseudo tags in Table 14.3.
> The tag name Plib_custom can be used for custom entries.
> The tag name Plib is reserved.
Details A marked content point with the specified tag name and properties will be created. If no
options are provided a marked content point without any properties will be created.
Open a new node in the document part hierarchy (requires PDF/VT or PDF 2.0).
optlist An option list specifying document part hierarchy options according to Table
14.7: associatedfiles, dpm
PDF/VT The first call to PDF_begin_dpart( ) implicitly creates the root node of the document part
(DPart) hierarchy. It is an error to call PDF_begin_dpart( ) more than once at the top level.
A call to PDF_begin_dpart( ) followed by a call to PDF_begin_page_ext( ) defines the
start of the page range of a document part. All subsequent pages until the next call to
PDF_begin_dpart( ) belong to the same document part. All calls together create the docu-
ment part hierarchy as a tree structure which can contain two types of nodes:
> Inner nodes have one or more other nodes as descendants. The descendants may be
inner nodes or leaf nodes, but a particular inner node may not contain descendants
of both types.
> Leaf nodes describe the page(s) in a range. Leaf nodes never have descendant nodes.
Scope document; this function must always be paired with a matching PDF_end_dpart( ) call.
associatedfiles (List of asset handles; only for PDF 2.0 and PDF/A-3) Asset handles for associated files. The files must have
been loaded with PDF_load_asset( ) and type=attachment.
dpm (POCA container handle; may be supplied to PDF_begin_dpart( ) or PDF_end_dpart( ), but not to both
functions for the same document part) Handle for a dictionary container created with PDF_poca_new( )
which contains document part metadata for the new node. The dictionary must have been created with
the option usage=dpm.
Close a node in the document part hierarchy (requires PDF/VT or PDF 2.0).
optlist An option list specifying document part hierarchy options according to Table
14.7: associatedfiles, dpm
PDF/VT The first call to PDF_end_dpart( ) after PDF_end_page_ext( ) implicitly defines the end of
the page range belonging to a leaf of the document part hierarchy. The calls to PDF_
begin_dpart( ) and PDF_end_dpart( ) must match when PDF_end_document( ) is called.
Scope document; this function must always be paired with a matching PDF_begin_dpart( ) call.
& alignment
in add/create_textflow() 96
&name option list macro call in fit_textflow() 101 in create_annotation() 217
suboption for leader in fit/info_textline() and
3D add/create_textflow() 92
alpha keyword for the type suboption of
3Dactivate in create_annotation() 250
softmask in create_gstate() 140
3Ddata in create_annotation() 250
alphachannelname in load_image() 171
3Dinitialview in create_annotation() 250
alphaisshape in create_gstate() 139
3Dinteractive in create_annotation() 250
Alt in begin_item() and the tag option 264
3Dshared in create_annotation() 250
alternate
3Dview in create_action() 232
in create_devicen() 163
angle keyword in info_textline() 93
A angularunit suboption for georeference 243
acrobat in info_font() 72 animation suboption for the activate suboption
action of richmedia in create_annotation() 255
in begin/end_page_ext() 53 annotation suboption for targetpath in
in create_annotation() 217 create_action() 235
annotationtype in add_table_cell() and
in create_bookmark() 213
suboption for the caption option 115
in create_field/group() 226
annotcolor in create_annotation() 217
in end_document() 43
antialias
in process_pdi() 201
in shading() and suboption of the shading
activate suboption of richmedia in
graphics appearance option 165
create_annotation() 254
api in info_font() 71, 72
activeitemid keyword in get_option() 29
apiversion sub-suboption for portfolio in
activeitemindex keyword in get_option() 29
PDF_add_portfolio_file/folder() 242
activeitemisinline keyword in get_option() 29
area suboption for fill in fit_table() 118
activeitemkidcount keyword in get_option() 29 areaunit suboption for georeference 243
activeitemname keyword in get_option() 29 artbox in begin/end_page_ext() 53
activeitemstandardname keyword in artifactsubtype in begin_item() and the tag
get_option() 29 option 264
actual in info_font() 71 artifacttype in begin_item() and the tag option
actualtext 264
in set_text_option(), fit_textline(), and ascender
fill_textblock() 75 in info_font() 71
ActualText in begin_item() and the tag option in load_font() 65
264 keyword in info_textline() 93
addfitbox suboption for wrap in fit_textflow() asciifile in set_option() 25
108 assets
addpath keyword in add_path_point() 151 sub-suboption for portfolio in
adjustmethod in add/create_textflow() 98 PDF_add_portfolio_file/folder() 242
adjustpage suboption of richmedia in
in fit_image/fit_graphics/fit_pdi_page() 174 create_annotation() 254
in fit_pdi_page() 198 associatedfiles
advancedlinebreak in add/create_textflow() 98 in begin/end_dpart() 270
align in begin/end_page_ext() 53
in draw_path() 125 in end_document() 43
keyword for the transform option in in load_image(), load_graphics(),
begin_pattern_ext() 188 open_pdi_page(), and begin_template_ext()
alignchar in fit/info_textline() 125 186
xid
keyword in info_textline() 94
Z
keyword in info_graphics() 182 zoom
keyword in info_image() 176 in add_nameddest() and suboption for
keyword in info_pdi_page() 200 destination in create_action(),
suboption for pdfvt in begin_template_ext() create_annotation(), create_bookmark() and
189 begin/end_document() 237
in create_annotation() 222
in define_layer() 59
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
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
292
Index
Note that options and keywords are listed separately in Appendix B, page 275.
A I
abbreviated tagging 266 ICC Profiles 159
action lists in option lists 12 ICC-based color 13
alignment (position option) 127 iccbased keyword 15
All spot color name 161 iccbasedcmyk keyword 15
Author field 260 iccbasedgray keyword 15
iccbasedrgb keyword 15
B Ideographic Variation Sequences (IVS) 67
image functions 169
Bzier curve 145 import functions for PDF (PDI) 191
Boolean values in option lists 11 info fields 259
inline option lists for Textflows 102
C inner cell box for table cells 113
circles in option lists 16 invisible text 78
CMYK color 13 IVS 67
cmyk keyword 14
color functions 157 K
color in option lists 14
Keywords field 260
Creator field 260
keywords in option lists 11
curves in option lists 16
D L
Lab color 13
DeviceN color 13
lab keyword 14
devicen keyword 15
landscape mode 54
document and page functions 41
linearized PDF 43
document information fields 259
lines in option lists 15
document scope 17
list values in option lists 8
Dublin Core 259
F M
metadata 261
fast Web view 43
float and integer values in option lists 12
floats in option lists 11 N
font scope 17 Nchannel color spaces 163
fontsize in option lists 12 nested option lists 8
function scopes 17 None spot color name 161
numbers in option lists 11
G
global options 25 O
glyph scope 17 object scope 17
graphics functions 135, 177 option list syntax 7
gray keyword 14 outline text 78
H P
handles in option lists 12 page scope 17
page size formats 52
path painting and clipping 149
Index 293
path scope 17 PDF_draw_path() 153
pattern color 14 PDF_ellipse() 147
pattern keyword 15 PDF_elliptical_arc() 147
pattern scope 17 PDF_encoding_set_char() 87
pCOS functions 191, 203 PDF_end_document() 42
PDF import functions (PDI) 191 PDF_end_dpart() 270
PDF Object Creation API (POCA) 37 PDF_end_font() 85
PDF_activate_item() 267 PDF_end_glyph() 86
PDF_add_nameddest() 236 PDF_end_item() 266
PDF_add_path_point() 151 PDF_end_layer() 61
PDF_add_portfolio_folder() 238, 239 PDF_end_mc() 268
PDF_add_table_cell( ) 112 PDF_end_pattern() 168
PDF_add_textflow() 95 PDF_end_template_ext() 184
PDF_align() 143 PDF_endpath() 150
PDF_arc() 146, 147 PDF_fill_graphicsblock() 212
PDF_arcn() 146 PDF_fill_imageblock() 210
PDF_begin_document() 41 PDF_fill_pdfblock() 211
PDF_begin_dpart() 270 PDF_fill_stroke() 149
PDF_begin_font() 84 PDF_fill_textblock() 208
PDF_begin_glyph_ext() 85 PDF_fill() 149
PDF_begin_item() 262 PDF_fit_graphics() 180
PDF_begin_layer() 60 PDF_fit_image() 174
PDF_begin_mc() 268 PDF_fit_pdi_page() 198
PDF_begin_page_ext() 52, 53 PDF_fit_table( ) 115
PDF_begin_pattern_ext 167 PDF_fit_textflow() 103
PDF_begin_template_ext() 183 PDF_fit_textline() 89
PDF_circle() 146 PDF_get_apiname() 22
PDF_clip() 150 PDF_get_buffer() 51
PDF_close_font() 69 PDF_get_errmsg() 22
PDF_close_graphics() 180 PDF_get_errnum() 21
PDF_close_image() 173 PDF_get_opaque() 22
PDF_close_pdi_document() 194 PDF_get_option() 28
PDF_close_pdi_page() 197 PDF_get_string() 30
PDF_closepath_fill_stroke() 150 PDF_info_font() 70
PDF_closepath_stroke() 149 PDF_info_graphics() 181
PDF_closepath() 148 PDF_info_image() 175
PDF_concat() 143 PDF_info_matchbox() 133
PDF_continue_text() 82 PDF_info_path() 155
PDF_continue_text2() 82 PDF_info_pdi_page() 199
PDF_convert_to_unicode( ) 23 PDF_info_pvf() 35
PDF_create_3dview() 246 PDF_info_table( ) 120
PDF_create_action() 231 PDF_info_textflow() 109
PDF_create_annotation() 215 PDF_info_textline() 91
PDF_create_bookmark() 213 PDF_lineto() 145
PDF_create_devicen() 162 PDF_load_3ddata() 245
PDF_create_field() 223 PDF_load_asset() 251
PDF_create_fieldgroup() 225 PDF_load_font() 63
PDF_create_gstate() 139 PDF_load_graphics() 177
PDF_create_pvf() 34 PDF_load_iccprofile() 159
PDF_create_textflow() 101 PDF_load_image() 169
PDF_curveto() 145 PDF_makespotcolor() 161
PDF_define_layer() 58 PDF_mc_point() 269
PDF_delete_dl( ) 33 PDF_moveto() 145
PDF_delete_path() 156 PDF_new_dl( ) 32
PDF_delete_pvf() 35 PDF_new() 32
PDF_delete_table( ) 121 PDF_new2() 32
PDF_delete_textflow() 111 PDF_open_pdi_callback() 193
PDF_delete() 33 PDF_open_pdi_document() 191
294 Index
PDF_open_pdi_page() 195 rectangles in option lists 16
PDF_pcos_get_number( ) 203 RGB color 13
PDF_pcos_get_stream( ) 204 rgb keyword 14
PDF_pcos_get_string( ) 203 rich media 251
PDF_poca_delete() 38
PDF_poca_insert() 39
PDF_poca_new() 37
S
PDF_poca_remove() 40 scopes 17
PDF_process_pdi() 201 separation color space 13
PDF_rect() 148 setup functions 32
PDF_restore() 139 skewing 143
PDF_resume_page() 56 spot color (separation color space) 13
PDF_rotate() 142 spot keyword 14
PDF_save() 138 spotname keyword 15
PDF_scale() 142 standard page sizes 52
PDF_set_graphics_option() 137 strings in option lists 9
PDF_set_gstate() 141 Subject field 259
PDF_set_info() 259 subscript 78
PDF_set_info2() 259 superscript 78
PDF_set_layer_dependency() 59 SVG 177
PDF_set_option() 25
syntax of option lists 7
PDF_set_text_option() 79
PDF_set_text_pos() 80
PDF_setcolor() 157 T
PDF_setfont() 80 table formatting 112
PDF_setlinewidth() 138 template scope 17
PDF_setmatrix() 144 text appearance options 89
PDF_shading_pattern() 166 text filter options 89
PDF_shading() 164 text functions 63
PDF_shfill() 166
Textflow: inline option lists 102
PDF_show_xy() 81
Title field 259
PDF_show_xy2() 81
Trapped field 260
PDF_show() 81
PDF_show2() 81
PDF_skew() 143 U
PDF_stringwidth() 82 Unichar values in option lists 11
PDF_stringwidth2() 82 Unicode ranges in option lists 11
PDF_stroke() 149 Unquoted string values in option lists 10
PDF_suspend_page() 56
PDF_translate() 142
PDF/A or PDF/X output intent 201 V
PDFlib Personalization Server (PPS) 207 vector graphics functions 177
PDI (PDF import) 191
POCA (PDF Object Creation API) 37
polylines in option lists 15
W
PPS (PDFlib Personalization Server) 207 web-optimized PDF 43
R X
raster image functions 169 XMP metadata 261
Index 295
ABC
PDFlib GmbH
Franziska-Bilek-Weg 9
80339 Mnchen, Germany
www.pdflib.com
phone +49 89 452 33 84-0
fax +49 89 452 33 84-99
Licensing contact
sales@pdflib.com
Support
support@pdflib.com (please include your license number)