This topic explains how to add a watermark during the conversion process using GroupDocs.Conversion for Python via .NET. The watermark can be applied to a document as it is converted to another format, helping to protect the content and ensure it is identifiable.
To enable watermarking, you can use the watermark attribute in the appropriate ConvertOptions classes. Below are the supported ConvertOptions classes that allow you to configure the watermark during conversion:
Tip
Looking for advanced watermarking capabilities? While GroupDocs.Conversion offers basic watermarking, you can explore GroupDocs.Watermark for a comprehensive solution with enhanced features.
Supported ConvertOptions Classes
The following ConvertOptions classes that provide watermark attribute.
PdfConvertOptions – Options for converting to PDF format.
WordProcessingConvertOptions – Options for converting to Word Processing formats.
SpreadsheetConvertOptions – Options for converting to Spreadsheet formats.
PresentationConvertOptions – Options for converting to Presentation formats.
ImageConvertOptions – Options for converting to Image formats (e.g., PNG, JPEG).
WebConvertOptions – Options for converting to Web formats (e.g., HTML).
PageDescriptionLanguageConvertOptions – Options for converting to Page Description Language formats (e.g., PostScript).
EBookConvertOptions – Options for converting to EBook formats (e.g., EPUB, MOBI).
DiagramConvertOptions – Options for converting to Diagram formats (e.g., VSDX).
WatermarkTextOptions Class Attributes
The WatermarkTextOptions class is used to configure the appearance of the watermark. The following options can be configured for adding a watermark:
text: The text to be used for the watermark.
font: The font name used for the watermark text.
color: The color of the watermark text.
width: The width of the watermark.
height: The height of the watermark.
top: The top position of the watermark.
left: The left position of the watermark.
rotation_angle: The rotation angle of the watermark.
transparency: The transparency level of the watermark.
background: Specifies whether the watermark is stamped as a background. If set to True, the watermark is placed at the bottom. By default, it is False, and the watermark is placed on top of the content.
Example: Add a Watermark to Converted Document
The following example demonstrates how to convert DOCX document to PDF and add a watermark:
fromgroupdocs.pydrawingimportColorfromgroupdocs.conversionimportConverterfromgroupdocs.conversion.options.convertimportPdfConvertOptions,WatermarkTextOptionsdefadd_watermark_to_converted_document():# Instantiate Converter with the input document withConverter("./professional-services.docx")asconverter:# Set up the watermark optionswatermark=WatermarkTextOptions("DRAFT")watermark.color=Color.from_argb(128,211,211,211)# lite graywatermark.top=10watermark.left=10watermark.width=300watermark.height=300watermark.background=True# Set up the conversion optionsoptions=PdfConvertOptions()options.watermark=watermark# Perform the conversionconverter.convert("./professional-services.pdf",options)if__name__=="__main__":add_watermark_to_converted_document()
professional-services.docx is the sample file used in this example. Click here to download it.
professional-services.pdf is the expected output PDF file. Click here to download it.
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.