1. Products
  2.   Editor
  3.   Java
  4.   OpenPDF
 
  

OpenPDF: The Java PDF Toolkit

Generate, edit, and render PDFs with ease in Java

What is OpenPDF?

OpenPDF is a mature, open-source Java library for working with PDF documents. It is a fork of iText 4.2.0, offering a reliable and free alternative for generating, editing, and rendering PDFs with full compliance to PDF/A and PDF/UA standards. Ideal for reports, invoices, forms, and archival documents, OpenPDF provides a clean API with support for advanced typography, digital signatures, and accessibility features.

Unlike proprietary solutions, OpenPDF is licensed under the LGPL and MPL, making it suitable for both open-source and commercial projects. With its robust handling of Unicode, embedded fonts, and vector graphics, it’s a top choice for developers needing precise PDF control without vendor lock-in.

Key advantages of OpenPDF include:

  • Standards-compliant: Supports PDF/A-1, PDF/A-3, and PDF/UA for accessibility
  • Rich typography: Advanced font embedding (TrueType, OpenType, WOFF)
  • Security: Digital signatures and encryption (AES-256)
  • Cross-platform: Pure Java with no native dependencies
  • Community-driven: Actively maintained with transparent development

Perfect for invoicing, legal documents, and automated report generation.

GitHub

GitHub Stats

Name:
Language:
Stars:
Forks:
License:
Repository was last updated at

Why Choose OpenPDF?

  • Freedom: No proprietary licensing fees (LGPL/MPL)
  • Precision: Pixel-perfect PDF rendering
  • Accessibility: Built-in support for tagged PDFs (PDF/UA)
  • Performance: Optimized for large documents
  • Extensibility: Modular design with pluggable components

Installation

Add OpenPDF via Maven or Gradle:

Maven



    com.github.librepdf
    openpdf
    1.3.30


Gradle


implementation 'com.github.librepdf:openpdf:1.3.30'

System Requirements: Java 7+

Code Examples

Practical OpenPDF use cases include creating a simple PDF from scratch, adding a table to a PDF, generating a PDF/A-Compliant document, and many more. Following are exmaples of working with OpenPDF API from Java.

OpenPDF API for Java

Example 1: Create a Simple PDF using OpenPDF Java API

This example demonstrates how to generate a basic PDF document with OpenPDF. Using just a few lines of code, you can create a structured PDF with styled text, headings, and formatted content. The Document class defines the page structure, while PdfWriter handles file output. Fonts are customized via FontFactory, supporting embedded typefaces and precise sizing—ideal for invoices, reports, or documentation. OpenPDF’s intuitive API ensures compatibility across platforms, with no native dependencies. The example outputs a clean PDF with a title and bullet points, showcasing the library’s ease of use for everyday PDF generation tasks.

The Document class represents the PDF structure, while PdfWriter handles the output. Fonts and paragraphs are styled using FontFactory and Paragraph objects.

Example 2: Add a Table to a PDF with OpenPDF Java API

This example illustrates OpenPDF’s robust table generation capabilities using the PdfPTable class. Designed for structured data presentation, the code creates a professional sales report with dynamic headers, aligned columns, and scalable row insertion. Key features include automatic width distribution (setWidthPercentage(100)), font customization for headers (HELVETICA_BOLD), and seamless integration of data from arrays or databases. The example highlights OpenPDF’s precision in handling tabular layouts—perfect for financial statements, product catalogs, or any dataset requiring clear visual organization. With built-in support for nested tables and cell styling, it’s a versatile solution for complex PDF layouts.

Example 3: Generate a PDF/A-Compliant Document in Java

This example demonstrates how to create archival-grade PDFs using OpenPDF’s PDF/A-1B conformance features. The code enforces strict standards for long-term document preservation, including embedded fonts (required), XMP metadata, and ICC color profiling. Key steps include initializing a PdfAWriter with conformance validation, loading an sRGB ICC profile for color consistency, and using only embedded fonts to ensure portability. Ideal for legal records, regulatory submissions, or any content requiring future-proofing, this implementation guarantees compliance with ISO 19005 standards. The example includes error-resistant resource handling for production environments, making it a turnkey solution for archival workflows.

Conclusion

OpenPDF is the go-to open-source solution for Java PDF needs. Ideal for:

  • Reports: Dynamic invoice and statement generation
  • Archival: PDF/A for long-term preservation
  • Accessibility: PDF/UA for screen reader compatibility
  • Automation: Batch processing of PDFs

With its permissive licensing and enterprise-grade features, OpenPDF empowers developers to build scalable PDF workflows without restrictions.

Similar Products