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.
- 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.
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.
- Download or clone this repository.
- Add the
src\pdfLib.xlsm
module into your VBA project (or import *.cls, *.bas files). - (Optional) Replace
Dictionary.cls
with a reference toMicrosoft Scripting Runtime
if preferred.
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).
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
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/
- GitHub Issues for bug reports and feature suggestions