Aspose.PDF.Cpp.x86
24.12.0
dotnet add package Aspose.PDF.Cpp.x86 --version 24.12.0
NuGet\Install-Package Aspose.PDF.Cpp.x86 -Version 24.12.0
<PackageReference Include="Aspose.PDF.Cpp.x86" Version="24.12.0" />
paket add Aspose.PDF.Cpp.x86 --version 24.12.0
#r "nuget: Aspose.PDF.Cpp.x86, 24.12.0"
// Install Aspose.PDF.Cpp.x86 as a Cake Addin #addin nuget:?package=Aspose.PDF.Cpp.x86&version=24.12.0 // Install Aspose.PDF.Cpp.x86 as a Cake Tool #tool nuget:?package=Aspose.PDF.Cpp.x86&version=24.12.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.12.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
24.12.0 | 296 | 12/18/2024 |
24.11.0 | 608 | 11/20/2024 |
24.10.1 | 530 | 10/18/2024 |
24.9.0 | 742 | 9/17/2024 |
24.8.0 | 676 | 8/21/2024 |
24.7.0 | 558 | 7/19/2024 |
24.6.0 | 712 | 6/20/2024 |
24.5.0 | 628 | 5/16/2024 |
24.4.0 | 638 | 4/22/2024 |
24.3.0 | 952 | 3/18/2024 |
24.2.1 | 831 | 2/23/2024 |
24.1.0 | 19,309 | 1/20/2024 |
23.12.0 | 1,222 | 12/20/2023 |
23.11.0 | 1,211 | 11/21/2023 |
23.10.0 | 1,007 | 10/20/2023 |
23.9.0 | 1,068 | 9/20/2023 |
23.8.0 | 1,322 | 8/17/2023 |
23.7.0 | 1,071 | 7/25/2023 |
23.6.0 | 771 | 6/20/2023 |
23.5.0 | 740 | 5/22/2023 |
23.4.0 | 1,078 | 4/17/2023 |
23.3.0 | 4,942 | 3/20/2023 |
23.2.0 | 1,141 | 2/20/2023 |
23.1.0 | 1,170 | 1/23/2023 |
22.12.1 | 3,759 | 12/28/2022 |
22.12.0 | 1,140 | 12/20/2022 |
22.11.0 | 977 | 11/22/2022 |
22.10.1 | 1,061 | 10/21/2022 |
22.10.0 | 961 | 10/20/2022 |
22.9.0 | 1,153 | 9/15/2022 |
22.8.0 | 1,208 | 8/17/2022 |
22.7.0 | 1,363 | 7/22/2022 |
22.6.0 | 1,560 | 6/21/2022 |
22.5.0 | 1,761 | 5/24/2022 |
22.4.0 | 1,591 | 4/25/2022 |
22.3.0 | 1,462 | 3/21/2022 |
22.2.0 | 1,493 | 2/21/2022 |
22.1.0 | 1,409 | 1/20/2022 |
21.12.0 | 788 | 12/20/2021 |
21.11.0 | 803 | 11/17/2021 |
21.10.0 | 870 | 10/18/2021 |
21.8.0 | 945 | 8/13/2021 |
21.7.0 | 746 | 7/16/2021 |
21.6.0 | 812 | 6/17/2021 |
21.5.1 | 807 | 5/18/2021 |
21.5.0 | 1,154 | 5/18/2021 |
21.4.0 | 898 | 4/15/2021 |
21.3.0 | 1,085 | 3/16/2021 |
21.2.0 | 1,032 | 2/16/2021 |
21.1.0 | 874 | 1/22/2021 |
20.12.0 | 1,071 | 12/19/2020 |
20.11.0 | 1,208 | 11/18/2020 |
20.10.0 | 1,054 | 10/21/2020 |
20.9.0 | 1,165 | 9/21/2020 |
20.8.0 | 957 | 8/24/2020 |
20.7.1 | 1,041 | 8/4/2020 |
20.7.0 | 1,190 | 7/17/2020 |