Sample code for 30+ languages & platforms
Classic ASP Requires Chilkat v11.7.0+

Clipped, Off-Page and White-on-White Text in PDF Extraction

See more PDF Text Extraction Examples

Demonstrates the "clippedText", "offPageText" and "obscuredText" filters. Text that a reader never sees - hidden by a clipping path, outside the crop box, or drawn in the same color as the box beneath it - is excluded by default, and the quality report notes what was skipped. Each kind can be included.

Chilkat Classic ASP Downloads

Classic ASP
<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 hidden_text.pdf

set pdf = Server.CreateObject("Chilkat.Pdf")
success = pdf.LoadFile("qa_data/pdf/hidden_text.pdf")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
    Response.End
End If

set json = Server.CreateObject("Chilkat.JsonObject")
set jsonOut = Server.CreateObject("Chilkat.JsonObject")

'  The page has a visible paragraph plus three hidden lines: one drawn outside its clipping
'  rectangle, one below the crop box, and one in white on a white box.
success = pdf.ExtractText("text",json,jsonOut)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "---- default ----") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( jsonOut.StringOf("text")) & "</pre>"

'  The quality report says what was left out.
i = 0
count_i = jsonOut.SizeOfArray("quality.pages[0].issues")
Do While i < count_i
    jsonOut.I = i
    Response.Write "<pre>" & Server.HTMLEncode( "issue: " & jsonOut.StringOf("quality.pages[0].issues[i].code")) & "</pre>"
    i = i + 1
Loop

'  Include everything.
success = json.UpdateString("clippedText","include")
success = json.UpdateString("offPageText","include")
success = json.UpdateString("obscuredText","include")
success = pdf.ExtractText("text",json,jsonOut)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( pdf.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "---- clippedText, offPageText, obscuredText: include ----") & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( jsonOut.StringOf("text")) & "</pre>"

'  Sample output:

'  ---- default ----
'  Visible Text
'  
'  This paragraph is visible. The page also carries three kinds of text a reader never sees.
'  
'  End of the visible text.
'  issue: obscuredTextSkipped
'  issue: clippedTextSkipped
'  ---- clippedText, offPageText, obscuredText: include ----
'  Visible Text
'  
'  This paragraph is visible. The page also carries three kinds of text a reader never sees.
'  
'  CLIPPED: this line is drawn outside its clipping rectangle.
'  
'  OBSCURED: this line is white on a white box.
'  
'  End of the visible text.
'  
'  OFFPAGE: this line sits below the crop box.

%>
</body>
</html>