A “Hello, World!” example is often the first step when exploring GroupDocs.Watermark for Python via .NET. It serves as a simple test to confirm that your development environment is correctly set up and that the library is functioning as expected.
Overview
GroupDocs.Watermark for Python via .NET lets you add, search, and remove watermarks in various document formats. A wide range of supported formats makes it versatile for different use cases.
How to add a watermark
The following steps demonstrate how to add a text watermark to a document using GroupDocs.Watermark for Python via .NET:
Import the groupdocs.watermark classes you need.
Open a Watermarker with the path to the sample document.
Create a TextWatermark with the desired text and font, and style it.
Apply the watermark with add().
Save the result.
Complete example
The example below adds a semi-transparent, diagonal “Hello, Watermark!” text watermark and saves the result:
fromgroupdocs.watermarkimportWatermarkerfromgroupdocs.watermark.watermarksimportTextWatermark,Font,Colordefhello_world():# Open the document, add a single text watermark, and save the resultwithWatermarker("./sample.pdf")aswatermarker:watermark=TextWatermark("Hello, Watermark!",Font("Arial",36.0))watermark.foreground_color=Color.redwatermark.opacity=0.5watermark.rotate_angle=45.0watermarker.add(watermark)watermarker.save("./output.pdf")print("Watermark added successfully. Output saved to ./output.pdf.")if__name__=="__main__":hello_world()
sample.pdf is the sample file used in this example. Click here to download it.
The watermark is saved back to the same PDF format as output.pdf. To stamp a different document, change the input path and the output extension — GroupDocs.Watermark saves in the input document’s format.
Additional resources
This demo references the GroupDocs.Watermark for Python via .NET code samples.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.