Adds a watermark to PDF document.

Namespace:  SautinSoft
Assembly:  PdfMetamorphosis (in PdfMetamorphosis.dll) Version: 6.7.12.19

Syntax

      
 C#  Visual Basic 
Public Function Add ( _
	imagePath As String, _
	x As PdfMetamorphosis..::.Sizes, _
	y As PdfMetamorphosis..::.Sizes, _
	width As PdfMetamorphosis..::.Sizes, _
	height As PdfMetamorphosis..::.Sizes, _
	transparency As Integer, _
	pageNum As Integer() _
) As PdfMetamorphosis..::.WaterMark

Parameters

imagePath
String
Path to image for watermark.
x
PdfMetamorphosis..::.Sizes
A watermark position by horizontal from the left-top edge of page.
y
PdfMetamorphosis..::.Sizes
A watermark position by vertical from the left-top edge of page.
width
PdfMetamorphosis..::.Sizes
A watermark width.
height
PdfMetamorphosis..::.Sizes
A warermark height.
transparency
Int32
Transparency in percents. 0 - invisible.
pageNum
array< Int32 >[]()[]
Place this watermark only on these pages.

Return Value

Reference to the just added watermark.

Examples

CopyHow to add Watermarks into a produced PDF document using C# in memory
using System;
using System.IO;
using System.Collections;

namespace Sample
{
    class Test
    {

        static void Main(string[] args)
        {
            SautinSoft.PdfMetamorphosis p = new SautinSoft.PdfMetamorphosis();

            SautinSoft.PdfMetamorphosis.WaterMark w1 = new SautinSoft.PdfMetamorphosis.WaterMark(@"..\..\..\..\..\WaterMark.png");

            w1.PosX.Mm = 0;
            w1.PosX.Mm = 0;
            w1.PosDX.Mm = 50;
            w1.PosDY.Mm = 50;

            p.WaterMarks.Add(w1);


            SautinSoft.PdfMetamorphosis.WaterMark w2 = p.WaterMarks.Add();
            w2.Img = System.Drawing.Image.FromFile(@"..\..\..\..\..\WaterMark.png");
            w2.Transparency = 20;
            w2.PosX.Mm = 60;
            w2.PosY.Mm = 0;
            w2.PosDX.Mm = 100;
            w2.PosDY.Mm = 100;
            w2.PageNum = new int[] { 1 };



            if (p != null)
            {
                string rtfPath = @"..\..\..\..\..\test.rtf";
                string pdfPath = @"..\..\..\..\..\test.pdf";

                int i = p.RtfToPdfConvertFile(rtfPath,pdfPath);

                if (i !=0)
                {
                    System.Console.WriteLine("An error occured during converting RTF to PDF!");
                }
                else
                {
                    System.Diagnostics.Process.Start(pdfPath);
                }
            }
        }
    }
}
CopyHow to add Watermarks into a produced PDF document using VB.Net in memory
Imports System
Imports System.IO
Imports System.Text

Module sample

    Sub Main()
        Dim p As New SautinSoft.PdfMetamorphosis()

        Dim w1 As New SautinSoft.PdfMetamorphosis.WaterMark("..\..\..\..\..\WaterMark.png")

        w1.PosX.Mm = 0
        w1.PosX.Mm = 0
        w1.PosDX.Mm = 50
        w1.PosDY.Mm = 50

        p.WaterMarks.Add(w1)


        Dim w2 As SautinSoft.PdfMetamorphosis.WaterMark = p.WaterMarks.Add()
        w2.Img = System.Drawing.Image.FromFile("..\..\..\..\..\WaterMark.png")
        w2.Transparency = 20
        w2.PosX.Mm = 60
        w2.PosY.Mm = 0
        w2.PosDX.Mm = 100
        w2.PosDY.Mm = 100
        w2.PageNum = New Integer() {1}



        If p IsNot Nothing Then
            Dim rtfPath As String = "..\..\..\..\..\test.rtf"
            Dim pdfPath As String = "..\..\..\..\..\test.pdf"

            Dim i As Integer = p.RtfToPdfConvertFile(rtfPath, pdfPath)

            If i <> 0 Then
                System.Console.WriteLine("An error occured during converting RTF to PDF!")
            Else
                System.Diagnostics.Process.Start(pdfPath)
            End If
        End If
    End Sub
End Module

See Also