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-klasse{Device}.Process()Document.Encrypt() met een gebruikers- en eigenaarswachtwoordCryptoAlgorithm enumPermissions typeDocument.Decrypt()Annotation en AnnotationCollectionForm-klasseForm.Add()/Form.Delete()Form.Flatten()Voeg de bibliotheek toe als een CMake-subdirectory, open vervolgens een document, tel de pagina’s, extraheer tekst met TextAbsorber, en render pagina 1 naar PNG op 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 een document en bescherm het met een gebruikers- en eigenaarwachtwoord met behulp van AES-256-encryptie.
#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");
}
Lees bestaande /Info-vermeldingen en werk de documenttitel bij via 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");
}
Het is MIT-gelicentieerd en gratis te gebruiken in commerciële en niet-commerciële producten, zonder activatiesleutel of API aanroeplimieten.
Een C++20-compiler (clang 16+, gcc 13+, of MSVC 2022 17.5+) en CMake 3.22 of hoger. Python 3 is alleen vereist tijdens het bouwen.
Nee. Het linkt alleen tegen de C++-standaardbibliotheek — er is geen derde-partij PDF-, afbeelding- of compressie-afhankelijkheid vereist tijdens runtime.
Het leest en slaat native PDF-documenten op, en exporteert gerenderde pagina’s naar Bmp, Jpeg en Tiff, plus platte tekst. SVG-inhoud kan worden geïmporteerd.
Roep Document.Encrypt() aan met een gebruikerswachtwoord, een eigenaarwachtwoord en een CryptoAlgorithm (RC4x40, RC4x128, AESx128, of AESx256).
Ja — een paar XmpValue type-checking helpers (IsDateTime, IsField en soortgelijke) zijn stubs die altijd false teruggeven; gebruik IsString/IsInteger/IsDouble/IsArray in plaats daarvan.