Creating PDF Documents from Scratch with PDFium VCL in Delphi

While PDFium is primarily known for PDF viewing and manipulation, PDFium VCL also provides powerful PDF creation capabilities. The Create PDF demo shows how to generate PDF documents programmatically with text, shapes, tables, and watermarks.

Overview

This demo creates a new PDF document with various elements including styled text, geometric shapes, a simple table, and a diagonal watermark. It demonstrates the core PDF creation APIs available in PDFium VCL.

Key Features

  • Create New Documents – Generate PDFs from scratch
  • Add Text – Insert styled text with custom fonts, sizes, and colors
  • Draw Shapes – Create rectangles, paths, and other geometric shapes
  • Build Tables – Create simple text-based tables
  • Add Watermarks – Insert rotated, semi-transparent text

PDFium DLL Requirements

Before running any PDFium VCL application, ensure the PDFium DLL files are installed:

  • pdfium32.dll / pdfium64.dll – Standard versions (~5-6 MB)
  • pdfium32v8.dll / pdfium64v8.dll – With V8 JavaScript engine (~23-27 MB)

Installation: Run PDFiumVCL\DLLs\CopyDlls.bat as Administrator to automatically copy the DLLs to Windows system directories.

Creating a New PDF Document

Adding Text

The AddText method adds styled text to the current page:

Complete PDF Creation Example

Drawing Shapes with CreatePath

Shape Drawing Examples

Creating Complex Paths

Building Simple Tables

Adding Watermarks

Adding Images

Multi-Page Documents

Page Sizes

Format Width (pts) Height (pts)
A4 Portrait 595 842
A4 Landscape 842 595
Letter Portrait 612 792
Letter Landscape 792 612
Legal Portrait 612 1008

Use Cases

  • Report Generation – Create formatted reports from data
  • Invoice Creation – Generate invoices and receipts
  • Certificate Generation – Create certificates with templates
  • Document Templates – Fill templates with dynamic content

Conclusion

The Create PDF demo shows that PDFium VCL isn’t just for viewing—it’s a complete PDF toolkit. With support for text, shapes, images, and multi-page documents, you can generate professional PDFs entirely from code.

Combined with the component’s viewing and manipulation capabilities, PDFium VCL provides everything you need for comprehensive PDF handling in Delphi applications.

Explore PDF creation with PDFium VCL Component and bring dynamic document generation to your applications.