Skip to content

vanillapdf/vanillapdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2,750 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Vanilla.PDF – The Ultimate C++ PDF Toolkit

Distribution CI & Quality Security
NuGet Downloads Docs License Build Coverage Fuzzing CodeQL Sanitizers OpenSSF Scorecard SLSA 2

Vanilla.PDF is a modern, high-performance, open-source C++17 SDK for creating, editing, signing, and analyzing PDF documents. With no external runtime dependencies and full cross-platform support, it's ideal for embedding into desktop, server, or automation workflows.

  • πŸ“„ Create & modify PDF documents β€” pages, text, images, vector graphics
  • πŸ” Sign & verify digital signatures (CMS/PKCS#7) with certificate chain validation
  • πŸ”’ Encrypt & decrypt with AES or RC4 using passwords or certificates
  • βš™οΈ ABI-stable C API β€” opaque handles callable from any language with a C FFI
  • 🧡 Thread-safe β€” no global state; synchronization is handled internally

Install

vcpkg (Recommended)

vcpkg install vanillapdf

CMake FetchContent

include(FetchContent)
FetchContent_Declare(vanillapdf
    GIT_REPOSITORY https://github.com/vanillapdf/vanillapdf.git
    GIT_TAG        main)
FetchContent_MakeAvailable(vanillapdf)
target_link_libraries(myapp PRIVATE vanillapdf::vanillapdf)

Other methods

  • NuGet (.NET interop) β€” dotnet add package vanillapdf.net
  • Conan 🚧 β€” coming soon (not yet published to Conan Center)
  • Homebrew (macOS) 🚧 β€” coming soon (formula not yet live in Homebrew core)
  • Build from source β€” clone with submodules, then configure with a CMake preset

See the installation guide and building from source on Read the Docs for full instructions.

Quick Example

Create a PDF with a blank page:

#include <vanillapdf/c_vanillapdf_api.h>

int main(void) {
    DocumentHandle* doc = NULL;
    CatalogHandle* cat = NULL;
    PageTreeHandle* pages = NULL;
    PageObjectHandle* page = NULL;

    Document_Create("hello.pdf", &doc);
    Document_GetCatalog(doc, &cat);
    Catalog_GetPages(cat, &pages);
    PageObject_CreateFromDocument(doc, &page);
    PageTree_AppendPage(pages, page);
    Document_Save(doc, "hello.pdf");

    PageObject_Release(page);
    PageTree_Release(pages);
    Catalog_Release(cat);
    Document_Release(doc);
    return 0;
}

Platforms

Platform Compilers Architectures
Windows Visual Studio 2022, 2026 x86, x64, ARM64
Linux GCC 8.1+, Clang 10+ x64, ARM64, ARM
macOS AppleClang 15+ (Xcode 15) x64, ARM64
Android NDK toolchain arm64, armv7, x86, x86_64

Features

Feature C API Description
Create documents Document_Create Pages, text, images, vector paths
Digital signatures Document_Sign OpenSSL CMS β€” RSA, ECDSA (P-256/P-384/P-521), Ed25519, Ed448 via PKCS#12 keys or custom callbacks
Signature verification DigitalSignatureExtensions_Verify Chain validation, weak-algorithm detection, signing-time checks
File structure validation FileStructureValidator_* Walk xref/trailers/streams and report malformed files
Interactive forms FormField_GetValue / _SetValue Read/write AcroForm field values
Encryption Document_AddEncryption / _RemoveEncryption AES and RC4, owner/user passwords, certificate-based decryption (FIPS-compatible)
Content streams ContentStream_* Parse and encode PostScript-style page content
Low-level parsing File_Open XRef tables, indirect objects, cross-reference streams

A vanillapdf-tools command-line utility is built from source (not yet distributed as a standalone app) and exposes sign, verify, merge, extract, encrypt/decrypt, and more β€” see CLI Tools on Read the Docs.

Architecture

The library is organized into three layers:

  • Syntax β€” PDF object types, tokenizer, parser, XRef tables, compression filters
  • Semantics β€” Documents, pages, catalogs, annotations, digital signatures, forms
  • Contents β€” Content stream parsing, PostScript instruction processing

The C++ core is hidden behind an ABI-stable ANSI C interface using opaque handles (DocumentHandle*, FileHandle*, PageObjectHandle*, etc.) and cdecl calling conventions, so any language with a C FFI can use this library. Handles are reference-counted; callers acquire and release references explicitly. This design guarantees binary compatibility across compiler versions and minor/patch releases.

Thread Safety

Vanilla.PDF provides fine-grained thread safety: the same object can be accessed concurrently from multiple threads β€” including objects that initialize lazily on first access β€” without any caller-side locking. This is a stronger guarantee than merely running separate documents on separate threads; synchronization within a shared object is handled internally.

See the Architecture Guide for the memory and locking model.

Non-Goals

Vanilla.PDF is a document structure library, not a rendering engine. It does not rasterize pages, lay out text with font shaping, or display PDFs on screen. If you need to view a PDF, use a dedicated renderer and this library for the structural operations around it.

Current known limitations:

  • No PDF rendering or rasterization
  • No CRL/OCSP revocation checking (#157)
  • No PAdES compliance levels (BES, T, LTV)
  • No RFC 3161 timestamp validation

Versioning

Vanilla.PDF follows Semantic Versioning. The C API is stable within a major version: minor releases add functionality without breaking existing callers, patch releases contain only fixes. Query the version at runtime with LibraryInfo_GetVersionMajor, LibraryInfo_GetVersionMinor, LibraryInfo_GetVersionPatch.

Documentation

Full documentation is hosted on Read the Docs.

Guide Description
Overview Design philosophy, scope, and project goals
Quickstart Create your first PDF document step by step
Installation vcpkg, FetchContent, Conan, Homebrew, NuGet
C API Guide Handles, memory management, error handling
Architecture Three-layer design, object model, memory model, thread safety
CLI Tools sign, verify, merge, extract, encrypt, decrypt
Signature Verification Trust stores, chain validation, weak-algorithm detection
Building Build from source with CMake presets
Examples Code samples for signing, merging, encryption
PDF Format PDF syntax, objects, and document structure

See the Changelog for release notes.

Contributing

We welcome pull requests, feature proposals, and bug reports.

All changes require a branch and pull request. The main and release/* branches are protected.

License

Vanilla.PDF is licensed under the Apache 2.0 License.

Contact & Support

Channel Link
Email info@vanillapdf.com
Website vanillapdf.com
Issues GitHub Issues
Sponsor GitHub Sponsors

About

Vanilla.PDF is a cross-platform SDK for creating and modifying PDF documents

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

13 stars

Watchers

1 watching

Forks

Sponsor this project

 

Contributors