Watermarker.SetImage

Watermarker SetImage method. Adds Image watermark into the document.

SetImage(string, string, string)

Adds Image watermark into the document.

public static void SetImage(string inputFileName, string outputFileName, 
    string watermarkImageFileName)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
watermarkImageFileNameStringImage 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.

Examples

Shows how to add image watermark into the document.

Watermarker.SetImage(MyDir + "Simple.docx", ArtifactsDir + "Watermarker.SetImage.docx", MyDir + @"Images\logo.png");

See Also


SetImage(string, string, string, ImageWatermarkOptions)

Adds Image watermark into the document.

public static void SetImage(string inputFileName, string outputFileName, 
    string watermarkImageFileName, ImageWatermarkOptions options = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
watermarkImageFileNameStringImage that is displayed as a watermark.
optionsImageWatermarkOptionsDefines 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.

Examples

Shows how to add image watermark into the document with custom watermark options.

ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions();
imageWatermarkOptions.Scale = 0.1;
imageWatermarkOptions.IsWashout = true;
Watermarker.SetImage(MyDir + "Simple.docx", ArtifactsDir + "Watermarker.SetImage.doc", MyDir + @"Images\logo.png", imageWatermarkOptions);

See Also


SetImage(string, string, SaveFormat, string, ImageWatermarkOptions)

Adds Image watermark into the document.

public static void SetImage(string inputFileName, string outputFileName, SaveFormat saveFormat, 
    string watermarkImageFileName, ImageWatermarkOptions options = null)
ParameterTypeDescription
inputFileNameStringThe input file name.
outputFileNameStringThe output file name.
saveFormatSaveFormatThe save format.
watermarkImageFileNameStringImage that is displayed as a watermark.
optionsImageWatermarkOptionsDefines 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.

Examples

Shows how to add image watermark into the document saving the result in explicitly specified save format.

ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions() { Scale = 0.1 };
Watermarker.SetImage(MyDir + "Simple.docx", ArtifactsDir + "Watermarker.SetImage.rtf", SaveFormat.Rtf, MyDir + @"Images\logo.png", imageWatermarkOptions);

See Also


SetImage(Stream, Stream, SaveFormat, Image, ImageWatermarkOptions)

Adds Image watermark into the document.

public static void SetImage(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    Image watermarkImage, ImageWatermarkOptions options = null)
ParameterTypeDescription
inputStreamStreamThe input stream.
outputStreamStreamThe output stream.
saveFormatSaveFormatThe save format.
watermarkImageImageImage that is displayed as a watermark.
optionsImageWatermarkOptionsDefines 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.

Examples

Shows how to add image watermark from Image object into the document using streams.

ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions() { Scale = 0.1 };

using (Stream input = File.OpenRead(MyDir + "Simple.docx"))
using (Stream output = File.Create(ArtifactsDir + "Watermarker.SetImage.xps"))
using (System.Drawing.Image image = System.Drawing.Image.FromFile(MyDir + @"Images\logo.png"))
{
    Watermarker.SetImage(input, output, SaveFormat.Xps, image, imageWatermarkOptions);
}

See Also


SetImage(Stream, Stream, SaveFormat, Stream, ImageWatermarkOptions)

Adds Image watermark into the document.

public static void SetImage(Stream inputStream, Stream outputStream, SaveFormat saveFormat, 
    Stream watermarkImageStream, ImageWatermarkOptions options = null)
ParameterTypeDescription
inputStreamStreamThe input stream.
outputStreamStreamThe output stream.
saveFormatSaveFormatThe save format.
watermarkImageStreamStreamImage stream that is displayed as a watermark.
optionsImageWatermarkOptionsDefines 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.

Examples

Shows how to add image watermark into the document using streams.

ImageWatermarkOptions imageWatermarkOptions = new ImageWatermarkOptions() { Scale = 0.1 };

using (Stream input = File.OpenRead(MyDir + "Simple.docx"))
using (Stream output = File.Create(ArtifactsDir + "Watermarker.SetImage.pdf"))
using (Stream image = File.OpenRead(MyDir + @"Images\logo.png"))
{
    Watermarker.SetImage(input, output, SaveFormat.Pdf, image, imageWatermarkOptions);
}

See Also