Visual FoxPro Requires Chilkat v11.7.0+
Visual FoxPro
Tile a Watermark Across a PDF Page
See more PDF Watermark Examples
Demonstrates a tiled watermark, which repeats the stamp over the whole page instead of placing it once. Tiling overrides position.align; tile.spacingX and spacingY set the gaps, and tile.stagger offsets alternate rows by half a tile so the pattern does not line up in columns. A faint tiled stamp carrying the name or address is the usual way to mark a document so that a leaked copy can be traced back, and zOrder back keeps it behind the text where it does not hinder reading.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loPdf
LOCAL loJson
LOCAL loJsonOut
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
* The PDF used in this example is available at long_report.pdf
loPdf = CreateObject('Chilkat.Pdf')
lnSuccess = loPdf.LoadFile("qa_data/pdf/long_report.pdf")
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
CANCEL
ENDIF
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("type","text")
* {date:FORMAT} is replaced per page when the watermark is added. The other placeholders are
* {page}, {pages} and {filename}; {{ gives a literal brace.
loJson.UpdateString("text","jdoe@example.com {date:yyyy-MM-dd}")
loJson.UpdateString("id","trace")
loJson.UpdateString("zOrder","back")
loJson.UpdateNumber("font.size","14")
loJson.UpdateNumber("opacity","0.15")
loJson.UpdateNumber("rotation","30")
loJson.UpdateBool("tile.enabled",1)
loJson.UpdateNumber("tile.spacingX","60")
loJson.UpdateNumber("tile.spacingY","80")
loJson.UpdateBool("tile.stagger",1)
loJsonOut = CreateObject('Chilkat.JsonObject')
lnSuccess = loPdf.Watermark("add",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut
CANCEL
ENDIF
? "id: " + loJsonOut.StringOf("id") + " pages: " + loJsonOut.StringOf("pages")
lnSuccess = loPdf.WriteFile("qa_output/report_traced.pdf")
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut
CANCEL
ENDIF
* Sample output:
* id: trace pages: 1-3
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut