PDFlib Cookbook


Block Handling and PPS

block_below_contents Fill PDFlib Blocks so that they are placed below the imported page.
business_cards Output an imported PDF page several times, with its Blocks filled with different personalized data.
clone_blocks Clone Blocks from another document. Use POCA to copy a modified Block.
create_blocks_with_poca Create PDFlib Blocks with the POCA interface.
dump_block_properties Dump Block information from an existing PDF document.
duplicate_block Duplicate a PDFlib Block to any number of pages.
fill_converted_formfields Output an imported PDF page with its Blocks filled with different personalized data.
linked_textblocks Link multiple Textflow Blocks.
nested_blocks Create nested Blocks.
override_block_rectangle Fill Blocks of an imported PDF page while changing the rectangle coordinates.
pdfvt1_with_blocks Create a large number of invoices in a single PDF and make use of PDF/VT-1 features.
query_block_color Query the background color of Blocks.
query_block_properties Import a PDF page containing Blocks and query various Block properties.
starter_block Import a PDF page containing Blocks and fill text and image Blocks with some data.


blendmode updated Demonstrate all blend modes available in PDF.
blendmode_effects updated Demonstrate various color effects with blend modes.
color_All_for_cropmarks Create crop marks which will be visible on all color separations, using the special spot color "All".
color_gradient updated Fill some area or text with a smooth transition from one color to another.
colorize_image_with_DeviceN_color Create a DeviceN color space based on two Pantone spot colors to colorize a 2-channel image in raw format.
devicen_color Define and use several DeviceN colors.
iccprofile_to_image updated Assign an ICC profile to an image.
overprint Demonstrate overprint controls using CMYK and DeviceN colors or blend modes.
recombine_color_channels Colorize images and place all colorized images on top of each other.
reverse_printing 'Reverse printing' is the process of printing text or graphical elements by applying ink to the surrounding area and keeping the text unprinted.
softmask_effects updated Create a soft mask based on arbitrary geometric objects.
spot_color Define and use several spot colors.
spot_color_shading Define and use several spot colors as shading.
starter_color Demonstrate all supported color spaces.
svg_color_extension Demonstrate SVG color extensions: Load SVG graphics with non-sRGB color spaces including CMYK and spot color.
web_colornames Create a list of Web colors with color names and RGB color patches.

Complex Scripts

arabic_formatting Arabic formatting issues.
bidi_formatting Create several variants of Bidirectional text output.
gaiji_eudc Demonstrate the use of SING and EUDC fonts for merging a Gaiji character into an existing font.
starter_shaping Demonstrate text shaping for Arabic, Hebrew, Hindi and Sanskrit scripts. Right-to-left text is reordered according to the Bidi algorithm.


barcode_font Output text in a barcode font.
character_references Demonstrate character references.
font_configuration Configure font resources and search for fonts.
font_info Query various properties of a font such as font name, font style, or encoding.
font_lister Create a list of all fonts available in the 'searchpath' directories.
font_metrics_info Query various font-related metrics such as ascender or descender.
glyph_availability Check the availability of glyphs in a font.
glyph_replacement Show the effects of glyph substitution in case of glyphs missing in the font.
opentype_feature_tester Demonstrate all supported typographic OpenType features after checking whether a particular feature is supported in a font.
opentype_features_for_cjk Demonstrate the use of OpenType features for CJK fonts and text.
retain_font Performance benefits of keeping a font open across multiple documents.
simulated_fontstyles Simulate italic and bold text
starter_fallback Starter sample for fallback fonts
starter_opentype Demonstrate various typographic OpenType features after checking whether a particular feature is supported in a font.

Form Fields

form_and_layers Define two layers for English or German contents and hide or show them via form field buttons.
form_checkbox Create form fields of type "checkbox".
form_combobox Create a form field of type "combobox" for choosing an item from a list or changing an existing item.
form_listbox Create a form field of type "listbox" for choosing an item from a list.
form_multiline_textfield Create a form field of type "textfield" for entering multiline text.
form_pushbutton Create form fields of type "pushbutton" for executing the "Print" and "Save As" commands."
form_radiobutton Create a field group with three form fields of type "radiobutton".
form_synchronized_fields Create multiple form fields of type 'textfield' with synchronized values
form_tab_order Define the position of each form field in the tab order, i.e. when the user presses the "Tab" key.
form_textfield_fill_with_js Fill a form text field with a value using JavaScript.
form_textfield_height Determine the height of a form field of type "textfield" with respect to the font size and vice versa.
form_textfield_input_check Check whether the date entered in a form field of type "textfield" has been formatted correctly.
form_textfield_input_format Format the data entered in a form field of type "textfield" according to the specified rules
form_triggers_js_actions Demonstrate all possibilities to trigger a JavaScript action from a form field.
starter_formfields Create linearized PDF which is encrypted and contains some form fields.

