VBScript Requires Chilkat v11.7.0+
VBScript
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 VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 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
set pdf = CreateObject("Chilkat.Pdf")
success = pdf.LoadFile("qa_data/pdf/long_report.pdf")
If (success = 0) Then
outFile.WriteLine(pdf.LastErrorText)
WScript.Quit
End If
set json = CreateObject("Chilkat.JsonObject")
success = json.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.
success = json.UpdateString("text","jdoe@example.com {date:yyyy-MM-dd}")
success = json.UpdateString("id","trace")
success = json.UpdateString("zOrder","back")
success = json.UpdateNumber("font.size","14")
success = json.UpdateNumber("opacity","0.15")
success = json.UpdateNumber("rotation","30")
success = json.UpdateBool("tile.enabled",1)
success = json.UpdateNumber("tile.spacingX","60")
success = json.UpdateNumber("tile.spacingY","80")
success = json.UpdateBool("tile.stagger",1)
set jsonOut = CreateObject("Chilkat.JsonObject")
success = pdf.Watermark("add",json,jsonOut)
If (success = 0) Then
outFile.WriteLine(pdf.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("id: " & jsonOut.StringOf("id") & " pages: " & jsonOut.StringOf("pages"))
success = pdf.WriteFile("qa_output/report_traced.pdf")
If (success = 0) Then
outFile.WriteLine(pdf.LastErrorText)
WScript.Quit
End If
' Sample output:
' id: trace pages: 1-3
outFile.Close