Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active January 20, 2023 20:54
How to Add Watermark to PDF using Python. For more details: https://kb.aspose.com/pdf/python/how-to-add-watermark-to-pdf-in-python/
import aspose.pdf as pdf
# Load the license
license = pdf.License()
license.set_license("Aspose.Total.lic")
# Load input PDF document
document = pdf.Document("Combine.pdf")
# Set watermark image
stamp = pdf.ImageStamp("Sample.jpg")
# Set properties for the watermark
stamp.x_indent = 200
stamp.y_indent = 200
stamp.height = 60
stamp.width = 60
stamp.background = True
# Add watermark image
document.pages[1].add_stamp(stamp)
# Save the PDF with watermark
document.save("Watermark.pdf")
print("Watermark added successfully")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment