Visual FoxPro Requires Chilkat v11.7.0+
>, says so with placeholderSyntax, written around the word "name".
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loPdf
LOCAL loJson
LOCAL loJsonOut
LOCAL i
LOCAL lnCount_i
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 letter_template.pdf
loPdf = CreateObject('Chilkat.Pdf')
lnSuccess = loPdf.LoadFile("qa_data/pdf/letter_template.pdf")
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
CANCEL
ENDIF
* The letter reads: "Dear [[name]]," ... "expires on [[expiry]]" ... "[[amount]] per year" ... "[[agent]]".
loJson = CreateObject('Chilkat.JsonObject')
loJson.UpdateString("placeholderSyntax","[[name]]")
loJson.UpdateString("placeholders.date","October 18, 2026")
loJson.UpdateString("placeholders.name","Ms. Rivera")
loJson.UpdateString("placeholders.expiry","December 31, 2026")
loJson.UpdateString("placeholders.amount","$299.00")
loJson.UpdateString("placeholders.agent","Dana Whitfield, Account Manager")
loJsonOut = CreateObject('Chilkat.JsonObject')
lnSuccess = loPdf.TextReplace("apply",loJson,loJsonOut)
IF (lnSuccess = 0) THEN
? "Not applied: " + loJsonOut.Emit()
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut
CANCEL
ENDIF
ENDIF
i = 0
lnCount_i = loJsonOut.SizeOfArray("replacements")
DO WHILE i < lnCount_i
loJsonOut.I = i
? "[[" + loJsonOut.StringOf("replacements[i].field") + "]] replaced"
i = i + 1
ENDDO
lnSuccess = loPdf.WriteFile("qa_output/letter_rivera.pdf")
IF (lnSuccess = 0) THEN
? loPdf.LastErrorText
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut
CANCEL
ENDIF
* Sample output:
* [[date]] replaced
* [[name]] replaced
* [[expiry]] replaced
* [[amount]] replaced
* [[agent]] replaced
RELEASE loPdf
RELEASE loJson
RELEASE loJsonOut