Classic ASP Requires Chilkat v11.7.0+
Classic ASP
How a PDF Watermark Is Stored: artifact, annotation, layer or content
See more PDF Watermark Examples
Demonstrates the approach member, which decides how the watermark is stored and therefore what can be done with it afterwards. artifact (the default) is marked content that viewers draw, text extraction leaves out and Chilkat can remove later. annotation is a Watermark annotation, always on top, and the only approach allowed on a signed PDF while PreserveSignatures is true. layer is an optional-content layer the viewer can hide and that can be made print-only. content draws straight into the page with no marker: visible everywhere and the tamper-resistant choice, but by design it can never be listed or removed again.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 two_page_memo.pdf
set json = Server.CreateObject("Chilkat.JsonObject")
set jsonOut = Server.CreateObject("Chilkat.JsonObject")
set filter = Server.CreateObject("Chilkat.JsonObject")
' The same watermark stored four different ways, each in its own copy of the document.
set pdf = Server.CreateObject("Chilkat.Pdf")
success = pdf.LoadFile("qa_data/pdf/two_page_memo.pdf")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
Response.End
End If
success = json.UpdateString("type","text")
success = json.UpdateString("text","DRAFT")
success = json.UpdateString("id","draft")
success = json.UpdateString("approach","artifact")
success = pdf.Watermark("add",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
Response.End
End If
' detect answers whether anything matching the filter is in the document. Finding nothing is
' still success: "found" is simply false.
success = filter.UpdateString("id","draft")
success = pdf.Watermark("detect",filter,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "artifact: found = " & jsonOut.BoolOf("found")) & "</pre>"
' An annotation: always drawn on top, and the one approach a signed PDF accepts.
set pdf2 = Server.CreateObject("Chilkat.Pdf")
success = pdf2.LoadFile("qa_data/pdf/two_page_memo.pdf")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf2.LastErrorText) & "</pre>"
Response.End
End If
success = json.UpdateString("approach","annotation")
success = pdf2.Watermark("add",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf2.LastErrorText) & "</pre>"
Response.End
End If
success = pdf2.Watermark("detect",filter,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf2.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "annotation: found = " & jsonOut.BoolOf("found")) & "</pre>"
' A layer, which the viewer's layers panel can switch off.
set pdf3 = Server.CreateObject("Chilkat.Pdf")
success = pdf3.LoadFile("qa_data/pdf/two_page_memo.pdf")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf3.LastErrorText) & "</pre>"
Response.End
End If
success = json.UpdateString("approach","layer")
success = json.UpdateString("layer.name","Draft marking")
success = pdf3.Watermark("add",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf3.LastErrorText) & "</pre>"
Response.End
End If
success = pdf3.Watermark("detect",filter,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf3.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "layer: found = " & jsonOut.BoolOf("found")) & "</pre>"
' Drawn into the page content with no marker. There is nothing to find afterwards, which is the
' point of it: it cannot be stripped out by a tool that removes watermarks.
set pdf4 = Server.CreateObject("Chilkat.Pdf")
success = pdf4.LoadFile("qa_data/pdf/two_page_memo.pdf")
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf4.LastErrorText) & "</pre>"
Response.End
End If
success = json.UpdateString("approach","content")
success = pdf4.Watermark("add",json,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf4.LastErrorText) & "</pre>"
Response.End
End If
success = pdf4.Watermark("detect",filter,jsonOut)
If (success = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( pdf4.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( "content: found = " & jsonOut.BoolOf("found")) & "</pre>"
' Sample output:
' artifact: found = True
' annotation: found = True
' layer: found = True
' content: found = False
%>
</body>
</html>