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, and pages are rendered to raster images via
device classes such as PngDevice, JpegDevice, BmpDevice, and TiffDevice. Do not
rely on releases 1.0.1 or 26.11 to protect confidential documents or to read
password-protected ones. Interactive form fields are
managed through the Form class, and annotations — text notes, highlights, shapes, and
stamps — are created 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 with CMake — build and install it, then
locate it from your project with find_package() — 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(), Document.Decrypt() and the CryptoAlgorithm enum are part of the APIAnnotation and AnnotationCollection (flattening needs release 26.11, which also saves text, author, subject and color changes to loaded ones)Form classForm.Add()/Form.Delete()Form.Flatten() (release 26.11 keeps the field values; releases 1.0.x remove them)Build and install the library as described in the installation guide, link it from your CMake project, then open a document, count its pages, extract text with TextAbsorber, and render page 1 to PNG at 150 DPI.
find_package(aspose_pdf_foss CONFIG REQUIRED)
target_link_libraries(your_app PRIVATE aspose_pdf_foss::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);
}
Read existing /Info entries and update the document title through DocumentInfo.
Releases 1.0.x: saving metadata changes to a file that has no
/Infodictionary throws an exception. Release 26.11 creates the dictionary.
#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.
No. Do not rely on releases 1.0.1 or 26.11 to protect confidential documents or to read password-protected ones.
Yes — a few XmpValue type-checking helpers (IsDateTime, IsField, and similar) are stubs that always return false; use IsString/IsInteger/IsDouble/IsArray instead.