General Programming

aes256_unicode_password updated Create AES-256-encrypted document with a master password containing Unicode characters.
data_from_memory Create a PVF file which holds an image or PDF and import the data from the PVF file.
error_handling Demonstrate different strategies with respect to exception handling.
initial_view Define the initial viewing properties for a document, such as zoom, page number, navigation tab, or title bar.
license_key Apply the PDFlib license key using various methods to get rid of the demo stamp.
metric_topdown_coordinates Output text using metric coordinates in a topdown coordinate system.
permission_settings Change the permission settings so that only commenting the PDF is allowed.
repeated_contents Create contents which are used identically on multiple pages, such as fixed headers or footers.
starter_basic Create simple text, vector graphics and image output.

Geospatial PDF

georeferenced_image updated Attach geospatial reference data to an image.
starter_geospatial updated Import an image with a map and add geospatial reference information.


arrows Create an arrow using different methods.
dashed_lines Create some dash patterns to be used as line styles.
fill_pattern Define some hatching patterns and use them to fill arbitrary shapes.
fill_rules Define some overlapping vector graphics and fill them using various methods.
hierarchical_layers Define a layer hierarchy using the parent and child options.
layers_and_bookmarks Define two layers and hide or show them via bookmarks.
overprinting_text Create text which will overprint other page contents instead of knocking it out.
pdfclock Create an analog clock with current time.
rounded_rectangle Create a rectangle with rounded corners.
stamp_on_print_layer Place a stamp on a layer which is only visible upon printing.
starter_graphics Create some basic examples of vector graphics.
starter_layer Define several layers, output images and text into them and define particular layers to be visible when opening the document.
starter_svg Load SVG graphics and fit into a box.
transparent_graphics Create some transparent graphics objects.


align_text_at_image Align text at an image.
alpha_channel Demonstrate use of an integrated alpha channel in TIFF and/or PNG images.
center_image_on_card Place an image on an imported PDF card.
clip_image Clip image.
frame_around_image Draw a frame around an image.
image_color_manipulation Manipulate image colors with the 'decode' and 'chromakey' options.
image_dimensions Get the dimensions of an image for various purposes.
image_from_url Read an image from an URL and place it in a PDF document.
image_mask Place an image and apply a mask to it.
image_rounded_corners Place an image with rounded corners.
integrated_clipping_path Place an image and apply its integrated clipping path.
multi_page_tiff Convert a TIFF image containing one or more frames to PDF.
starter_image Load and place an image using various options for scaling and positioning.
tiling_pattern Define a tiling pattern containing an image and use it to cover the page background with tiles.
transparent_images Create transparent images.

Interactive Elements

acrobat_menu_items Upon opening the page, create a full list of all menu item names in Acrobat.
custom_stamp_annotation Create a custom stamp annotation which uses a template as 'normal' icon; the template contains the stamp text
link_annotations On images and text lines, create links to open PDF files or Web pages, or to execute JavaScript.
markup_annotations Create various types of markup annotations directly and in a Textflow.
nested_bookmarks Create bookmarks which are nested in several levels.
starter_portfolio updated Package multiple PDF and other documents into a PDF portfolio.
triggers_for_javascript_actions Demonstrate all possibilities to trigger JavaScript actions (except form fields).

Document Interchange

associated_files Demonstrate associated files at various locations of the document (requires PDF 2.0 output).
control_nexpress_trays For NexPress digital color printing machines, create special annotations to control the input tray.
embed_xmp Embed custom XMP metadata in a document.
import_xmp_from_pdf Retrieve the XMP metadata from an imported document and write all document-level XMP metadata to the output PDF.


javascript_for_renditions Screen annotation for video: Demonstrate use of Screen annotations, Renditions and Rendition actions to play video and sound.
screen_annotations Manipulate renditions with JavaScript.


insert_toc Create some pages, assign labels to them and insert a table of contents at the beginning of the document.
page_sizes Create some pages with different sizes.
page_x_of_y Create a running footer "Page x of y" on each page of the document.
reverse_page_order Create pages in reverse page order.

Path Objects

aligned_path_objects Path objects are attached at a line by an attachment point and with an alignment.
arrow_as_path_object Example for a path object: arrow with rounded arrow head and two attachment points.
clipping Demonstrate the effect of different PDF clipping rules.
crop_marks Create crop marks which specify the "cutting area".
import_path_from_image Import a path object from an image file and use it for filling, stroking or clipping.
path_objects Create various shapes with path objects.
starter_path Starter sample for path objects: create basic examples of path object construction and use.
svg_path Create a path object from a description in SVG path syntax.


