Watermarks

<< Click to Display Table of Contents >>

Navigation:  Programming Techniques >

Watermarks

Previous pageReturn to chapter overviewNext page

By default, new objects are added at the top of the z-order. This means newly added objects are drawn above all previously added objects. For the Professional Edition and higher you can set the property InsertAtBottomZOrder = True to add new objects at the bottom of the z-order, i.e. newly added objects are drawn below all previously added objects.

This way you can easily add watermarks to a document.

Example: let’s assume you have created and printed a document. The document is still in memory and you wish to add a watermark, in order to print a copy:

Doc.InsertAtBottomZOrder = true

Doc.TextColor = COLOR_LTGRAY

Doc.FontSize = 28

for page = 1 to Doc.PageCount

 Doc.CurrentPage = page

 Doc.Print(8, 13, "COPY")

end for

Doc.PrintDoc(true)

The above example places a watermark with the text “COPY” in light gray on each page. Afterwards the document is printed.

 

The following example assumes you have already created a document and stored it to a file using the method WriteDoc(“mydoc.vpe”). The example code reads the file into memory and places a watermark with the text “COPY” in light gray on each page. Afterwards the document is written to the file “mydoc_copy.vpe”.

Doc.OpenDoc()

Doc.ReadDoc("mydoc.vpe")

Doc.InsertAtBottomZOrder = true

Doc.TextColor = COLOR_LTGRAY

Doc.FontSize = 28

for page = 1 to Doc.PageCount

 Doc.CurrentPage = page

 Doc.Print(8, 13, "COPY")

end for

Doc.WriteDoc("mydoc_copy.vpe")

Doc.CloseDoc()