BCL easyPDF SDK
easyPDF SDK Usermanual
PDF Creator Programming API  |  Download Free Trial  |  Contact Us to Purchase

AddWatermarkOnLayer Method

Adds a watermark onto a layer with advanced visibility options. For example, this function allows print-only watermarks.

Sub AddWatermarkOnLayer(InputFileName As String,
                         OutputFileName As String,
                         hpos As prcWmarkHPosition,
                         vpos As prcWmarkVPosition,
                         zpos As prcWmarkZOrder,
                         alignment As prcWmarkAlignment,
                         hoffset As Double,
                         voffset As Double,
                         firstPageOnly As Boolean,
                         font As String,
                         fontsize As Double,
                         embedding As prcFontEmbedding,
                         angle As Double,
                         color As OLE_COLOR,
                         opacity As Double,
                         outlineOnly As Boolean,
                         text As String,
                         bShowWhenDisplay As Boolean,
                         bShowWhenPrint As Boolean,
                         bShowWhenExport As Boolean,
                         AdvancedOptions As String)

void AddWatermarkOnLayer(string InputFileName,
                          string OutputFileName,
                          prcWmarkHPosition hpos,
                          prcWmarkVPosition vpos,
                          prcWmarkZOrder zpos,
                          prcWmarkAlignment alignment,
                          double hoffset,
                          double voffset,
                          bool firstPageOnly,
                          string font,
                          double fontsize,
                          prcFontEmbedding embedding,
                          double angle,
                          System.UInt32 color,
                          double opacity,
                          bool outlineOnly,
                          string text,
                          bool bShowWhenDisplay,
                          bool bShowWhenPrint,
                          bool bShowWhenExport,
                          string AdvancedOptions)

void AddWatermarkOnLayer(String InputFileName,
                          String OutputFileName,
                          prcWmarkHPosition hpos,
                          prcWmarkVPosition vpos,
                          prcWmarkZOrder zpos,
                          prcWmarkAlignment alignment,
                          double hoffset,
                          double voffset,
                          boolean firstPageOnly,
                          String font,
                          double fontsize,
                          prcFontEmbedding embedding,
                          double angle,
                          int color,
                          double opacity,
                          boolean outlineOnly,
                          String text,
                          boolean bShowWhenDisplay,
                          boolean bShowWhenPrint,
                          boolean bShowWhenExport,
                          String AdvancedOptions) throws PDFProcessorException

Parameters

Return Values

N/A.

Remarks

Note 1: Coordinate system information:

  1. The location of the origin (0, 0) is at top-left corner.

Note 2: OLE_COLOR conversion from various programming languages:

C++:

static_cast<OLE_COLOR>(RGB(0, 0, 255))

VB6:

RGB(0, 0, 255)

VB.NET:

Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.FromArgb(0, 0, 255))

C#:

(uint)System.Drawing.ColorTranslator.ToOle(Color.FromArgb(0, 0, 255))

Others:

32 bit integer value in following format: 0x00bbggrr (in BGR format, not in RGB)


For more information about color translation, refer to MSDN Knowledge Base article Q131101.

Note 3: This function uses layers (also known as Optional Content Groups), a feature that requires PDF-1.5 or newer (Acrobat 6 or newer). If the input PDF's version is older, this function automatically increases it to PDF-1.5.

Example Usage

Set oProcessor = CreateObject("easyPDF.PDFProcessor.8")
 
oProcessor.AddWatermarkOnLayer "C:\test\input.pdf", _
                               "C:\test\output.pdf", _
                               PRC_WMARK_HPOS_CENTER, _ 
                               PRC_WMARK_VPOS_TOP, _ 
                               PRC_WMARK_ZORDER_TOP, _
                               PRC_WMARK_ALIGN_CENTER, _
                               0, _
                               0, _
                               False, _
                               "Arial", _
                               40, _
                               0, _
                               35, _
                               RGB(255, 0, 255), _
                               50, _
                               True, _
                               "Watermark", _
                               False, True, True ' visible for Print and Export only