Aspose.PDF FOSS for C++ is an open-source, modern C++20 library for working with PDF documents — opening and saving PDFs, extracting text, rasterising pages to image formats, and building documents from scratch (text, images, tables, vector graphics, annotations, AcroForm fields, and bookmarks). The library links against nothing but the C++ standard library: every primitive, including the TIFF, JPEG, and PNG codecs and the page rasteriser, is implemented from scratch with no dependency on any commercial PDF stack.
The core API is built around the Document class and its Pages() collection. Text is
extracted with Aspose::Pdf::Text::TextAbsorber, pages are rendered to raster images via
device classes such as PngDevice, JpegDevice, BmpDevice, and TiffDevice, and
documents can be secured with Document.Encrypt() using RC4-40, RC4-128, AES-128, or
AES-256 algorithms selected through the CryptoAlgorithm enum. Interactive form fields are
managed through the Form class, and annotations — text notes, highlights, shapes, and
stamps — are added and modified through the Annotation class hierarchy.
Aspose.PDF FOSS for C++ is released under the MIT license with no runtime fees or usage restrictions. It builds as a static library via CMake — add it as a subdirectory of your build or install it standalone — and requires a C++20 compiler with no other runtime dependencies. For enterprise features and support, see Aspose.PDF for C++ — Enterprise Product.
DocumentDocument.Pages() (PageCollection)PageCollection.Add()/Insert()/Delete()DocumentInfo (Document.Info())Document.Optimize()/OptimizeResources()Aspose::Pdf::Text::TextAbsorberTextAbsorber.Visit()TextAbsorber.Text()TextFragmentAbsorber.TextFragments()PngDeviceJpegDevice, BmpDevice, TiffDeviceResolution class{Device}.Process()Document.Encrypt() using a user and owner passwordCryptoAlgorithm enumPermissions typeDocument.Decrypt()Annotation and AnnotationCollectionForm classForm.Add()/Form.Delete()Form.Flatten()Add the library as a CMake subdirectory, then open a document, count its pages, extract text with TextAbsorber, and render page 1 to PNG at 150 DPI.
add_subdirectory(aspose.pdf-foss-for-cpp)
target_link_libraries(your_app PRIVATE aspose_pdf_foss)
#include <aspose/pdf/document.hpp>
#include <aspose/pdf/page_collection.hpp>
#include <aspose/pdf/text_absorber.hpp>
#include <aspose/pdf/png_device.hpp>
#include <aspose/pdf/resolution.hpp>
#include <fstream>
#include <iostream>
int main() {
Aspose::Pdf::Document doc("input.pdf");
std::cout << "Pages: " << doc.Pages().Count() << "\n";
Aspose::Pdf::Text::TextAbsorber absorber;
absorber.Visit(doc);
std::cout << absorber.Text() << "\n";
Aspose::Pdf::Devices::PngDevice png(Aspose::Pdf::Devices::Resolution(150));
std::ofstream out("page1.png", std::ios::binary);
png.Process(doc.Pages()[1], out);
}
Open a document and protect it with a user and owner password using AES-256 encryption.
#include <aspose/pdf/document.hpp>
int main() {
Aspose::Pdf::Document doc("input.pdf");
doc.Encrypt("user-password", "owner-password",
Aspose::Pdf::Permissions(),
Aspose::Pdf::CryptoAlgorithm::AESx256);
doc.Save("encrypted.pdf");
}
Read existing /Info entries and update the document title through DocumentInfo.
#include <aspose/pdf/document.hpp>
#include <aspose/pdf/document_info.hpp>
#include <iostream>
int main() {
Aspose::Pdf::Document doc("input.pdf");
auto& info = doc.Info();
std::cout << "Title: " << info.Title() << "\n";
std::cout << "Author: " << info.Author() << "\n";
doc.SetTitle("Updated Report Title");
doc.Save("output.pdf");
}
It is MIT-licensed and free to use in commercial and non-commercial products, with no activation key or API call limits.
A C++20 compiler (clang 16+, gcc 13+, or MSVC 2022 17.5+) and CMake 3.22 or later. Python 3 is required at build time only.
No. It links against nothing but the C++ standard library — no third-party PDF, image, or compression dependency is required at runtime.
It reads and saves native PDF documents, and exports rendered pages to Bmp, Jpeg, and Tiff, plus plain text. SVG content can be imported.
Call Document.Encrypt() with a user password, an owner password, and a CryptoAlgorithm (RC4x40, RC4x128, AESx128, or AESx256).
Yes — a few XmpValue type-checking helpers (IsDateTime, IsField, and similar) are stubs that always return false; use IsString/IsInteger/IsDouble/IsArray instead.