Class Watermarker
Namespace: Aspose.Words.LowCode
Assembly: Aspose.Words.dll (25.12.0)
Provides methods intended to insert watermarks into the documents.
public class Watermarker : ProcessorInheritance
object ← Processor ← Watermarker
Inherited Members
Processor.mResultDocument , Processor.From(string) , Processor.From(string, LoadOptions) , Processor.From(Stream) , Processor.From(Stream, LoadOptions) , Processor.To(string) , Processor.To(string, SaveOptions) , Processor.To(string, SaveFormat) , Processor.To(Stream, SaveOptions) , Processor.To(Stream, SaveFormat) , Processor.To(List<Stream>, SaveOptions) , Processor.To(List<Stream>, SaveFormat) , Processor.Execute() , Processor.Execute(CancellationToken) , Processor.ExecuteCore() , Processor.CheckArgumentsSet() , Processor.GetPartFileName(string, int, SaveFormat) , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Methods
CheckArgumentsSet()
protected override void CheckArgumentsSet()Create(WatermarkerContext)
Creates new instance of the watermarker processor.
public static Watermarker Create(WatermarkerContext context)Parameters
context WatermarkerContext
Returns
Examples
Shows how to insert watermark text to the document using context.
string doc = MyDir + "Big document.docx";
string watermarkText = "This is a watermark";
WatermarkerContext watermarkerContext = new WatermarkerContext();
watermarkerContext.TextWatermark = watermarkText;
watermarkerContext.TextWatermarkOptions.Color = Color.Red;
Watermarker.Create(watermarkerContext)
.From(doc)
.To(ArtifactsDir + "LowCode.WatermarkContextText.docx")
.Execute();Shows how to insert watermark image to the document using context.
string doc = MyDir + "Document.docx";
string watermarkImage = ImageDir + "Logo.jpg";
WatermarkerContext watermarkerContext = new WatermarkerContext();
watermarkerContext.ImageWatermark = File.ReadAllBytes(watermarkImage);
watermarkerContext.ImageWatermarkOptions.Scale = 50;
Watermarker.Create(watermarkerContext)
.From(doc)
.To(ArtifactsDir + "LowCode.WatermarkContextImage.docx")
.Execute();Shows how to insert watermark text to the document from the stream using context.
string watermarkText = "This is a watermark";
using (FileStream streamIn = new FileStream(MyDir + "Document.docx", FileMode.Open, FileAccess.Read))
{
WatermarkerContext watermarkerContext = new WatermarkerContext();
watermarkerContext.TextWatermark = watermarkText;
watermarkerContext.TextWatermarkOptions.Color = Color.Red;
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.WatermarkContextTextStream.docx", FileMode.Create, FileAccess.ReadWrite))
Watermarker.Create(watermarkerContext)
.From(streamIn)
.To(streamOut, SaveFormat.Docx)
.Execute();
}Shows how to insert watermark image to the document from a stream using context.
string watermarkImage = ImageDir + "Logo.jpg";
using (FileStream streamIn = new FileStream(MyDir + "Document.docx", FileMode.Open, FileAccess.Read))
{
WatermarkerContext watermarkerContext = new WatermarkerContext();
watermarkerContext.ImageWatermark = File.ReadAllBytes(watermarkImage);
watermarkerContext.ImageWatermarkOptions.Scale = 50;
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.WatermarkContextImageStream.docx", FileMode.Create, FileAccess.ReadWrite))
Watermarker.Create(watermarkerContext)
.From(streamIn)
.To(streamOut, SaveFormat.Docx)
.Execute();
}ExecuteCore()
protected override void ExecuteCore()SetImage(string, string, string)
Adds an image watermark into the document.
public static void SetImage(string inputFileName, string outputFileName, string watermarkImageFileName)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
watermarkImageFileName string
Image that is displayed as a watermark.
Examples
Shows how to insert watermark image to the document.
string doc = MyDir + "Document.docx";
string watermarkImage = ImageDir + "Logo.jpg";
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkImage.1.docx", watermarkImage);
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.2.docx", SaveFormat.Docx, watermarkImage);
ImageWatermarkOptions options = new ImageWatermarkOptions();
options.Scale = 50;
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.3.docx", watermarkImage, options);
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.4.docx", SaveFormat.Docx, watermarkImage, options);Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetImage(string, string, string, ImageWatermarkOptions)
Adds an image watermark into the document with options.
public static void SetImage(string inputFileName, string outputFileName, string watermarkImageFileName, ImageWatermarkOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
watermarkImageFileName string
Image that is displayed as a watermark.
options ImageWatermarkOptions
Defines additional options for the image watermark.
Examples
Shows how to insert watermark image to the document.
string doc = MyDir + "Document.docx";
string watermarkImage = ImageDir + "Logo.jpg";
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkImage.1.docx", watermarkImage);
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.2.docx", SaveFormat.Docx, watermarkImage);
ImageWatermarkOptions options = new ImageWatermarkOptions();
options.Scale = 50;
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.3.docx", watermarkImage, options);
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.4.docx", SaveFormat.Docx, watermarkImage, options);Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetImage(string, string, SaveFormat, string)
Adds an image watermark into the document with options and specified save format.
public static void SetImage(string inputFileName, string outputFileName, SaveFormat saveFormat, string watermarkImageFileName)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveFormat SaveFormat
The save format.
watermarkImageFileName string
Image that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetImage(string, string, SaveFormat, string, ImageWatermarkOptions)
Adds an image watermark into the document with options and specified save format.
public static void SetImage(string inputFileName, string outputFileName, SaveFormat saveFormat, string watermarkImageFileName, ImageWatermarkOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveFormat SaveFormat
The save format.
watermarkImageFileName string
Image that is displayed as a watermark.
options ImageWatermarkOptions
Defines additional options for the image watermark.
Examples
Shows how to insert watermark image to the document.
string doc = MyDir + "Document.docx";
string watermarkImage = ImageDir + "Logo.jpg";
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkImage.1.docx", watermarkImage);
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.2.docx", SaveFormat.Docx, watermarkImage);
ImageWatermarkOptions options = new ImageWatermarkOptions();
options.Scale = 50;
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.3.docx", watermarkImage, options);
Watermarker.SetImage(doc, ArtifactsDir + "LowCode.SetWatermarkText.4.docx", SaveFormat.Docx, watermarkImage, options);Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetImage(string, string, SaveOptions, string)
Adds an image watermark into the document with options and specified save format.
public static void SetImage(string inputFileName, string outputFileName, SaveOptions saveOptions, string watermarkImageFileName)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveOptions SaveOptions
The save options.
watermarkImageFileName string
Image that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetImage(string, string, SaveOptions, string, ImageWatermarkOptions)
Adds an image watermark into the document with options and specified save format.
public static void SetImage(string inputFileName, string outputFileName, SaveOptions saveOptions, string watermarkImageFileName, ImageWatermarkOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveOptions SaveOptions
The save options.
watermarkImageFileName string
Image that is displayed as a watermark.
options ImageWatermarkOptions
Defines additional options for the image watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetImage(Stream, Stream, SaveFormat, SKBitmap)
[CLSCompliant(false)]
public static void SetImage(Stream inputStream, Stream outputStream, SaveFormat saveFormat, SKBitmap watermarkImage)Parameters
inputStream Stream
outputStream Stream
saveFormat SaveFormat
watermarkImage SKBitmap
SetImage(Stream, Stream, SaveFormat, SKBitmap, ImageWatermarkOptions)
[CLSCompliant(false)]
public static void SetImage(Stream inputStream, Stream outputStream, SaveFormat saveFormat, SKBitmap watermarkImage, ImageWatermarkOptions options)Parameters
inputStream Stream
outputStream Stream
saveFormat SaveFormat
watermarkImage SKBitmap
options ImageWatermarkOptions
SetImage(Stream, Stream, SaveOptions, SKBitmap)
[CLSCompliant(false)]
public static void SetImage(Stream inputStream, Stream outputStream, SaveOptions saveOptions, SKBitmap watermarkImage)Parameters
inputStream Stream
outputStream Stream
saveOptions SaveOptions
watermarkImage SKBitmap
SetImage(Stream, Stream, SaveOptions, SKBitmap, ImageWatermarkOptions)
[CLSCompliant(false)]
public static void SetImage(Stream inputStream, Stream outputStream, SaveOptions saveOptions, SKBitmap watermarkImage, ImageWatermarkOptions options)Parameters
inputStream Stream
outputStream Stream
saveOptions SaveOptions
watermarkImage SKBitmap
options ImageWatermarkOptions
SetImage(Stream, Stream, SaveFormat, Stream)
Adds an image watermark into the document from streams with options.
public static void SetImage(Stream inputStream, Stream outputStream, SaveFormat saveFormat, Stream watermarkImageStream)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveFormat SaveFormat
The save format.
watermarkImageStream Stream
Image stream that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetImage(Stream, Stream, SaveFormat, Stream, ImageWatermarkOptions)
Adds an image watermark into the document from streams with options.
public static void SetImage(Stream inputStream, Stream outputStream, SaveFormat saveFormat, Stream watermarkImageStream, ImageWatermarkOptions options)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveFormat SaveFormat
The save format.
watermarkImageStream Stream
Image stream that is displayed as a watermark.
options ImageWatermarkOptions
Defines additional options for the image watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetImage(Stream, Stream, SaveOptions, Stream)
Adds an image watermark into the document from streams with options.
public static void SetImage(Stream inputStream, Stream outputStream, SaveOptions saveOptions, Stream watermarkImageStream)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveOptions SaveOptions
The save options.
watermarkImageStream Stream
Image stream that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetImage(Stream, Stream, SaveOptions, Stream, ImageWatermarkOptions)
Adds an image watermark into the document from streams with options.
public static void SetImage(Stream inputStream, Stream outputStream, SaveOptions saveOptions, Stream watermarkImageStream, ImageWatermarkOptions options)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveOptions SaveOptions
The save options.
watermarkImageStream Stream
Image stream that is displayed as a watermark.
options ImageWatermarkOptions
Defines additional options for the image watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetText(string, string, string)
Adds a text watermark into the document.
public static void SetText(string inputFileName, string outputFileName, string watermarkText)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
watermarkText string
Text that is displayed as a watermark.
Examples
Shows how to insert watermark text to the document.
string doc = MyDir + "Big document.docx";
string watermarkText = "This is a watermark";
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.1.docx", watermarkText);
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.2.docx", SaveFormat.Docx, watermarkText);
TextWatermarkOptions watermarkOptions = new TextWatermarkOptions();
watermarkOptions.Color = Color.Red;
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.3.docx", watermarkText, watermarkOptions);
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.4.docx", SaveFormat.Docx, watermarkText, watermarkOptions);Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetText(string, string, string, TextWatermarkOptions)
Adds a text watermark into the document with options.
public static void SetText(string inputFileName, string outputFileName, string watermarkText, TextWatermarkOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
watermarkText string
Text that is displayed as a watermark.
options TextWatermarkOptions
Defines additional options for the text watermark.
Examples
Shows how to insert watermark text to the document.
string doc = MyDir + "Big document.docx";
string watermarkText = "This is a watermark";
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.1.docx", watermarkText);
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.2.docx", SaveFormat.Docx, watermarkText);
TextWatermarkOptions watermarkOptions = new TextWatermarkOptions();
watermarkOptions.Color = Color.Red;
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.3.docx", watermarkText, watermarkOptions);
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.4.docx", SaveFormat.Docx, watermarkText, watermarkOptions);Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetText(string, string, SaveFormat, string)
Adds a text watermark into the document with options and specified save format.
public static void SetText(string inputFileName, string outputFileName, SaveFormat saveFormat, string watermarkText)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveFormat SaveFormat
The save format.
watermarkText string
Text that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetText(string, string, SaveFormat, string, TextWatermarkOptions)
Adds a text watermark into the document with options and specified save format.
public static void SetText(string inputFileName, string outputFileName, SaveFormat saveFormat, string watermarkText, TextWatermarkOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveFormat SaveFormat
The save format.
watermarkText string
Text that is displayed as a watermark.
options TextWatermarkOptions
Defines additional options for the text watermark.
Examples
Shows how to insert watermark text to the document.
string doc = MyDir + "Big document.docx";
string watermarkText = "This is a watermark";
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.1.docx", watermarkText);
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.2.docx", SaveFormat.Docx, watermarkText);
TextWatermarkOptions watermarkOptions = new TextWatermarkOptions();
watermarkOptions.Color = Color.Red;
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.3.docx", watermarkText, watermarkOptions);
Watermarker.SetText(doc, ArtifactsDir + "LowCode.WatermarkText.4.docx", SaveFormat.Docx, watermarkText, watermarkOptions);Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetText(string, string, SaveOptions, string)
Adds a text watermark into the document with options and specified save format.
public static void SetText(string inputFileName, string outputFileName, SaveOptions saveOptions, string watermarkText)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveOptions SaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetText(string, string, SaveOptions, string, TextWatermarkOptions)
Adds a text watermark into the document with options and specified save format.
public static void SetText(string inputFileName, string outputFileName, SaveOptions saveOptions, string watermarkText, TextWatermarkOptions options)Parameters
inputFileName string
The input file name.
outputFileName string
The output file name.
saveOptions SaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
options TextWatermarkOptions
Defines additional options for the text watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), each page of the output will be saved as a separate file. The specified output file name will be used to generate file names for each part following the rule: outputFile_partIndex.extension.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF file.
SetText(Stream, Stream, SaveFormat, string)
Adds a text watermark into the document from streams with options.
public static void SetText(Stream inputStream, Stream outputStream, SaveFormat saveFormat, string watermarkText)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveFormat SaveFormat
The save format.
watermarkText string
Text that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetText(Stream, Stream, SaveFormat, string, TextWatermarkOptions)
Adds a text watermark into the document from streams with options.
public static void SetText(Stream inputStream, Stream outputStream, SaveFormat saveFormat, string watermarkText, TextWatermarkOptions options)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveFormat SaveFormat
The save format.
watermarkText string
Text that is displayed as a watermark.
options TextWatermarkOptions
Defines additional options for the text watermark.
Examples
Shows how to insert watermark text to the document from the stream.
string watermarkText = "This is a watermark";
using (FileStream streamIn = new FileStream(MyDir + "Document.docx", FileMode.Open, FileAccess.Read))
{
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.WatermarkTextStream.1.docx", FileMode.Create, FileAccess.ReadWrite))
Watermarker.SetText(streamIn, streamOut, SaveFormat.Docx, watermarkText);
using (FileStream streamOut = new FileStream(ArtifactsDir + "LowCode.WatermarkTextStream.2.docx", FileMode.Create, FileAccess.ReadWrite))
{
TextWatermarkOptions options = new TextWatermarkOptions();
options.Color = Color.Red;
Watermarker.SetText(streamIn, streamOut, SaveFormat.Docx, watermarkText, options);
}
}Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetText(Stream, Stream, SaveOptions, string)
Adds a text watermark into the document from streams with options.
public static void SetText(Stream inputStream, Stream outputStream, SaveOptions saveOptions, string watermarkText)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveOptions SaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetText(Stream, Stream, SaveOptions, string, TextWatermarkOptions)
Adds a text watermark into the document from streams with options.
public static void SetText(Stream inputStream, Stream outputStream, SaveOptions saveOptions, string watermarkText, TextWatermarkOptions options)Parameters
inputStream Stream
The input stream.
outputStream Stream
The output stream.
saveOptions SaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
options TextWatermarkOptions
Defines additional options for the text watermark.
Remarks
If the output format is an image (BMP, EMF, EPS, GIF, JPEG, PNG, or WebP), only the first page of the output will be saved to the specified stream.
If the output format is TIFF, the output will be saved as a single multi-frame TIFF to the specified stream.
SetWatermarkToImages(string, ImageSaveOptions, string)
Adds a text watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(string inputFileName, ImageSaveOptions saveOptions, string watermarkText)Parameters
inputFileName string
The input file name.
saveOptions ImageSaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
Returns
Stream []
SetWatermarkToImages(string, ImageSaveOptions, string, TextWatermarkOptions)
Adds a text watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(string inputFileName, ImageSaveOptions saveOptions, string watermarkText, TextWatermarkOptions options)Parameters
inputFileName string
The input file name.
saveOptions ImageSaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
options TextWatermarkOptions
Defines additional options for the text watermark.
Returns
Stream []
Examples
Shows how to insert watermark text to the document and save result to images.
string doc = MyDir + "Big document.docx";
string watermarkText = "This is a watermark";
Stream[] images = Watermarker.SetWatermarkToImages(doc, new ImageSaveOptions(SaveFormat.Png), watermarkText);
TextWatermarkOptions watermarkOptions = new TextWatermarkOptions();
watermarkOptions.Color = Color.Red;
images = Watermarker.SetWatermarkToImages(doc, new ImageSaveOptions(SaveFormat.Png), watermarkText, watermarkOptions);SetWatermarkToImages(Stream, ImageSaveOptions, string)
Adds a text watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(Stream inputStream, ImageSaveOptions saveOptions, string watermarkText)Parameters
inputStream Stream
The input file stream.
saveOptions ImageSaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
Returns
Stream []
SetWatermarkToImages(Stream, ImageSaveOptions, string, TextWatermarkOptions)
Adds a text watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(Stream inputStream, ImageSaveOptions saveOptions, string watermarkText, TextWatermarkOptions options)Parameters
inputStream Stream
The input file stream.
saveOptions ImageSaveOptions
The save options.
watermarkText string
Text that is displayed as a watermark.
options TextWatermarkOptions
Defines additional options for the text watermark.
Returns
Stream []
Examples
Shows how to insert watermark text to the document from the stream and save result to images.
string watermarkText = "This is a watermark";
using (FileStream streamIn = new FileStream(MyDir + "Document.docx", FileMode.Open, FileAccess.Read))
{
Stream[] images = Watermarker.SetWatermarkToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), watermarkText);
TextWatermarkOptions watermarkOptions = new TextWatermarkOptions();
watermarkOptions.Color = Color.Red;
images = Watermarker.SetWatermarkToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), watermarkText, watermarkOptions);
}SetWatermarkToImages(string, ImageSaveOptions, byte[])
Adds an image watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(string inputFileName, ImageSaveOptions saveOptions, byte[] watermarkImageBytes)Parameters
inputFileName string
The input file name.
saveOptions ImageSaveOptions
The save options.
watermarkImageBytes byte
[]
Image bytes that is displayed as a watermark.
Returns
Stream []
SetWatermarkToImages(string, ImageSaveOptions, byte[], ImageWatermarkOptions)
Adds an image watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(string inputFileName, ImageSaveOptions saveOptions, byte[] watermarkImageBytes, ImageWatermarkOptions options)Parameters
inputFileName string
The input file name.
saveOptions ImageSaveOptions
The save options.
watermarkImageBytes byte
[]
Image bytes that is displayed as a watermark.
options ImageWatermarkOptions
Defines additional options for the image watermark.
Returns
Stream []
Examples
Shows how to insert watermark image to the document and save result to images.
string doc = MyDir + "Document.docx";
string watermarkImage = ImageDir + "Logo.jpg";
Watermarker.SetWatermarkToImages(doc, new ImageSaveOptions(SaveFormat.Png), File.ReadAllBytes(watermarkImage));
ImageWatermarkOptions options = new ImageWatermarkOptions();
options.Scale = 50;
Watermarker.SetWatermarkToImages(doc, new ImageSaveOptions(SaveFormat.Png), File.ReadAllBytes(watermarkImage), options);SetWatermarkToImages(Stream, ImageSaveOptions, Stream)
Adds an image watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(Stream inputStream, ImageSaveOptions saveOptions, Stream watermarkImageStream)Parameters
inputStream Stream
The input stream.
saveOptions ImageSaveOptions
The save options.
watermarkImageStream Stream
Image stream that is displayed as a watermark.
Returns
Stream []
SetWatermarkToImages(Stream, ImageSaveOptions, Stream, ImageWatermarkOptions)
Adds an image watermark into the document with options. Renders the output to images.
public static Stream[] SetWatermarkToImages(Stream inputStream, ImageSaveOptions saveOptions, Stream watermarkImageStream, ImageWatermarkOptions options)Parameters
inputStream Stream
The input stream.
saveOptions ImageSaveOptions
The save options.
watermarkImageStream Stream
Image stream that is displayed as a watermark.
options ImageWatermarkOptions
Defines additional options for the image watermark.
Returns
Stream []
Examples
Shows how to insert watermark image to the document from a stream and save result to images.
string watermarkImage = ImageDir + "Logo.jpg";
using (FileStream streamIn = new FileStream(MyDir + "Document.docx", FileMode.Open, FileAccess.Read))
{
using (FileStream imageStream = new FileStream(watermarkImage, FileMode.Open, FileAccess.Read))
{
Watermarker.SetWatermarkToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), imageStream);
Watermarker.SetWatermarkToImages(streamIn, new ImageSaveOptions(SaveFormat.Png), imageStream, new ImageWatermarkOptions() { Scale = 50 });
}
}