Xojo Plugin Requires Chilkat v11.7.0+
>, says so with placeholderSyntax, written around the word "name".
Xojo Plugin
PDF Placeholders with Other Delimiters: [[name]]
See more PDF Text Replacement Examples
Demonstrates the "placeholderSyntax" option. Placeholders are {{name}} by default; a template written with other delimiters, such as [[name]] or <Chilkat Xojo Plugin Downloads
Dim success As Boolean
success = False
// 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 letter_template.pdf
Dim pdf As New Chilkat.Pdf
success = pdf.LoadFile("qa_data/pdf/letter_template.pdf")
If (success = False) Then
System.DebugLog(pdf.LastErrorText)
Return
End If
// The letter reads: "Dear [[name]]," ... "expires on [[expiry]]" ... "[[amount]] per year" ... "[[agent]]".
Dim json As New Chilkat.JsonObject
success = json.UpdateString("placeholderSyntax","[[name]]")
success = json.UpdateString("placeholders.date","October 18, 2026")
success = json.UpdateString("placeholders.name","Ms. Rivera")
success = json.UpdateString("placeholders.expiry","December 31, 2026")
success = json.UpdateString("placeholders.amount","$299.00")
success = json.UpdateString("placeholders.agent","Dana Whitfield, Account Manager")
Dim jsonOut As New Chilkat.JsonObject
success = pdf.TextReplace("apply",json,jsonOut)
If (success = False) Then
System.DebugLog("Not applied: " + jsonOut.Emit())
If (success = False) Then
System.DebugLog(pdf.LastErrorText)
Return
End If
End If
Dim i As Int32
i = 0
Dim count_i As Int32
count_i = jsonOut.SizeOfArray("replacements")
While i < count_i
jsonOut.I = i
System.DebugLog("[[" + jsonOut.StringOf("replacements[i].field") + "]] replaced")
i = i + 1
Wend
success = pdf.WriteFile("qa_output/letter_rivera.pdf")
If (success = False) Then
System.DebugLog(pdf.LastErrorText)
Return
End If
// Sample output:
// [[date]] replaced
// [[name]] replaced
// [[expiry]] replaced
// [[amount]] replaced
// [[agent]] replaced