Add Image Stamp to PDF via Python

Create Image Stamp programmaticaly using Aspose.PDF for Python for .NET Tool

How to add Image Stamps to PDF Using Python for .NET

In order to work with image stamp into PDF file, we’ll use Aspose.PDF for .NET API which is a feature-rich, powerful and easy to use document manipulation API for python-net platform. Open NuGet package manager, search for Aspose.PDF and install. You may also use the following command from the Package Manager Console.

Python Package Manager Console

pip install aspose-pdf

Add Image Stamp to PDF Document Python


You need Aspose.PDF for Python 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 - Python

import aspose.pdf as ap

# Open document
document = ap.Document(input_pdf)

# Create image stamp
image_stamp = ap.ImageStamp(input_image_file)
image_stamp.background = True
image_stamp.x_indent = 100
image_stamp.y_indent = 100
image_stamp.height = 300
image_stamp.width = 300
image_stamp.rotate = ap.Rotation.ON270
image_stamp.opacity = 0.5
# Add stamp to particular page
document.pages[1].add_stamp(image_stamp)

# Save output document
document.save(output_pdf)