fromgroupdocs.watermarkimportWatermarker# Load a document.watermarker=Watermarker("./document.pdf")# Use Watermarker methods to add, search, or remove watermarks.# Save the document.watermarker.save("./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
fromgroupdocs.watermarkimportWatermarkerfromgroupdocs.watermark.options.pdfimportPdfLoadOptionsload_options=PdfLoadOptions()load_options.password="123"withWatermarker(r"C:\Documents\test.pdf",load_options)aswatermarker:# perform operations on the encrypted PDFpass
init
Initializes a Watermarker with the specified document path and settings.
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
fromgroupdocs.watermarkimportWatermarker,WatermarkerSettingsfromgroupdocs.watermark.search.objectsimportSearchableObjectsfromgroupdocs.watermark.search.objectsimportWordProcessingSearchableObjects,SpreadsheetSearchableObjects,PresentationSearchableObjects,DiagramSearchableObjects,PdfSearchableObjectssettings=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,)withWatermarker("./document.pdf",settings)aswatermarker:# work with watermarker, e.g., search or remove watermarkspass
init
Initializes a new Watermarker instance with the specified document path, load options, and settings.
fromgroupdocs.watermarkimportWatermarkerdefload_from_stream():withopen("input.pdf","rb")asinput_stream,open("output.pdf","wb")asoutput_stream:withWatermarker(input_stream)aswatermarker:# Use methods of Watermarker to add, search or remove watermarks.watermarker.save(output_stream)
init
Initializes a new Watermarker instance with the specified stream and load options.
Learn more about loading documents.
def__init__(self,document,options):...
Parameter
Type
Description
document
io.RawIOBase
The stream to load document from.
options
LoadOptions
Additional options to use when loading a document.
Raises
Description
UnsupportedFileTypeException
Supplied document type is not supported.
InvalidPasswordException
Supplied password is incorrect.
Example
fromgroupdocs.watermarkimportWatermarkerfromgroupdocs.watermark.options.pdfimportPdfLoadOptionswithopen(r"C:\Documents\test.pdf","rb")asfile_stream:load_options=PdfLoadOptions()load_options.password="123"withWatermarker(file_stream,load_options)aswatermarker:# perform operations with watermarkerpass
init
Initializes a new Watermarker instance 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
fromgroupdocs.watermarkimportWatermarker,WatermarkerSettingsfromgroupdocs.watermark.search.objectsimportSearchableObjectsfromgroupdocs.watermark.search.objectsimportWordProcessingSearchableObjects,SpreadsheetSearchableObjects,PresentationSearchableObjects,DiagramSearchableObjects,PdfSearchableObjectssettings=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,)forfile_pathin["./document1.pdf","./document2.docx"]:withopen(file_path,"rb")asstream:withWatermarker(stream,settings)aswatermarker:watermarks=watermarker.search()# work with found watermarks
init
Initializes a new instance of the Watermarker class with the specified stream, load options and settings.