Add Text Stamp to PDF via Python

Create text stamp programmaticaly using Aspose.PDF for Python via C++ Library

How to add Text Stamps to PDF Using Python via C++ Library

Need to stamp a PDF? Programmatic modification of PDF documents is an essential part of modern digital workflows. Python libraries like Aspose.PDF – are stand-alone solutions that don’t rely on other software and are ready for commercial use. They cover all possible needs of professional Python developers.

This Python for .NET library enables developers to stamp PDF documents quickly and efficiently through programming. With this library, you can easily produce stamped PDF output for printing, archiving, or network sharing. It is a standalone solution for processing PDF documents in Python for .NET that does not require the installation of any third-party software.

To compress PDF files, we’ll use Aspose.PDF for C++ API, a feature-rich, powerful and easy-to-use document manipulation API for Python.

Add Text Stamp to PDF Document Python


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

  1. Create a Document object.
  2. Create a TextStamp object.
  3. Set various properties of TextStamp.
  4. Add the text stamp to the first page of the document
  5. Save the document as a PDF file

Add Text Stamp to PDF with Python

Simple example to text stamp on PDF using Python

import AsposePDFPythonWrappers as ap
import AsposePDFPython as apCore

document = ap.Document("sample0.pdf")

textStamp = ap.TextStamp("Sample Stamp")

textStamp.x_indent = 100
textStamp.y_indent = 100

textStamp.width = 100
textStamp.height = 20
textStamp.draw = False
textStamp.rotate = apCore.Rotation.on90

# Add stamp to particular page
document.pages[1].add_stamp(textStamp)

# Save output document
document.save("sample_stamp.pdf")