Working with PDF Attachments in Delphi using PDFium Component

PDF documents can contain embedded file attachments—a powerful feature for bundling related files like spreadsheets, images, or supporting documents. The Attachment demo shows how to work with PDF attachments using PDFium VCL.

Overview

This demo provides complete attachment management including listing, extracting, adding, and deleting file attachments from PDF documents. It’s essential for document management systems that need to handle complex PDF files.

Key Features

  • List Attachments – View all embedded files in a PDF
  • Extract Attachments – Save attachments to disk
  • Add Attachments – Embed new files into PDFs
  • Delete Attachments – Remove attachments from PDFs
  • View Details – See attachment names and sizes

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.

Listing Attachments

Extracting Attachments

Adding Attachments

Deleting Attachments

Accessing Attachment Properties

Creating a New Document with Attachments

Saving Document After Modifications

Displaying Attachment Details

Use Cases

  • Document Packages – Bundle main document with supporting files
  • Form Submissions – Attach evidence or supporting documents to forms
  • Technical Manuals – Include CAD files, spreadsheets, or source code
  • Legal Documents – Attach exhibits and appendices
  • Archive Management – Extract attachments for processing

Conclusion

The Attachment demo shows how PDFium VCL provides complete control over PDF file attachments. Whether you’re building a document management system or processing PDF forms with embedded files, these APIs make it straightforward.

The ability to add, extract, and delete attachments programmatically opens up many possibilities for document automation and processing workflows.

Manage PDF attachments with ease using Delphi PDFium VCL.