The constructors Watermarker(String) and Watermarker(InputStream) can load a document of any supported format. When you’re loading a document, GroupDocs.Watermark automatically detects its type and creates an instance of the appropriate class. If document format is not supported, constructor throws UnsupportedFileTypeException. If you need specify the format of a document to load, you can use constructors with LoadOptions parameter.
The following examle demonstrates how to create a watermarker for the Spreadsheet document:
// Specify an absolute or relative path to your document. Ex: "C:\\Docs\\spreadsheet.xlsx"
StringfilePath="spreadsheet.xlsx";SpreadsheetLoadOptionsloadOptions=newSpreadsheetLoadOptions();Watermarkerwatermarker=newWatermarker(filePath,loadOptions);// use watermarker methods to manage watermarks in the Spreadsheet document
TextWatermarkwatermark=newTextWatermark("Test watermark",newFont("Arial",12));watermarker.add(watermark);watermarker.save("spreadsheet.xlsx");watermarker.close();
Any supported format family has the specific LoadOptions descendant: