PDFlib Migration Guide
PDFlib Migration Guide
Latest PDFlib versions covered in this document: PDFlib 9.4 and 10.0.1
The PDFlib API generally remains compatible among major releases. Sometimes API
methods, parameters or options are phased out and replaced with an improved succes-
sor which is more general or more powerful than the old method. In these situations
the new PDFlib version declares the old method as deprecated without changing the
functionality in any way. The new method is always preferable. New code should not
use deprecated API methods; existing code should switch to the replacement method as
soon as possible. Deprecated methods may be removed in a future release.
This Guide contains recommendations for users who migrate existing PDFlib appli-
cation code which has been developed with an older PDFlib release. It explains how to
identify deprecated API features in application code. Once identified the deprecated
features should be replaced with the recommended newer ones.
PDFlib 10 removes several old features which have been deprecated in earlier ver-
sions. Legacy applications which still use these features must apply the replacements
detailed in this document before they can switch to PDFlib 10. In most cases one-to-one
replacement methods or options are available.
The majority of changes affects only very old applications which haven’t been up-
dated in many years.
Note Since PDFlib 10 removes deprecated features it is strongly recommended to check your applica-
tion for deprecated method calls and options with PDFlib 9.4 to ensure forward compatibility.
Java binding. The pdflib.jar module is created from source code which contains
@Deprecated annotations and @deprecated Javadoc comments for all deprecated API
methods so that the compiler can warn about the use of deprecated methods. The Java
compiler emits a warning similar to the following:
javac -classpath pdflib.jar:. image.java
Note: image.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
If you supply the compiler option -Xlint:deprecation the name and location of the depre-
cated API methods are shown:
The Javadoc documentation for PDFlib lists all deprecated methods along with the re-
commended replacement method, e.g.
double get_value(java.lang.String key, double modifier) Deprecated.
Use PDF_get_option().
In Eclipse you must attach pdflib.jar as library to make information about deprecated
API methods available to the integrated Java compiler. If deprecated API methods are
found in your code, the name of the deprecated method is displayed with a strike-out,
and a pop-up box informs about the method’s status (see Figure 1.1). These messages are
also listed in the Problems view.
.NET binding with Visual Studio. The PDFlib package marks all deprecated API meth-
ods so that calls to deprecated methods are marked with an underline, and IntelliSense
pop-ups are shown with a warning for calls to deprecated API methods when editing the
code.
The PDFlib assembly also contains »Obsolete« attributes for all deprecated API meth-
ods so that the compiler can warn about the use of deprecated API methods.
Visual Studio emits warnings for calls to deprecated API methods if warning level 2 is
enabled in Project, Properties, Build, Errors and warnings. The warning includes the re-
commended replacement method:
image.cs(37,13): warning CS0618: 'PDFlib_dotnet.PDFlib.get_value(string, double)' is
obsolete: 'Deprecated, use PDF_get_option().'
.NET binding with command-line compiler. The dotnet run command also emits warn-
ings for deprecated API methods in the compilation phase, provided the <WarningLevel>
element in the project file is set to 2 or higher:
image.cs(37,13): warning CS0618: 'PDFlib.get_value(string, double)' is obsolete:
'Deprecated, use PDF_get_option().'
C++ binding with Visual Studio, GCC or Clang. The header file pdflib.hpp contains suit-
able attributes for all deprecated API methods so that the compiler can warn about the
use of deprecated methods.
Visual Studio emits warnings for deprecated API calls if warning level 3 is enabled in
Project, Properties, Configuration Properties, C/C++, General/Warning Level: Level 3 (/W3):
C binding with Visual Studio, GCC or Clang. The pdflib.h header file contains suitable
attributes for all deprecated API methods so that the compiler can warn about the use of
deprecated methods.
Visual Studio emits warnings for deprecated API calls if warning level 3 is enabled in
Project, Properties, Configuration Properties, C/C++, General/Warning Level: Level 3 (/W3):
image.c(44): warning C4996: 'PDF_get_value': was declared deprecated
Logging for all language bindings. Calls to deprecated API methods are identified in
the log file for all language bindings with logging class api=1. It can be set as follows (see
PDFlib API Reference for more details on logging):
p.set_option("logging={filename=deprecated.log classes={api=1}}");
With this setting the log file contains a warning for calls to deprecated API methods, e.g.
PDF_get_value(p_0x2599c20, "major", 0.000000)
[PDF_get_value() is deprecated since PDFlib 9]
PHP language binding. The PDFlib extension module for PHP contains information
about deprecated API methods so that the PHP interpreter can warn about deprecated
methods. Depending on the PHP configuration warnings about deprecated method
calls are written to the configured PHP error log file, the Web server log file, the Win-
dows event log/system log, or stderr/stdout. The following directive in php.ini configures
the log file:
error_log = /var/log/php.errors
Perl language binding. The PDFlib module for Perl emits warnings about deprecated
API methods at runtime if the predefined warning category deprecated is enabled, which
is true by default. Perl emits a warning similar to the following:
PDF_get_value(): Deprecated, use PDF_get_option(). at image.pl line 31.
Use the following instruction or the -X command-line option of the Perl interpreter to
disable warnings about deprecated API methods on a module basis:
no warnings 'deprecated';
Warnings for deprecated API methods can be enabled on a module basis with the fol-
lowing instruction in the application code:
use warnings 'deprecated';
With this setting the log file contains a message for calls with deprecated options, e.g.
PDF_create_annotation(p_0x1529c20, 100.000000, 400.000000, 400.000000, 500.000000,
"FileAttachment", "filename=foo.jpg mimetype=image/jpeg")
[Option "filename" is deprecated since PDFlib 9]
[Option "mimetype" is deprecated since PDFlib 9]
These options must be replaced in the application; see Section 2.2, »Deprecated Options
and Keywords which are no longer available in PDFlib 10«, for details.
Table 2.2 pCOS paths as replacements for deprecated keys of PDF_get_pdi_value( ) and PDF_get_pdi_parameter( )
key for PDF_get_pdi_value( ) and
PDF_get_pdi_parameter( ) pCOS path for PDF_pcos_get_number( ) and PDF_pcos_get_string( )
vdp/blockcount length:pages[...]/blocks
/Root/Pages/Count length:pages
/Rotate pages[...]/Rotate
version pdfversion
vdp/Blocks/<name>/<property> pages[...]/blocks/<name>/<property>
vdp/Blocks[...]/<property> pages[...]/blocks[...]/<property>
vdp/Blocks/<name>/Custom/<property> pages[...]/blocks/<name>/Custom/<property> or
pages[...]/blocks[...]/Custom/<property>
isempty pages[...]/isempty
filename filename
/Info/<key> /Info/<key>
tagged tagged
pdfx pdfx
Table 2.3 Deprecated global parameters for PDF_set/get_value( ) and PDF_set/get_parameter( ) and their replacements
deprecated
deprecated parameter since replacement method and option
resource categories
Encoding, FontAFM, FontOutline, FontPFM, PDFlib 9 same-named options of PDF_set_option( ); multiple entries
HostFont, ICCProfile, resourcefile, can be set with a single call;
searchpath PDF_get_option( ): use option resourcenumber to iterate
over all values
document properties
page properties
ArtBox, BleedBox, CropBox, TrimBox PDFlib 6 PDF_begin/end_page_ext( ) with options artbox, bleed-
box, cropbox, trimbox
color
preserveoldpantonenames PDFlib 9.3 none; old-style PANTONE color names are no longer in use
font handling
ascender, ascenderfaked, capheight, PDFlib 7 PDF_info_font( ) with same-named keywords; for the
capheightfaked, descender, numerical values fontsize=1 must be supplied;
descenderfaked, fontencoding, fontname,
parameter fontencoding: use keyword encoding
fontmaxcode, xheight, xheightfaked
monospace PDFlib 7 none; only for the obsolete concept of standard CJK fonts
text output
images
graphics state
fillrule in PDF_set_parameter( ) PDFlib 9.3 PDF_set_graphics_option( ) with option fillrule
interactive elements
miscellaneous
iccwarning, fontwarning, glyphwarning, PDFlib 7 corresponding API method with option errorpolicy
imagewarning, pdiwarning, warning
Table 2.4 Deprecated PDFlib API options or keywords which have been removed in PDFlib 10, and their replacements
deprecated
deprecated option or keyword since replacement option or action
font and text
PDF_create_textflow( ): textwarning PDFlib 7 errorpolicy
PDF_fit_textline( ): locallink, pdflink, weblink PDFlib 7 matchbox in PDF_fit_textline( ) and PDF_
create_annotation( ) to create links
PDF_load_font( ): autocidfont PDFlib 9 none; not functional
PDF_load_font( ): autosubsetting, subsetlimit PDFlib 10.0.1 These options don’t work with the font
subsetting implementation in PDFlib 10.
They are still accepted for compatibility, but
don’t have any effect on subsetting.
PDF_load_font( ), PDF_info_font( ) and PDF_fill_ PDFlib 9 configure TrueType/OpenType fonts or use
textblock( ): option and Block property monospace host fonts
PDF_load_font( ): fontwarning PDFlib 7 errorpolicy
PDF_load_font( ): kerning PDFlib 8 readkerning
text option glyphwarning PDFlib 7 glyphcheck
PDF_info_textline( ): keywords scalex, scaley PDFlib 9 fitscalex/fitscaley
PDF_info_textline( ): keyword unmappedglyphs PDFlib 8 unmappedchars
PDF_info_textflow( ): keyword remainchars PDFlib 8 none; worked reliably only under certain
conditions
PDF_fit/info_textline( ), PDF_add/create_textflow( ) and PDFlib 9.3 none; these features are enabled auto-
PDF_fill_textblock( ): option features with keywords vrt2 matically for fonts in vertical mode
and vert
PDF_begin_font( ): colorize PDFlib 10 option colorize of PDF_begin_glyph_ext( )
interactive elements
PDF_create_action( ): actionwarning PDFlib 7 errorpolicy
PDF_create_action( ): defaultdir, parameters and PDFlib 9.3 none
operation for type=Launch1
PDF_create_annotation( ): annotwarning PDFlib 7 errorpolicy
PDF_create_annotation( ): filename and mimetype PDFlib 9 attachment and options filename and
mimetype of PDF_load_asset( )
PDF_create_annotation( ): popup PDFlib 10 none; the connection is created automati-
cally if parentname is specified for the pop-
up annotation.
PDF_create_annotation( ): option template with PDFlib 10 none; PDFlib always creates the required
suboptions normal/rollover/down: keyword viewer appearance stream
PDF_create_field( ), PDF_create_fieldgroup( ): PDFlib 7 none; didn’t have any effect
fieldwarning
PDF_create_field( ), PDF_create_fieldgroup( ): errorpolicy PDFlib 9.3 none; didn’t have any effect
PDF_create_bookmark( ): option destination with sub- PDFlib 6 options fontstyle and textcolor of PDF_
options fontstyle and color create_bookmark( )
Table 2.5 Features deprecated in PDF 2.0 which are still available in PDF 1.x mode
PDFlib features deprecated in PDF 2.0 notes
PDF_begin_document( ): permissions with keyword Restricting document accessibility is deprecated in PDF 2.0.
noaccessible
PDF_begin/end_document( ): viewerpreferences, Prepress viewer preferences are deprecated in PDF 2.0.
suboptions printarea, printclip, viewarea, viewclip
PDF_begin_page_ext( ) and PDF_end_page_ext( ): Separation dictionaries are deprecated in PDF 2.0.
separationinfo
PDF_create_annotation( ): type=Movie Use type=RichMedia.
PDF_create_action( ): type=Movie Use type=RichMediaExecute.
PDF_create_gstate( ): blendmode accepts only a single Blendmode arrays are deprecated in PDF 2.0.
keyword, but not a list with multiple values
Features outside of ISO 32000-1. The features listed in Table 2.6 were never part of ISO
32000-1. They work only in Acrobat, but not in third-party viewers. If any of these fea-
tures is used, PDFlib 9.4 emits a warning (PDFlib 10: warning in PDF 1.x mode and an er-
ror in PDF 2.0 mode). It is recommended to avoid these features since they are not part
of standard PDF.
Table 2.6 Features outside of ISO 32000 which are still available in PDF 1.x mode
features outside of ISO 32000 notes
PDF_create_field( ) and PDF_create_fieldgroup( ): barcode Barcode fields work only in the full version of Acrobat, but
neither in Acrobat Reader nor third-party viewers.
PDF_begin_document( ): search An attached search index works only in Acrobat, but not in
third-party viewers.
PDF_begin_template_ext( ): watermark Editable watermarks work only in Acrobat, but not in third-
party viewers.
Table 2.7 Obsolete PDF concepts which have been removed from PDFlib 10
deprecated
deprecated concept since notes
PDF versions and standards
PDF 1.3 (1999): PDF_begin_document( ) with option PDFlib 8.1 not relevant
compatibility=1.3
PDF/X-1:2001: PDF_begin_document( ) with option PDFlib 7 superseded by PDF/X-4
pdfx=PDF/X-1:2001
PDF/X-1a:2001, PDF/X-3:2002: PDF_begin_document( ) PDFlib 8.1 superseded by PDF/X-4
with option pdfx=PDF/X-1a:2001 and PDF/X-3:2002
PDF/X-3 standard output intents without embedded ICC PDFlib 9 superseded by PDF/X-3 and PDF/X-4 with
profile and resource category StandardOutputIntent embedded or referenced ICC profile
PDF/X-5g, PDF/X-5pg: PDF_begin_document( ) with option PDFlib 9.3 not accepted in the marketplace
pdfx=PDF/X-5g and PDF/X-5pg
PDF/VT-2: PDF_begin_document( ) with option PDFlib 9.3 not accepted in the marketplace
pdfvt=PDF/VT-2
password security
password encryption: PDF_begin_document( ) with option PDFlib 9.3.1 This combination results in weak RC4
userpassword or masterpassword and compatibility= encryption which should be avoided. Create
1.4 or 1.5 a newer PDF version, preferably PDF 1.7ext8.
font handling
Multiple Master PostScript Type 1 fonts PDFlib 9.3 not relevant
resource fork PostScript Type 1 (LWFN) fonts on macOS PDFlib 9.3 not relevant
SVG fonts, i.e. fonts in SVG files (not OpenType color fonts PDFlib 9.3 deprecated in SVG 2.0 and unsupported in
with SVG glyphs) most browsers
CEF fonts PDFlib 9.3 not used as stand-alone fonts
standard CJK fonts and font option/Block property PDFlib 9 Configure TrueType/OpenType fonts or use
monospace host fonts.
CJK TrueType fonts without Unicode cmap table PDFlib 9.3 Use Unicode-compatible fonts.
image handling
images in GIF and CCITT formats PDFlib 9.4 outdated formats; use PNG or TIFF instead
UCS-2 CMaps PDFlib 9.3 Use encoding=unicode.
PANTONE spot colors
PANTONE Goe coated/uncoated PDFlib 9.1 no longer supported by Pantone, Inc.
PANTONE hexachrome coated/uncoated
PANTONE solid in hexachrome coated
PANTONE solid to process coated
PANTONE solid to process coated EURO
Table 2.8 Deprecated features which are still available in PDFlib 10, but shouldn’t be used
deprecated recommended
deprecated feature since replacement option or action
Encryption with PDF_begin_document( ) and the options PDFlib 10 Remove the password option or increase
userpassword/masterpassword with compatibility=1.6, PDF output compatibility to 1.7ext8 or
1.7 or 1.7ext3 above.
CMaps for CJK legacy encodings, i.e. loading a font with a PDFlib 10 Switch to a Unicode workflow.
predefined CMap (this affects only non-Unicode-aware
language bindings); font option keepnative
PostScript Type 1 fonts PDFlib 9.3.1 Use TrueType or OpenType fonts.
PDF/X-1a:2003: PDF_begin_document( ) with option PDFlib 9.3 Use PDF/X-4.
pdfx=PDF/X-1a:2003
PDF/X-3:2003: PDF_begin_document( ) with option PDFlib 9.4 Use PDF/X-4.
pdfx=PDF/X-3:2003
PDF_begin_font( ): option colorized PDFlib 10 Use option colorized of PDF_begin_
glyph( ); the color status can now be
specified for individual glyphs instead of
only for all glyphs in the font.
PDF_info_font( ): option shapingsupport PDFlib 9.3.1 This keyword couldn’t be used reliably to
test for shaping support of a font.
PDFlib 4 2001
PDFlib 5 2003
PDFlib 6 2004
PDFlib 7 2006
PDFlib 8 2009