Home > BSPrinter documentation > Reference

AddWatermark Method

Applies to: PrintPreview control , IPrinterEx object

Return Type: None.
In          Required          Text          As String
In          Optional          Angle          As Long          Default value: 0
In          Optional          OpacityPercent          As Single          Default value: 15
In          Optional          ZPosition          As BSWatermarkZPositionConstants          Default value: 1 - bsWPForeground
In          Optional          Color          As Long          Default value: 0
In          Optional          PositionUnits          As BSWatermarkPositionUnitsConstants          Default value: 0 - bsPUPercentageOfPage
In          Optional          Left          As Single          Default value: 15
In          Optional          Top          As Single          Default value: 20
In          Optional          Width          As Single          Default value: 70
In          Optional          Height          As Single          Default value: 60
In          Optional          Font          As Font          Default value: 0
In          Optional          ID          As String


Adds a watermark text that will be printed on each page.
The only required parameter is the watermark text.
Any number of watermarks can be added.
The watermarks need to be added from the procedure that prints the report. With the PrintPreview control it means that they must be added when the PrepareReport event is executing, that is, from inside that event.

Parameters explained.

Text: the text of the watermark. It may contain more than one line by adding line feeds (vbCrLf).

Angle: the angle in that defines the direction of the watermark, between 0 and 360 degrees. The default is 0 and means horizontal. A value of 45 produces diagonal watermark and a value of 90 a vertical watermark.

OpacityPercent: it defines the opacity of the watermark. The value must be between 0 and 100. 0 means transparent and 100 means opaque. The default is 15.

ZPosition: defines if the watermark is placed behind the printing of the document or above. The default value is bsWPForeground that means above.
Note: When the watermark is placed on the foreground, it uses GDI+ that is available from Windows XP.

Color: sets the fore color of the text. The default value is vbBlack

PositionUnits: defines the units used in the following position and size parameters.
bsPUPercentageOfPage: The watermark position and size are set in percentage of the page (of the full page, without taking into account margins, but taking into account the non-printable area).
bsPUPrinterScaleMode: The watermark position and size are set in the current ScaleMode units of the Printer object. If HandleMargins is True, the position and size is set inside the margins. Printer.ScaleWidth and Printer.ScaleHeight return the full ranges as a reference.

Left, Top, Width and Height: define the position of the watermark in the page. The default values are: 15, 20, 70 and 60, that along with PositionUnits set to bsPUPercentageOfPage (also the default value) position the watermark in the middle of the page.

Font: sets the font. The size is automatically changed to fit the space that was defined with the position parameters.

ID: needed only if you are going to call the RemoveWatermark method. It is used to identify the watermark. More than one watermark can share the same ID (in that case they will be removed together by RemoveWatermark.

Note: for printing the watermark in right to left direction, the Printer must be set with RightToLeft to True before adding the watermark.

See Also:

RemoveWatermark method
RemoveAllWatermarks method
SetHeader method
SetFooter method