javascript_for_3d_animation updated Load a PRC 3D model and animate it with JavaScript.
javascript_for_3d_camera updated JavaScript for 3D camera: load a PRC 3D model and align camera with JavaScript.
richmedia_3d updated Load a PRC 3D model and create a 3D RichMedia annotation.
starter_3d updated Create a 3D model and load it into a U3D annotation.

PDF Import

clip_imported_page Clip imported PDF page.
clone_page_boxes Clone the ArtBox, TrimBox, BleedBox, CropBox, and MediaBox entries of an imported PDF page.
crop_imported_pages Crop the pages of an existing PDF document.
fill_imported_form_fields Import all pages from a PDF document and fill form fields.
import_in_reverse_order Read the pages of an input PDF document and output them in reverse order.
import_pages_into_layers Import two pages and place them on two layers on the same output page.
import_repeated_contents In order to keep the output file size small, handles to imported PDF pages or images should be reused for repeated contents.
rotate_pages updated Rotate the pages of an existing PDF document.
scale_down_imported_pages Place A4 pages from an imported PDF as A5 pages in the output document.
shift_imported_page new Place an imported PDF page and shift it horizontally and vertically.
split_document Split PDF document in separate output documents where each output document contains a range of one or more pages from the input document.
stamp_pages Place a stamp on the pages of an existing PDF document.
starter_pcos Dump information from an existing PDF document.
starter_pdfimpose Import all pages from one or more existing PDFs, and place c x r pages on each sheet of the output PDF (imposition).
starter_pdfmerge Merge pages from multiple PDF documents.


clone_pdfa Clone PDF/A and PDF/X standard documents.
facturx_add_xml_to_pdfa3b Factur-X (=ZUGFeRD 2.1): add XML invoice to PDF.
facturx_invoice_pdfa3b Create a PDF/A-3b Factur-X (=ZUGFeRD 2.1) invoice and attach a delivery receipt as additional explanatory document.
form_fields_pdfa2b Form fields within PDF/A-2b.
images_to_pdfa2b Convert grayscale, CMYK or RGB image files in TIFF or JPEG format to PDF/A-2b, taking care of color space issues.
invoice_pdfa2a Combined PDF/UA-1 and PDF/A-2a invoice generation demo.
markup_annotations_pdfa3b Create various types of markup annotations in PDF/A-3b mode.
starter_pdfa1b Create output conforming to PDF/A-1b.
starter_pdfa2b Create PDF/A-2b conforming output with layers, transparency and PDF/A attachments.
text_to_pdfa2b Output text conforming to PDF/A-2b, taking care of color space and font issues.
transparent_stamp_for_pdfa1 Apply a transparent stamp to an existing PDF/A-1 document while maintaining PDF/A-1 conformance.
xmp_extension_schema_pdfa2b updated Demonstrate an XMP extension schema for PDF/A-1.
xmp_extension_schema_with_type_pdfa2b updated Demonstrate a complex XMP extension schema for PDF/A-1.
zugferd1_add_xml_to_pdfa3b ZUGFeRD 1: Add XML invoice to PDF.
zugferd1_invoice_pdfa3b Create a PDF/A-3b ZUGFeRD 1 invoice from scratch.
zugferd2_add_xml_to_pdfa3b ZUGFeRD 2: Add XML invoice to PDF.
zugferd2_invoice_pdfa3b Create a PDF/A-3b ZUGFeRD 2 invoice from scratch.


clone_pdfua updated Clone PDF/A, PDF/UA and PDF/X standard documents.
form_fields_pdfua1 Create accessible form field according to PDF/UA.
image_with_link_pdfua1 Create PDF/UA-1 document where an image is used as background for a link.
inline_tags_in_textflow_pdfua1 Create Tagged PDF with Textflow where the tags are supplied inline in the text.
invoice_pdfua1 Create combined PDF/UA-1 and PDF/A-2a invoice.
list_pdfua1 Demonstrate PDF/UA list tagging.
merge_and_stamp_pdfua1 Merge PDF/UA documents including the document structure trees. Additional text is stamped onto each page and tagged as Artifact.
parallel_columns_pdfua1 Demonstrate how to tag multiple columns in parallel with activate_item().
scan_with_ocr_pdfua1 Tagging for invisible OCR text which accompanies a scanned page.
starter_pdfua1 Create PDF/UA-1 document with various content types including structure elements, artifacts and interactive elements.
table_of_contents_pdfua1 Demonstrate PDF/UA list tagging.
table_pdfua1 Demonstrate automatic table tagging.
tag_out_of_order_pdfua1 Demonstrate how to create Tagged PDF out of order.
textflow_pdfua1 Create Tagged PDF containing a Textflow with appropriate structure elements on several pages.


