PDFlib or a simple PDF export: when the library pays off
PDFlib is a developer library from PDFlib GmbH in Munich, on the market since 1997. It is neither a layout program nor a converter: the application describes each page — text, graphics, images, bookmarks, annotations — and PDFlib writes the PDF from that. The core is written in C and C++ and is called from PHP, Java, .NET, Python and other languages; in our case almost always from PHP, where PDFlib is loaded as an extension. That is more work than an HTML template that a tool converts into a PDF. In return, the result is predictable: every line sits where it should, on the first page as on the last.
Four characteristics point to PDFlib. Volume: many documents in a short time, as a background process on the server. Precision: text flowing into frames and shapes, hyphenation, tables spanning several pages, OpenType fonts with their layout features. Standards: PDF/A for archiving, PDF/X for prepress, PDF/UA-1 for accessibility, PDF/VT for variable data, ZUGFeRD and Factur-X for e-invoicing. Print quality: CMYK, ICC profiles, output intents, PANTONE and HKS spot colours. If one of these applies to your project, PDFlib is a serious option. If two apply, it is usually the right one.
The reverse also holds: if you produce a manageable number of documents a month with a simple layout, have no standard to meet and take the look from a web template anyway, you do not need a PDFlib licence. An open-source HTML-to-PDF solution will do — and we build that just as well, in the same PHP application, with the same tests. We say so in the first conversation, not after the purchase. If requirements are added later, such as e-invoicing or print data for a printer, generation moves to PDFlib while the data side of the application stays as it is. A licence that does nothing you need is not a mark of quality.
PDFlib, PDFlib+PDI, PPS or TET: which product fits
The base product, PDFlib, creates PDFs from scratch: pages, text, graphics, images from SVG, PNG, JPEG, TIFF and other formats, tables and text flow. PDFlib+PDI adds the PDF Import Library. It reads existing PDF pages and reuses them — letterhead as a background, a form, a supplier’s data sheet — combining, stamping and rearranging them without losing PDF/A, PDF/X or PDF/UA conformance along the way. From PDFlib+PDI upwards, pCOS is included as well, which lets an application query information from PDFs. If you assemble documents from existing PDFs, you need PDI. If you only create new ones, you do not.
The PDFlib Personalization Server, PPS for short, is PDFlib+PDI plus blocks for variable data. In a PDF template, the Block Plugin for Acrobat (macOS and Windows) is used to define areas that the application later fills with text, images, SVG or PDF pages; existing form fields can be converted into blocks. The advantage lies in the division of labour: the design lives in the template, the logic in the code. If the layout changes, the template is adjusted, not the application. For web-to-print, personalised marketing material and forms whose look changes more often than their data, PPS is therefore usually the better choice.
TET 6, the Text and Image Extraction Toolkit, works in the opposite direction: it reads text as Unicode, images and metadata from existing PDFs, recognises tables and lists and, if required, outputs the result as TETML, an XML format — for a search index, say, or for further processing in a business application. Each product is licensed commercially, per machine and operating system; development and test systems are included, and support from the manufacturer is available as an optional annual contract. You buy the licence from PDFlib GmbH in your company’s name. We recommend the smallest product that covers your requirements — if you only generate invoices, you do not need PPS.
Invoices, catalogues, mail merge: where PDFlib is used
Since 1 January 2025, businesses in Germany have had to be able to receive e-invoices in B2B trade. ZUGFeRD, the German hybrid e-invoice format, and Factur-X combine two invoices in one file: a human-readable one as PDF/A-3 and a machine-readable one as XML embedded in it. PDFlib supports ZUGFeRD 1.0, 2.0 and 2.1 as well as Factur-X — complete generation, attaching the XML to existing PDF/A documents and reading the XML from incoming invoices via pCOS. Which ZUGFeRD profile you need, up to and including the XRechnung profile, we settle with your accounts department. The real care goes into consistency: what is in the XML has to be in the visible invoice, amount for amount.
Catalogues and data sheets are generated from the data in which they are maintained anyway: PIM, shop, ERP or a database of your own. PDFlib sets text in frames or arbitrary shapes, hyphenates, flows text around images and builds tables that run over several pages — with cells holding text, images, SVG or entire PDF pages. Fonts come as TrueType or OpenType with layout features, as well as WOFF and WOFF2; fallback fonts catch characters missing from the house typeface. Arabic, Hebrew, Thai and Devanagari are covered. When a price changes, the catalogue is generated again, not corrected.
Mail-merge and transactional documents are the third large group: personalised letters, account and transaction statements, contracts, personalised marketing material. For variable print data there is PDF/VT-1, for archiving PDF/A-1, PDF/A-2 and PDF/A-3. Generation runs as a background process on the server, not when a user clicks a button: every run is logged, an interrupted run resumes where it stopped, and every document can be traced back to the record it came from. Anyone sending out a large run at the end of the month needs that traceability more urgently than a prettier layout.
Print data, accessibility, validation: standards that have to be provable
For prepress, PDFlib generates PDF/X-3, PDF/X-4, PDF/X-4p and PDF/X-5n, with output intent and ICC profiles, in greyscale, RGB, CMYK or CIE L*a*b*, with PANTONE and HKS spot colours and with DeviceN. That is the basis for web-to-print: your customer designs a business card, flyer or sign in the browser, a PPS template takes the input, and preview and print file come from the same source. What was on screen ends up on the sheet. Which PDF/X flavour and which output profile apply is set by the printer — and that specification comes before the first line of code.
Accessible PDFs to PDF/UA-1 (ISO 14289-1) are tagged PDFs: headings, paragraphs, lists, tables and images are marked up as structure, the reading order is defined, images carry alternative text, the language is declared. PDFlib generates the tags for tables and for artefacts — content with no meaning when read aloud — automatically; the rest of the structure comes from the application. With generated documents that is an advantage: the structure is built once in the template and applies to every document, instead of each PDF being fixed individually. Whether a legal obligation applies to your documents — for instance under Germany’s Accessibility Strengthening Act (BFSG) or, for federal public bodies, under the accessible IT regulation BITV 2.0 — is for a lawyer to assess case by case.
Incoming PDFs are checked by the application with pCOS before it processes them: page count, metadata, fonts used, ICC profiles, embedded files. A print-data upload portal can thus reject an unsuitable file immediately instead of the problem surfacing in prepress; from incoming ZUGFeRD invoices, pCOS reads the XML. TET extracts text and images for search indexes and business applications. For everything we generate, one rule applies: every standard is validated with independent tools, not merely on the library’s word, and PDF/UA is also tested by hand with a screen reader. A PDF that only claims to meet a standard is caught at the first check — better by us than by the recipient.
Integration and operation: PHP, Symfony, TYPO3, Shopware
In PHP, PDFlib is loaded as an extension that has to match the PHP version on the server. We build generation in where the data lives: into PHP applications of your own based on Symfony or Laminas, as a TYPO3 extension that produces data sheets from records, or as a Shopware plugin that typesets product data sheets or business documents straight from the shop. Generation gets a module of its own with a clear boundary — data in, PDF out — so that templates and logic can be tested separately. Large runs go into a queue and run in the background, not within a page request. The website stays fast while the monthly run is busy next door.
PDFlib runs on the server, which makes operation part of the project. At Sharpness, PDFlib applications run on our own Proxmox VE clusters in the Hetzner data centre in Falkenstein, Germany, each customer environment on its own; PHP version, PDFlib extension, fonts and ICC profiles are maintained there together. Maintenance runs under a service level agreement — with a response time of 24, 8 or 4 hours, billed as a flat monthly fee, net; without an agreement we deal with requests within 48 hours during our business hours, Mon–Thu 9:00–16:00, Fri 9:00–13:00 (CET). On-call cover outside those hours exists only with an SLA. Updates to new PDFlib versions such as PDFlib 11 are tested with the same data in the old and the new version, and the results are compared before we switch.
We calculate in person-days, with separate items for the sample document, templates, implementation, validation and operation. The PDFlib licence is not an item of ours: you buy it from the manufacturer. We give the hourly rate and a price on request and after the initial assessment, not on the phone. The source code is yours and sits in your Git repository, and the PDFlib licence is registered to your company. Existing PDFlib applications we take over with an inventory — PHP version, PDFlib version, templates, fonts, dependencies — and then bring them up to a current PHP version and PDFlib 11. Operation and further development are then in one hand.