Add Image Stamp to PDF via C++

Create Image Stamp programmaticaly using Aspose.PDF for C++ Library

How to add Image Stamps to PDF Using C++

In order to work with image 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

PM > Install-Package Aspose.PDF.Cpp

Add Image Stamp to PDF Document C++


You need Aspose.PDF for C++ to try the code in your environment.

  1. Load the PDF with an instance of Document.
  2. Open a PDF document using Document object.
  3. Create a Image Stamp and define its properties.
  4. Add the Stamp to Page using AddStamp method

Add Image Stamp to PDF - C++


    // Open document
    auto document = MakeObject<Document>(_dataDir + inputFileName);

    // Create image stamp
    auto imageStamp = MakeObject<ImageStamp>(_dataDir + u"aspose-logo.jpg");
    imageStamp->set_Background(true);
    imageStamp->set_XIndent(100);
    imageStamp->set_YIndent(100);
    imageStamp->set_Height(48);
    imageStamp->set_Width(225);
    imageStamp->set_Rotate(Rotation::on270);
    imageStamp->set_Opacity(0.5);
   
    // Add stamp to particular page    
    document->get_Pages()->idx_get(1)->AddStamp(imageStamp);

    // Save output document
    document->Save(_dataDir + outputFileName);