Add Stamp to PDF in C++

Use PdfFileStamp for this task. The examples below retain the original C++ code and API Reference steps.

Add stamp to PDF

Bind an image to a Stamp and apply it with PdfFileStamp.

  1. Create PdfFileStamp.
  2. Bind the PDF input with Facade::BindPdf().
  3. Apply the configured stamp with PdfFileStamp::AddStamp().
  4. Save the resulting PDF with PdfFileStamp::Save().
#include <Aspose.PDF.Cpp/Facades/PdfFileStamp.h>
#include <Aspose.PDF.Cpp/Facades/Stamp.h>
#include <system/string.h>

namespace Facades::Examples::PDF_FileStamp
{
using namespace System;
using namespace Aspose::Pdf;
using namespace Aspose::Pdf::Facades;
using Stamp = Aspose::Pdf::Facades::Stamp;

void AddStampToPdf(String inputFile, String imageFile, String outputFile)
{
    auto pdfStamper = MakeObject<PdfFileStamp>();
    pdfStamper->BindPdf(inputFile);
    auto stamp = MakeObject<Stamp>();
    stamp->BindImage(imageFile);
    pdfStamper->AddStamp(stamp);
    pdfStamper->Save(outputFile);
}
} // namespace Facades::Examples::PDF_FileStamp