importgroupdocs.watermarkasgwwithgw.Watermarker("D:\\input.pdf")aswatermarker:# Use methods of Watermarker to add, search or remove watermarks.watermarker.save("D:\\output.pdf")
init
Initializes a new Watermarker instance with the specified document path and load options.
Additional options to use when loading a document.
Raises
Description
UnsupportedFileTypeException
Supplied document type is not supported.
InvalidPasswordException
Supplied password is incorrect.
Example
importgroupdocs.watermarkasgwload_options=gw.PdfLoadOptions()load_options.password="123"withgw.Watermarker(r"C:\Documents\test.pdf",load_options)aswatermarker:# work with the watermarker instancepass
init
Initializes a new Watermarker instance with the specified document path and settings.
Initializes a new Watermarker instance with the specified stream.
Learn more about loading documents.
def__init__(self,document):...
Parameter
Type
Description
document
io.RawIOBase
The stream to load document from.
Raises
Description
UnsupportedFileTypeException
Supplied document type is not supported.
InvalidPasswordException
Supplied password is incorrect.
Example
importioimportgroupdocs.watermarkasgwwithopen("D:/input.pdf","rb")asinput_stream,open("D:/output.pdf","wb")asoutput_stream:withgw.Watermarker(input_stream)aswatermarker:# Use methods of Watermarker to add, search, or remove watermarks.watermarker.save(output_stream)
init
Initializes a new instance of the Watermarker class with the specified stream and load options.
Additional options to use when loading a document.
Raises
Description
UnsupportedFileTypeException
Supplied document type is not supported.
InvalidPasswordException
Supplied password is incorrect.
Example
importgroupdocs.watermarkasgwload_options=gw.PdfLoadOptions()load_options.password="123"withopen(r"C:\Documents\test.pdf","rb")asstream:withgw.Watermarker(stream,load_options)aswatermarker:# work with the watermarkerpass
init
Initializes a new instance of the Watermarker class with the specified stream and settings.
Learn more about loading documents.
def__init__(self,document,settings):...
Parameter
Type
Description
document
io.RawIOBase
The stream to load document from.
settings
WatermarkerSettings
Additional settings to use when working with loaded document.
Raises
Description
UnsupportedFileTypeException
Supplied document type is not supported.
InvalidPasswordException
Supplied password is incorrect.
Example
importioimportgroupdocs.watermarkasgwfromgroupdocs.watermarkimport(WatermarkerSettings,SearchableObjects,WordProcessingSearchableObjects,SpreadsheetSearchableObjects,PresentationSearchableObjects,DiagramSearchableObjects,PdfSearchableObjects,)# Configure global searchable objectssettings=WatermarkerSettings()settings.searchable_objects=SearchableObjects(word_processing_searchable_objects=WordProcessingSearchableObjects.HYPERLINKS|WordProcessingSearchableObjects.TEXT,spreadsheet_searchable_objects=SpreadsheetSearchableObjects.HEADERS_FOOTERS,presentation_searchable_objects=PresentationSearchableObjects.SLIDES_BACKGROUNDS|PresentationSearchableObjects.SHAPES,diagram_searchable_objects=DiagramSearchableObjects.NONE,pdf_searchable_objects=PdfSearchableObjects.ALL,)# Process multiple filesforfile_pathin["doc1.pdf","doc2.docx"]:withopen(file_path,"rb")asstream:withgw.Watermarker(stream,settings)aswatermarker:# work with watermarker, e.g., search or add watermarkspass
init
Initializes a new Watermarker instance with the specified document stream, load options, and settings.
Additional options to use when loading a document.
settings
WatermarkerSettings
Additional settings to use when working with the loaded document.
Raises
Description
UnsupportedFileTypeException
Supplied document type is not supported.
InvalidPasswordException
Supplied password is incorrect.
Example
importgroupdocs.watermarkasgw# Configure searchable objects for email documentssettings=gw.WatermarkerSettings()settings.searchable_objects=gw.SearchableObjects(email_searchable_objects=gw.EmailSearchableObjects.Subject|gw.EmailSearchableObjects.HtmlBody|gw.EmailSearchableObjects.PlainTextBody)load_options=gw.EmailLoadOptions()withopen(r"D:\test.msg","rb")asstream:withgw.Watermarker(stream,load_options,settings)aswatermarker:criteria=gw.TextSearchCriteria("test",False)watermarks=watermarker.search(criteria)watermarks.clear()# Remove found text fragmentswatermarker.save()