GroupDocs.Watermark lets you replace text or images in watermarks that already exist in a document.
Replacing text
Loop through found watermarks and set the text property.
importgroupdocs.watermarkasgwimportgroupdocs.watermark.search.searchcriteriaasgws_scwithgw.Watermarker("document.pdf")aswatermarker:criteria=gws_sc.TextSearchCriteria("test",False)possible=watermarker.search(criteria)forwminpossible:try:wm.text="passed"exceptException:# Entity may not support text editing or the value is invalidpasswatermarker.save("document.pdf")
Replacing text with formatting
Use formatted_text_fragments to set styled text.
importgroupdocs.watermarkasgwimportgroupdocs.watermark.search.searchcriteriaasgws_scimportgroupdocs.watermark.watermarksasgwwwithgw.Watermarker("document.pdf")aswatermarker:criteria=gws_sc.TextSearchCriteria("test",False)possible=watermarker.search(criteria)forwminpossible:try:wm.formatted_text_fragments.clear()wm.formatted_text_fragments.add("passed",gww.Font("Calibri",19.0,gww.FontStyle.BOLD),gww.Color.red,gww.Color.aqua,)exceptException:# Entity may not support formatted text or values may be invalidpasswatermarker.save("document.pdf")
Replacing image
Swap the image data of matched watermarks.
importgroupdocs.watermarkasgwimportgroupdocs.watermark.search.searchcriteriaasgws_scwithopen("image.png","rb")asf:image_data=f.read()withgw.Watermarker("document.pdf")aswatermarker:criteria=gws_sc.ImageDctHashSearchCriteria("logo.bmp")possible=watermarker.search(criteria)forwminpossible:try:wm.image_data=image_dataexceptException:# Entity may not support image replacement or image format is invalidpasswatermarker.save("document.pdf")
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.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.