PPTX
DOCX
XLSX
PDF
ODP
PDF
Add Text Stamp PDF via C++
Create Text Stamp with Aspose.PDF using C++ APIs.
How to add Text Stamps to PDF Using C++ Library
In order to work with text stamps in PDF file, we’ll use Aspose.PDF for C++ API which is a feature-rich, powerful and easy to use document manipulation API for cpp platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.PDF.Cpp
Add Text Stamp to PDF Document C++
You need Aspose.PDF for C++ to try the code in your environment.
- Load the PDF with an instance of Document.
- Open a PDF document using Document object.
- Create Text Stamp and define its properties.
- Add the Text Stamp to Page using AddStamp method
System Requirements
Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with C++ Runtime Environment for Windows 32 bit, Windows 64 bit, and Linux 64 bit.
- Development environment like Microsoft Visual Studio.
- Aspose.PDF for C++ DLL referenced in your project.
Add Text Stamp to PDF - C++.
// Open document
auto document = MakeObject<Document>(_dataDir + inputFileName);
// Create text stamp
auto textStamp =MakeObject<TextStamp>(u"Sample Stamp");
// Set whether stamp is background
textStamp->set_Background(true);
// Set origin
textStamp->set_XIndent(100);
textStamp->set_YIndent(100);
// Rotate stamp
textStamp->set_Rotate(Rotation::on90);
// Set text properties
textStamp->get_TextState()->set_Font(FontRepository::FindFont(u"Arial"));
textStamp->get_TextState()->set_FontSize(14.0F);
textStamp->get_TextState()->set_FontStyle(FontStyles::Bold);
textStamp->get_TextState()->set_FontStyle(FontStyles::Italic);
textStamp->get_TextState()->set_ForegroundColor(Color::get_Green());
// Add stamp to particular page
document->get_Pages()->idx_get(1)->AddStamp(textStamp);
// Save output document
document->Save(_dataDir + outputFileName);