Classic ASP Requires Chilkat v11.7.0+
>, says so with placeholderSyntax, written around the word "name".
Classic ASP
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 Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
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 letter_template.pdf
set pdf = Server.CreateObject("Chilkat.Pdf")
success = pdf.LoadFile("qa_data/pdf/letter_template.pdf")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
Response.End
End If
' The letter reads: "Dear [[name]]," ... "expires on [[expiry]]" ... "[[amount]] per year" ... "[[agent]]".
set json = Server.CreateObject("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")
set jsonOut = Server.CreateObject("Chilkat.JsonObject")
success = pdf.TextReplace("apply",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( "Not applied: " & jsonOut.Emit()) & "</pre>"
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
Response.End
End If
End If
i = 0
count_i = jsonOut.SizeOfArray("replacements")
Do While i < count_i
jsonOut.I = i
Response.Write "<pre>" & Server.HTMLEncode( "[[" & jsonOut.StringOf("replacements[i].field") & "]] replaced") & "</pre>"
i = i + 1
Loop
success = pdf.WriteFile("qa_output/letter_rivera.pdf")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
Response.End
End If
' Sample output:
' [[date]] replaced
' [[name]] replaced
' [[expiry]] replaced
' [[amount]] replaced
' [[agent]] replaced
%>
</body>
</html>