Aspose.PDF.Cpp
24.11.0
dotnet add package Aspose.PDF.Cpp --version 24.11.0
NuGet\Install-Package Aspose.PDF.Cpp -Version 24.11.0
<PackageReference Include="Aspose.PDF.Cpp" Version="24.11.0" />
paket add Aspose.PDF.Cpp --version 24.11.0
#r "nuget: Aspose.PDF.Cpp, 24.11.0"
// Install Aspose.PDF.Cpp as a Cake Addin #addin nuget:?package=Aspose.PDF.Cpp&version=24.11.0 // Install Aspose.PDF.Cpp as a Cake Tool #tool nuget:?package=Aspose.PDF.Cpp&version=24.11.0
Efficient PDF Document Handling C++ API
Aspose.PDF for C++ is a versatile library for creating, manipulating, and converting PDF documents without the need for Adobe Acrobat. It offers developers comprehensive tools to compress PDFs, split and merge documents, insert or remove pages, and manage annotations. Aspose.PDF also supports adding text, images, tables, and forms to PDFs, as well as handling metadata, encrypting files, and applying digital signatures. With its support for low-level PDF operators, it enables precise control over document content, including image placements and custom graphical shapes. Ideal for developers looking to automate complex PDF workflows in their applications.
Working with Documents
Compress PDF documents
Reduce file size by compressing images, removing unused objects, and optimizing resources.
Split PDF documents
Divide a PDF into smaller documents.
Merge PDF documents
Combine multiple PDFs into one document.
Insert pages
Add pages from another document or new pages to an existing PDF.
Linearization
Optimize PDF for fast web view.
Validation
Ensure PDF compliance with standards like PDF/A.
Working with PDF Pages
Add pages
Add new pages to an existing PDF document.
Move or remove pages
Rearrange or delete specific pages within a PDF.
Crop pages
Adjust the visible area of a PDF page by cropping it.
Add watermarks
Insert watermarks to pages using text or images.
Add stamps
Apply stamps to pages for validation or marking.
Working with PDF Text
Add text
Insert new text into a PDF document.
Format text
Change font type, size, color, and alignment of text in the PDF.
Search and replace text
Locate specific text and replace it programmatically.
Extract text
Programmatically extract text from PDF documents.
Replace text using regular expressions
Perform advanced text replacements using regex patterns.
Working with PDF Images
Insert images
Add images to a PDF document at a specified location.
Remove images
Programmatically delete images from a PDF.
Extract images
Extract embedded images from a PDF document.
Replace images
Swap existing images with new ones in a PDF.
Working with PDF Tables
Insert tables
Create and add tables to a PDF document.
Decorate tables
Apply styles, borders, and colors to enhance table presentation.
Extract tabular data
Programmatically extract table data from a PDF document.
Create or Add Table in PDF
Add new tables to existing PDFs with control over columns, rows, borders, and margins.
Extract Table from PDF
Extract tabular data from PDF files or convert table borders into an image.
Manipulate Table Content
Modify cell content in tables within a PDF using
TableAbsorber
.
Remove Tables from PDF
Remove entire tables from a PDF document using the
Remove
method.
Insert Page Break in Table Rows
Add a page break between rows of a table to manage large datasets across multiple pages.
Working with PDF Forms
Add form fields
Insert various types of interactive form fields (e.g., text boxes, radio buttons).
Fill form fields
Programmatically populate form fields in a PDF.
Extract form data
Retrieve data entered into form fields.
Support for XFA and AcroForms
Work with both XML-based and standard forms.
Working with PDF Graphs
Add shapes
Insert graphical shapes like lines, circles, and rectangles.
Manipulate shapes
Modify shape properties such as color, size, and positioning.
Arc
Add an arc object to PDF files with support for filling colors.
Circle
Display data using a circle graph, or pie chart, with support for filled circles.
Curve
Add Bézier curves to model smooth curves in PDFs, with intuitive manipulation of control points.
Line
Add line graphs to display continuous data and track trends over time.
Rectangle
Use rectangle shapes in graphs to solve layout or graphical problems.
Ellipse
Add an ellipse, which creates an oval shape, to PDFs for specific graphical needs .
Working with PDF Annotations
Add annotations
Insert annotations like text, highlights, and multimedia.
Delete annotations
Remove unwanted annotations from a PDF document.
Modify annotations
Change properties of existing annotations.
Metadata in PDFs
Get and set metadata
Access and modify document metadata such as author, title, and keywords.
Work with XMP data
Programmatically manage embedded XMP metadata.
Get/Set PDF Metadata
Retrieve and modify PDF metadata, such as XMP data.
Insert Metadata with Prefix
Add metadata with a specific namespace URI, for better organization and tracking of document information.
Set Custom Metadata
Add custom properties to PDF documents for personalized metadata.
Securing and Signing PDF
Encrypt PDF documents
Apply password protection and encryption to secure a PDF.
Sign PDF documents
Digitally sign PDFs to verify their authenticity.
Decrypt PDF documents
Remove encryption from password-protected PDFs.
Working with Artifacts
Set Watermark
Add watermarks to a PDF file using the
WatermarkArtifact
class, allowing you to customize the text, font size, color, rotation, and opacity of the watermark.
Set Background
Add a background image to the page using the
BackgroundArtifact
class, inserting an image from the file system as the background.
Get Watermark
Retrieve watermarks from a PDF file, displaying the subtype, text, and location of each watermark.
Count Artifacts
Count the number of artifacts of a particular subtype, such as watermarks, on a specific page.
Manage watermarks
Insert, replace, or remove watermarks from a PDF.
Handle special objects
Work with other non-standard objects in a PDF.
Working with Operators
Add operators
Work with low-level PDF operators for drawing, such as text and graphics operators.
GSave
Saves the current graphical state of the PDF page, allowing subsequent operations to modify the graphics while keeping a backup of the original state.
ConcatenateMatrix
Defines how to place an image or graphical object on a PDF page by specifying the transformation matrix.
Do
Draws the image or form on the page at the specified location using the previously defined operators.
GRestore
Restores the previously saved graphical state, undoing any modifications made after the
GSave
operator.
Remove Graphics Objects
Removes graphics from a PDF page using operators like
Stroke
,ClosePathStroke
, andFill
, providing a low-level approach for manipulating the contents of a PDF.
Draw XForm on Page
Positions and draws an XForm (external form) on a PDF page using
GSave
,ConcatenateMatrix
,Do
, andGRestore
operators.
System Requirements for Aspose.PDF for C++
Category | Requirements |
---|---|
Operating System | Windows (7, 8, 10) & Server (2008, 2012) supported; XP, Vista, and Server 2003 not supported |
Development Environment | Microsoft Visual Studio 2017 or later (Microsoft Visual Studio®); other C++ environments also compatible |
Viewing PDFs | Adobe Acrobat Reader required to view created PDFs; Adobe Acrobat Reader is a free download from adobe.com |
PDF Creation | No need for Adobe Acrobat installation; Aspose.PDF for C++ allows standalone PDF creation |
Supported File Formats C++
Format | Description | Load | Save |
---|---|---|---|
Portable Document Format | ✔️ | ✔️ | |
PDF/A | Portable Document Format (PDF/A compliant) | ✔️ | ✔️ |
HTML | HTML Format | ✔️ | |
TeX | LaTeX typesetting file format | ✔️ | ✔️ |
XPS | XPS Documents | ✔️ | ✔️ |
XSLFO | XSL-FO (XSL-FO is part of XSL file) | ✔️ | |
XLS | Microsoft Excel | ✔️ | |
XLSX | Microsoft Excel | ✔️ | |
PPTX | PowerPoint Presentations | ✔️ | |
DOC | Microsoft Word | ✔️ | |
DOCX | Microsoft Word | ✔️ | |
JPEG | JPEG Format | ✔️ | |
EMF | Enhanced Metafile Format (EMF) | ✔️ | ✔️ |
PNG | PNG Format | ✔️ | ✔️ |
BMP | BMP Format | ✔️ | ✔️ |
TIFF | Single or Multi-Page TIFF | ✔️ | ✔️ |
Text | Text Format | ✔️ |
Installing Aspose.PDF for C++ via NuGet
1. Package Manager Console
- Open Visual Studio and go to
Tools > NuGet Package Manager > Package Manager Console
. - To install the latest release, run:
Install-Package Aspose.PDF.Cpp
2. Update Aspose.PDF
- To update to the latest version, use:
Update-Package Aspose.PDF.Cpp
3. Package Manager GUI
- Open your project and go to
Project > Manage NuGet Packages
. - Search for "Aspose.PDF" under the Browse tab and click Install or Update.
Extract Highlighted Text from PDF Document
This code snippet demonstrates how to extract only the highlighted text from a PDF document using Aspose.PDF for C++. By filtering text markup annotations, you can retrieve the specific text highlighted within a document.
void ExtractHighlightedText() {
// Start logging
std::clog << __func__ << ": Start" << std::endl;
// Define the file paths
String _dataDir("C:\\Samples\\Parsing\\");
String infilename("sample-highlight.pdf");
String outfilename("extracted-text.txt");
// Open the PDF document
auto document = MakeObject<Document>(_dataDir + infilename);
// Loop through all annotations on the first page
for (auto annotation : document->get_Pages()->idx_get(1)->get_Annotations())
{
// Check if the annotation is a highlight annotation
if (annotation->get_AnnotationType() == Aspose::Pdf::Annotations::AnnotationType::Highlight)
{
// Cast annotation to HighlightAnnotation
auto highlightedAnnotation = System::DynamicCast<Aspose::Pdf::Annotations::HighlightAnnotation>(annotation);
// Retrieve the highlighted text fragments
auto collection = highlightedAnnotation->GetMarkedTextFragments();
// Loop through the text fragments and print the highlighted text
for (auto tf : collection)
{
String s = tf->get_Text();
std::cout << s << std::endl; // Display highlighted text
}
}
}
// Finish logging
std::clog << __func__ << ": Finish" << std::endl;
}
Add Image to Existing PDF File
This example demonstrates how to add an image to an existing PDF file using operators in Aspose.PDF for C++. The operators manage the placement and drawing of the image on the PDF page.
void ExampleUsingOperators()
{
// Define file paths
String _dataDir("C:\\Samples\\");
// Open the input PDF document
auto document = MakeObject<Document>(_dataDir + u"PDFOperators.pdf");
// Set coordinates for the image placement
int lowerLeftX = 100;
int lowerLeftY = 100;
int upperRightX = 200;
int upperRightY = 200;
// Get the page where the image needs to be added
auto page = document->get_Pages()->idx_get(1);
// Load the image into a stream
auto imageStream = System::IO::File::OpenRead(_dataDir + u"PDFOperators.jpg");
// Add the image to the Resources collection of the page
page->get_Resources()->get_Images()->Add(imageStream);
// Save the current graphical state using GSave operator
page->get_Contents()->Add(MakeObject<Aspose::Pdf::Operators::GSave>());
// Create a Rectangle and Matrix object for the image placement
auto rectangle = MakeObject<Rectangle>(lowerLeftX, lowerLeftY, upperRightX, upperRightY);
auto matrix = MakeObject<Matrix>(
new double[] {
rectangle->get_URX() - rectangle->get_LLX(), 0, 0,
rectangle->get_URY() - rectangle->get_LLY(),
rectangle->get_LLX(), rectangle->get_LLY() });
// Use ConcatenateMatrix to define where the image should be placed
page->get_Contents()->Add(MakeObject<Aspose::Pdf::Operators::ConcatenateMatrix>(matrix));
// Use the Do operator to draw the image on the page
auto ximage = page->get_Resources()->get_Images()->idx_get(page->get_Resources()->get_Images()->get_Count());
page->get_Contents()->Add(MakeObject<Aspose::Pdf::Operators::Do>(ximage->get_Name()));
// Restore the graphical state using GRestore operator
page->get_Contents()->Add(MakeObject<Aspose::Pdf::Operators::GRestore>());
// Save the updated document
document->Save(_dataDir + u"PDFOperators_out.pdf");
}
Convert a PDF from RGB Colorspace to Grayscale
This code snippet shows how to convert a PDF document from RGB colorspace to grayscale using Aspose.PDF for C++. This can be useful for reducing the file size or preparing the PDF for printing.
void ConvertPDFfromColorspaceToGrayscale() {
// Define file paths
String _dataDir("C:\\Samples\\");
String infilename("OptimizeDocument.pdf");
String outfilename("Test-gray_out.pdf");
// Open the PDF document
auto document = MakeObject<Document>(_dataDir + infilename);
// Create a grayscale conversion strategy
auto strategy = MakeObject<Aspose::Pdf::RgbToDeviceGrayConversionStrategy>();
// Iterate through all pages and apply the grayscale conversion strategy
for (int idxPage = 1; idxPage <= document->get_Pages()->get_Count(); idxPage++)
{
auto page = document->get_Pages()->idx_get(idxPage); // Get the page
strategy->Convert(page); // Convert the page to grayscale
}
// Save the resultant grayscale PDF file
document->Save(_dataDir + outfilename);
}
Tags
PDF Creation
| PDF Manipulation
| PDF Compression
| Merge PDF
| Split PDF
| PDF Forms
| PDF Pages
| Text Extraction
| Image Manipulation
| Table Handling
| Digital Signatures
| PDF Metadata
| Watermark PDF
| XMP Metadata
| Annotations
| PDF Operators
| AcroForms
| XFA Forms
| Image Extraction
| Text Search
| Text Replacement
| C++ PDF Library
| NuGet PDF
| Grayscale PDF
| PDF Encryption
| PDF Decryption
| PDF Annotations
| PDF Watermarks
| Insert Pages
| PDF File Format
| PDF to Image
| Image to PDF
| Multi-page TIFF
| Portable Document Format
Product | Versions Compatible and additional computed target framework versions. |
---|---|
native | native is compatible. |
-
- CodePorting.Translator.Cs2Cpp.Framework (>= 24.11.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Aspose.PDF.Cpp:
Package | Downloads |
---|---|
Aspose.Total.Cpp
Aspose.Total for C++ is a complete package of C++ libraries specifically designed to create, manipulate and convert popular file formats from Microsoft Office and PDF without requiring Office or Adobe Automation. C++ API package also includes a specialized library to generate and recognize barcode labels from images with advanced features to customize the barcode generation and recognition process. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
24.11.0 | 929 | 11/20/2024 |
24.10.1 | 1,167 | 10/18/2024 |
24.9.0 | 1,276 | 9/17/2024 |
24.8.0 | 1,829 | 8/21/2024 |
24.7.0 | 1,432 | 7/19/2024 |
24.6.0 | 2,564 | 6/20/2024 |
24.5.0 | 2,935 | 5/16/2024 |
24.4.0 | 3,110 | 4/22/2024 |
24.3.0 | 3,971 | 3/18/2024 |
24.2.1 | 3,805 | 2/23/2024 |
24.1.0 | 21,541 | 1/20/2024 |
23.12.0 | 4,382 | 12/20/2023 |
23.11.0 | 4,884 | 11/21/2023 |
23.10.0 | 4,854 | 10/20/2023 |
23.9.0 | 4,821 | 9/20/2023 |
23.8.0 | 5,856 | 8/17/2023 |
23.7.0 | 6,183 | 7/25/2023 |
23.6.0 | 5,883 | 6/20/2023 |
23.5.0 | 7,567 | 5/22/2023 |
23.4.0 | 6,413 | 4/17/2023 |
23.3.0 | 10,668 | 3/20/2023 |
23.2.0 | 8,489 | 2/20/2023 |
23.1.0 | 7,016 | 1/23/2023 |
22.12.1 | 10,202 | 12/28/2022 |
22.11.0 | 7,796 | 11/22/2022 |
22.10.1 | 10,501 | 10/21/2022 |
22.9.0 | 7,381 | 9/15/2022 |
22.8.0 | 8,550 | 8/17/2022 |
22.7.0 | 9,107 | 7/22/2022 |
22.6.0 | 8,873 | 6/21/2022 |
22.5.0 | 8,309 | 5/24/2022 |
22.4.0 | 9,507 | 4/25/2022 |
22.3.0 | 9,139 | 3/21/2022 |
22.2.0 | 9,127 | 2/21/2022 |
22.1.0 | 2,822 | 1/20/2022 |
21.12.0 | 7,092 | 12/20/2021 |
21.11.0 | 12,785 | 11/17/2021 |
21.10.0 | 8,992 | 10/18/2021 |
21.8.0 | 13,184 | 8/13/2021 |
21.7.0 | 6,809 | 7/16/2021 |
21.6.0 | 8,048 | 6/17/2021 |
21.5.1 | 1,579 | 5/18/2021 |
21.5.0 | 4,530 | 5/18/2021 |
21.4.0 | 11,733 | 4/15/2021 |
21.3.0 | 7,169 | 3/16/2021 |
21.2.0 | 8,555 | 2/16/2021 |
21.1.0 | 8,281 | 1/22/2021 |
20.12.0 | 8,562 | 12/19/2020 |
20.11.0 | 7,565 | 11/18/2020 |
20.10.0 | 6,533 | 10/21/2020 |
20.9.0 | 6,524 | 9/21/2020 |
20.8.0 | 6,044 | 8/24/2020 |
20.7.2 | 5,835 | 8/4/2020 |
20.7.1 | 1,756 | 8/4/2020 |
20.7.0 | 10,147 | 7/17/2020 |
20.6.0 | 11,214 | 6/18/2020 |
20.5.0 | 6,418 | 5/21/2020 |
20.4.0 | 9,798 | 4/22/2020 |
20.3.0 | 6,807 | 3/16/2020 |
20.2.0 | 10,066 | 2/17/2020 |
20.1.0 | 2,121 | 1/20/2020 |
19.12.1 | 2,609 | 12/17/2019 |
19.12.0 | 2,173 | 12/16/2019 |
19.11.0 | 5,064 | 11/19/2019 |
19.10.0 | 1,524 | 10/18/2019 |
19.9.0 | 1,789 | 9/13/2019 |
19.8.0 | 1,831 | 8/14/2019 |
19.7.0 | 1,820 | 7/14/2019 |
19.6.0 | 1,736 | 6/23/2019 |
19.5.0 | 1,805 | 5/15/2019 |
19.4.0 | 1,767 | 4/14/2019 |
19.3.0 | 1,751 | 3/15/2019 |
19.2.0 | 1,773 | 2/22/2019 |
19.1.0 | 1,725 | 1/30/2019 |
18.12.0 | 1,782 | 12/27/2018 |
18.11.0 | 23,672 | 11/30/2018 |
18.4.0 | 2,269 | 4/28/2018 |
18.3.0 | 1,970 | 3/28/2018 |
18.2.1 | 2,903 | 2/26/2018 |
18.2.0 | 2,034 | 2/26/2018 |