starter_pdfvt1 Create a large number of invoices in a single PDF and make use of PDF/VT-1 features.


clone_pdfx Clone PDF/A and PDF/X standard documents.
starter_pdfx3 updated Create PDF/X-3-compliant output.
starter_pdfx4 updated Create PDF/X-4 conforming output with layers and transparency.
starter_pdfx5n updated Create PDF/X-5n conforming output with an image and DeviceN color.


align_decimals Align decimal numbers in a table.
colorize_cells Provide some table cells with a colored background.
fit_annotation_into_cell Fit link annotation into a table cell.
fit_formfield_into_cell Fit a form field into a table cell, e.g. to create a pushbutton in the cell.
mixed_table_contents Demonstrate how to place various kinds of contents in table cells spanning one or more columns or rows.
nested_tables Place a sub-table in one table cell.
repeat_cell_contents Show how table cell contents will be repeated on the next table instance if a cell or a row is split.
spread_oversized_table Output a table on 2 x m pages as it is needed to fit it completely.
spread_text_over_cells Use the 'continue' option of add_table_cell() to continue a Textflow in another cell.
starter_table Create table which may span multiple pages.
table_contact_sheet Create a contact sheet with photos and their labels.
table_invoice Create an invoice using the table formatter.
table_rotated_text Create a table containing rotated text.
table_row_height Define the height of the rows in a table.
table_schedule Create a weekly booking plan for the meeting rooms of a company.
table_timesheet Create a time sheet for the working hours of an employee.
vertical_text_alignment Demonstrate vertical alignment of text lines and Textflows in a table cell.

Text Output

emoji_sequences Modify emoji with Unicode sequences.
image_as_text_fill_color Create outline text and fill the interior of the glyphs with an image.
invisible_text Output invisible text on top of an image.
leaders_in_textline Use dot leaders to fill the space between text and page number such as in a table of contents.
shadowed_text Create a shadowed text line with the 'shadow' option of fit_textline.
simple_stamp Create a stamp across the page which runs diagonally from one corner to the other.
starter_textline Demonstrate various options for placing a text line.
text_as_clipping_path Output text filled with an image.
text_on_a_path Create text on a path.
transparent_text Create some transparent text.


avoid_linebreaking Create a Textflow and define various options for line breaking.
bulleted_list Output numbered and bulleted lists.
continue_note_after_text Insert a dot sequence automatically at the end of a Textflow fitbox after the last word which can be shown together with the dots completely inside the fitbox.
continue_textflow_in_annotation Continue Textflow in annotation: store overflow text in a Text annotation, also called 'sticky note'.
create_interactive_index In a Textflow define some terms to be indexed and create a sorted index from the indexed terms.
current_text_position Demonstrate how the current text position can be used to output simple text, text lines, or Textflows next to one another.
distance_between_paragraphs Control the distance between adjacent paragraphs.
dot_leaders_with_tabs Use leaders to fill the space defined by tabs between left-aligned and right-aligned text, such as in a table of contents.
drop_caps Create initial drop cap at the beginning of text.
fill_polygons_with_text Define arbitrary polygons to be filled with text.
footnotes_in_text Create footnotes (superscript text) in a Textflow provided with links to jump to the footnote text.
keep_lines_together Control the lines kept together on the page.
numbered_list Output numbered lists with the numbers left- or right-aligned.
rotated_text Create text output which does not run horizontally, but at some angle.
starter_textflow Create multi-column text output which may span multiple pages.
tabstops_in_text Create simple multi-column layout using tab stops.
text_on_color Place a text line and a Textflow on a colored background.
text_with_image_clipping_path Use the clipping path from a TIFF or JPEG image to shape text output.
textflow_with_shading Create multi-column output with text and use a shading where the geometry of each shading matches the respective text column.
transparent_part_of_text Use gstate in Textflow, e.g. for transparency/opacity.
underlined_text Create underlined text.
vertical_alignment_in_fitbox Control the vertical alignment of text in the fitbox.
weblink_in_text Create a Textflow and integrate colorized Web links in the text.
widows_and_orphans Create multi-column text output which may span multiple pages.
wrap_text_around_images Place images within a Textflow.
wrap_text_around_polygons Use arbitrary polygons as wrapping shapes for text to wrap around.

Type 3 Fonts

starter_type3font Create a simple Type 3 font from vector data.
type3_bitmaptext Create a simple Type 3 font from image data.
type3_subsetting Demonstrate Type 3 font definition, use, and subsetting.
type3_vectorlogo Create a Type 3 font which contains a single logo derived from a PDF page.