
wxPdfDocument
wxPdfDocument is a C++ class that allows wxWidgets applications to generate PDF files. The project was started as a port of the freely available PHP class FPDF (Free PDF) using the wxWidgets library. Several extension scripts found on the FPDF web pages have been incorporated. In the meantime, several extensions have been added that are not found in FPDF, including support for OpenType fonts, kerning, and layers. wxPdfDocument does not rely on libraries such as PDFlib or ClibPDF, which are subject to fees, at least for commercial use. wxPdfDocument is licensed under the wxWidgets (formerly wxWindows) license. This means that the component can also be used free of charge in commercial applications and modified according to the user’s needs. Current and future development is and will continue to be strongly influenced by the well-known Java PDF library iText.
is the latest version. The API documentation can be viewed online. The component itself is hosted on GitHub:
wxPdfDocument - Generation of PDF documents from wxWidgets applications
Features
The most important features of wxPdfDocument are:
- Choice of unit, page format, and page margins
- Management of page headers and footers
- Automatic page breaks
- Automatic line breaks and text alignment
- Support for various graphic formats (GIF, JPEG, PNG, and WMF)
- Colors
- Links
- 14 Adobe standard fonts
- TrueType and Type1 fonts (with or without embedding) and support for various character set encodings
- TrueType Unicode, OpenType Unicode, and Type0 fonts (for Chinese, Japanese, and Korean) in the Unicode version
- Page compression
- Graphics operations for creating simple drawings
- Definition of area boundaries
- Creation of an outline view
- Rotations
- Password protection and/or access rights management for documents
This class can be used to create documents in many languages: Western European, Central European, Cyrillic, Greek, Baltic, and Thai, provided that TrueType or Type1 fonts with the required character sets are available. Chinese, Japanese, and Korean are also supported in Unicode mode.
Examples
The following examples illustrate the PDF generation capabilities offered by wxPdfDocument:
- Hello world!
- Header, footer, page break and image embedding
- Line breaks and colors
- Multi-columns
- Tables
- Links and flowing text
-
Font embedding (Updated in 1.3.0 - Feb 2025)
- Document outline
-
Chinese/Japanese/Korean (You need CJK support installed for Acrobat Reader)
- Using clipping areas
- Graphics primitives
- Setting access permissions
-
Setting password protection (User password: Hello, Owner password: World)
- Rotating text and image
- Embedding Windows Meta File image
- Geometric transformations
- Color gradients
-
Barcodes (Updated in 1.3.0 - Feb 2025)
- Simple charting examples
- Simple label printing examples
- Document level JavaScript
- PDF forms example
- Text styling using simple markup language
- Alpha transparency and image masks
- Internal templates
- External templates
- Kerning
- Using a font with 2 different encodings
- List of usable system fonts
-
Layers (Optional Content Groups):
- Direct glyph writing
-
Indic script support:
- File attachments
History
A detailed version history can be found in the change log.