Add

Add(Watermark)

Adds a watermark to the loaded document.

public AddWatermarkResult Add(Watermark watermark)
Parameter Type Description
watermark Watermark The watermark to add to the document.

Remarks

Learn more about adding watermarks: Adding watermarks.

Examples

Add image and text watermark to a document of any supported type.

using (Watermarker watermarker = new Watermarker(@"D:\input.pdf"))
{
    TextWatermark textWatermark = new TextWatermark("DRAFT", new Font("Arial", 19));
    textWatermark.HorizontalAlignment = HorizontalAlignment.Center;
    textWatermark.VerticalAlignment = VerticalAlignment.Top;
    textWatermark.ConsiderParentMargins = true;
    textWatermark.ForegroundColor = Color.Red;
    textWatermark.IsBackground = true;
    textWatermark.Opacity = 0.5;
    watermarker.Add(textWatermark);

    using (ImageWatermark imageWatermark = new ImageWatermark(@"D:\draft.png"))
    {
        imageWatermark.HorizontalAlignment = HorizontalAlignment.Center;
        imageWatermark.VerticalAlignment = VerticalAlignment.Bottom;
        imageWatermark.ConsiderParentMargins = true;
        imageWatermark.IsBackground = true;
        imageWatermark.Opacity = 0.5;
        watermarker.Add(imageWatermark);
    }

    watermarker.Save(@"D:\output.pdf");
}

See Also


Add(Watermark, WatermarkOptions)

Adds a watermark to the loaded document using watermark options.

public AddWatermarkResult Add(Watermark watermark, WatermarkOptions options)
Parameter Type Description
watermark Watermark The watermark to add to the document.
options WatermarkOptions Additional options to use when adding the watermark.

Remarks

Learn more about adding watermarks Adding watermarks.

Examples

Add an image watermark to a particular page of a pdf document.

PdfLoadOptions loadOptions = new PdfLoadOptions();
using (Watermarker watermarker = new Watermarker(@"C:\doc.pdf", loadOptions))
using (ImageWatermark watermark = new ImageWatermark(@"C:\watermark.png"))
{
    PdfXObjectWatermarkOptions options = new PdfXObjectWatermarkOptions();
    options.PageIndex = 0;

    watermarker.Add(watermark, options);
    watermarker.Save();
}

See Also