wxPdfDocument  1.4.0
Library for generating PDF documents from wxWidgets applications
Loading...
Searching...
No Matches

What is wxPdfDocument?

wxPdfDocument is a C++ class which allows wxWidgets applications to generate PDF files. The code is a port of FPDF - a free PHP class for generating PDF files - to C++ using the wxWidgets library. wxPdfDocument does not make use of any libraries like PDFlib which require a fee at least for commercial usage. wxPdfDocument is published under the wxWidgets (formerly wxWindows) license. This means you may use it for any kind of usage and modify it to suit your needs.

wxPdfDocument offers all advantages of FPDF. Several add-on PHP scripts found on the FPDF web site are incorporated into wxPdfDocument. The main features are:

  • Choice of measure unit, page format and margins
  • Page header and footer management
  • Automatic page break
  • Automatic line break and text justification
  • Image support (GIF, JPEG, PNG and WMF)
  • Colours (Grayscale, RGB, CMYK, Spot colours)
  • Links (internal and external)
  • 14 Adobe standard fonts
  • TrueType and Type1 fonts (with or without embedding) and encoding support
  • TrueType Unicode and Type0 fonts (for Chinese, Japanese and Korean) support in the Unicode build
  • OpenType Unicode fonts support in the Unicode build
  • Page compression
  • Graphics primitives for the creation of simple drawings
  • Definition of clipping areas
  • Bookmarks for outlining the document
  • Rotation
  • Protecting the document by passwords and/or access permissions
  • Text annotations
  • PDF forms (supported field types: text, combo box, check box, radio button, push button)
  • JavaScript
  • Fill gradients
  • Templates
  • Layers (optional content groups)
  • Simple bitmap patterns as draw and fill colours

The class can produce documents in many languages other than the Western European ones: Central European, Cyrillic, Greek, Baltic and Thai, provided you own TrueType or Type1 fonts with the desired character set. In the Unicode build Chinese, Japanese and Korean are supported, too.

A Reference Manual showing all available methods in alphabetical order is provided. A sample application including more than 20 examples demonstrates the different features. Separate detailed descriptions are available for the MakeFont Utility and the ShowFont Utility. The chapter Styling text using a simple markup language describes the supported tags of the simple XML markup language used by the method wxPdfDocument::WriteXml.

wxPdfDocument is hosted at GitHub since end of 2015. For any remark, question or problem, you can leave a message on the wxPdfDocument issue tracker Or you can send a mail to the author directly.

Current Version

1.4.0 - May 2026

Changes:

  • Added wxPdfGraphicsContext (contributed by Blake-Madden)
  • Added support for granular font weights (contributed by Blake-Madden)
  • Updated 3rd party libraries zint and woff2
  • Improved documentation (contributed by Blake-Madden)
  • Changed default encryption to AES-256 instead of RC4
  • Applied various code improvements
  • Added wxPdfGraphicsContext implementation (and sample application)
  • Added support for granular font weights (Thin to ExtraHeavy)
  • Added linear and radial shading patterns for drawing and filling
  • Added font style and weight attributes to font description

Fixed bugs:

  • Fixed issue where bold fonts were not correctly selected when using wxFont with wxFONTWEIGHT_BOLD
  • Fixed various compile time warnings
  • Fixed several long-standing bugs

For a detailed change log see the Version history.

Author
Ulrich Telle (ulrich DOT telle AT gmx DOT de)

Known issues

Currently there are no known issues regarding the functionality of the wxPdfDocument component. All features were thoroughly tested individually, but it's almost impossible to check all potential combinations. If you find bugs please report them to the author!

Acknowledgements

I'm very grateful to Bruno Lowagie, the main author of the iText Java library, for allowing to take lots of ideas and inspirations from this great Java PDF library. Especially the font handling and font subsetting was influenced in that way.

Many thanks go to Ben Moores who provided code for layers and patterns he wrote for his PDF extension for Mapnik. This code has been extended based on ideas from the iText Java library and was incorporated into wxPdfDocument.

Support for Indic scripts is based on the efforts of Ian Back, creator of the PHP library mPDF; special thanks to K Vinod Kumar of the Centre for Development of Advanced Computing, Mumbai, for clearing license issues of the Raghu font series.

Kudos to Mark Dootson for contributing major enhancements of wxPdfDC and it's integration into the wxWidgets printing framework.

Kudos to Dieter Schmeer for contributing several enhancements for the XML markup handling.

Kudos to Blake Madden for contributing a wxPdfGraphicsContext implementation and support for granular font weights.

Since wxPdfDocument is based on the great FPDF PHP class and several of the contributions to it found on the FPDF website I would like to thank

  • Olivier Plathey (FPDF, Barcodes, Bookmarks, Rotation),
  • Maxime Delorme (Sector)
  • Johannes Guentert (JavaScript)
  • Martin Hall-May (WMF images, Transparency)
  • Emmanuel Havet (Code39 barcodes)
  • Shailesh Humbad (POSTNET barcodes)
  • Matthias Lau (i25 barcodes)
  • Pierre Marletta (Diagrams)
  • Laurent Passebecq (Labels)
  • David Hernandez Sanz (additional graphics primitives)
  • Valentin Schmidt (Transparency, Alpha channel)
  • Jan Slabon (FPDI)
  • Klemen Vodopivec (Protection)
  • Moritz Wagner (Transformation)
  • Andreas Wuermser (Clipping, Gradients, Transformation)

The wxPdfDocument encryption methods use the MD5 Message Digest Algorithm implementation of Alexander Peslyak (Public Domain) and the Rijndael cipher implementation of Szymon Stefanek (Public Domain). For detailed license information

See also
files pdfencrypt.cpp and pdfrijndael.h.