Skip to content

VBA code for simple modification of PDF files (read in, combine, write out) with no external libraries

License

Notifications You must be signed in to change notification settings

PerditionC/vbaPDF

Repository files navigation

vbaPDF License: MIT

vbaPDF is a pure VBA library for simple modification of PDF (Portable Document Format) files (read, combine or modify, and write) with no external libraries required.


Features

  • Read and parse PDF files in VBA (Excel, Word, etc.)
  • Combine and split PDF documents
  • Extract text from PDF pages
  • Add or modify bookmarks (outlines) and named destinations
  • Edit PDF metadata (title, author, etc.)
  • Save new or modified PDFs

Note: vbaPDF is designed for small to medium PDFs that fit in memory. It does not support rendering, OCR, or advanced PDF features.


Quick Start

Dim pdf As pdfDocument
Set pdf = pdfDocument.pdfDocument()
If pdf.OpenPdf("C:\path\to\input.pdf") Then
    Debug.Print "Title: " & pdf.Title
    Debug.Print "Pages: " & pdf.PageCount
    pdf.Title = "My Modified PDF"
    pdf.SavePdfAs "C:\path\to\output.pdf"
End If

See USAGE.md for more examples and API.md for detailed function descriptions.


Installation

  1. Download or clone this repository.
  2. Add the src\pdfLib.xlsm module into your VBA project (or import *.cls, *.bas files).
  3. (Optional) Replace Dictionary.cls with a reference to Microsoft Scripting Runtime if preferred.

Supported PDFs

vbaPDF targets PDFs generated by Microsoft Print to PDF and linearized PDFs saved by Adobe Acrobat Reader. Most basic PDF structures are supported, with limited filter support (currently only DEFLATE and with PNG UP).


Additional projects used

To enable self contained PDF support, uses VBA replacement Dictionary object. As basic inflation for zlib (DEFLATE) compression is needed, also provides copy of the ExcelZip to enable basic support for reading in files from ZIP archives.

See original source for updates and bugfixes: https://github.com/cristianbuse


License

MIT License. Some code imported from Cristian Buse's VBA-FastDictionary and related source (MIT). Remaining code is U.S. Public Domain or CC0 equivalent.


Project page: perditionc.github.io/vbaPDF/

About

VBA code for simple modification of PDF files (read in, combine, write out) with no external libraries

Topics

Resources

License

Stars

Watchers

Forks