Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Classic ASP Examples

Web API Categories

ASN.1
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
Geolocation
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text

HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Classic ASP) Google Cloud Vision Text Detection

Demonstrates calling the Google Cloud Vision for text detection (performs Optical Character Recognition). "Detects and extracts text within an image with support for a broad range of languages. It also features automatic language identification." See https://cloud.google.com/vision/docs/detecting-text

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

' Build the following request:

' {
'   "requests": [
'     {
'       "image": {
'         "content": "/9j/7QBEUGhvdG9zaG9...base64-encoded-image-content...fXNWzvDEeYxxxzj/Coa6Bax//Z"
'       },
'       "features": [
'         {
'           "type": "TEXT_DETECTION"
'         }
'       ]
'     }
'   ]
' }

' Use the this online tool to generate the code from sample JSON: 
' Generate Code to Create JSON

' Load an image file.
set imageData = Server.CreateObject("Chilkat_9_5_0.BinData")
' This image file contains some text...
success = imageData.LoadFile("qa_data/jpg/text.jpg")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Failed to load image file.") & "</pre>"
    Response.End
End If

' Create the above JSON.
set json = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = json.UpdateBd("requests[0].image.content","base64",imageData)
success = json.UpdateString("requests[0].features[0].type","TEXT_DETECTION")

' Send the following POST with the HTTP request body containing the above JSON.
' POST https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY

set http = Server.CreateObject("Chilkat_9_5_0.Http")
set sb = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
url = "https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY"
' resp is a Chilkat_9_5_0.HttpResponse
Set resp = http.PostJson3(url,"application/json",json)
If (http.LastMethodSuccess <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( http.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "status = " & resp.StatusCode) & "</pre>"

' A 200 response status indicate success.
If (resp.StatusCode <> 200) Then
    Response.Write "<pre>" & Server.HTMLEncode( resp.BodyStr) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "Failed.") & "</pre>"

    Response.End
End If

set sbResponseBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
success = resp.GetBodySb(sbResponseBody)
success = sbResponseBody.WriteFile("qa_output/textDetectResponse.json","utf-8",0)
success = json.LoadSb(sbResponseBody)

' The response is a JSON document like this:

' Use the this online tool to generate parsing code from sample JSON: 
' Generate Parsing Code from JSON

' {
'   "responses": [
'     {
'       "textAnnotations": [
'         {
'           "locale": "en",
'           "description": "Chilkat is a cross-language, cross-platform\nAPl providing 90+ classes for many Internet\nprotocols, formats, and algorithms.\n",
'           "boundingPoly": {
'             "vertices": [
'               {
'                 "x": 17,
'                 "y": 14
'               },
' 	...
'             ]
'           }
'         ],
'         "text": "Chilkat is a cross-language, cross-platform\nAPl providing 90+ classes for many Internet\nprotocols, formats, and algorithms.\n"
'       }
'     }
'   ]
' }

' The parsing code generated from the online tool:

i = 0
count_i = json.SizeOfArray("responses")
Do While i < count_i
    json.I = i
    fullTextAnnotationText = json.StringOf("responses[i].fullTextAnnotation.text")
    j = 0
    count_j = json.SizeOfArray("responses[i].textAnnotations")
    Do While j < count_j
        json.J = j
        locale = json.StringOf("responses[i].textAnnotations[j].locale")
        description = json.StringOf("responses[i].textAnnotations[j].description")
        k = 0
        count_k = json.SizeOfArray("responses[i].textAnnotations[j].boundingPoly.vertices")
        Do While k < count_k
            json.K = k
            x = json.IntOf("responses[i].textAnnotations[j].boundingPoly.vertices[k].x")
            y = json.IntOf("responses[i].textAnnotations[j].boundingPoly.vertices[k].y")
            k = k + 1
        Loop
        j = j + 1
    Loop
    j = 0
    count_j = json.SizeOfArray("responses[i].fullTextAnnotation.pages")
    Do While j < count_j
        json.J = j
        width = json.IntOf("responses[i].fullTextAnnotation.pages[j].width")
        height = json.IntOf("responses[i].fullTextAnnotation.pages[j].height")
        k = 0
        count_k = json.SizeOfArray("responses[i].fullTextAnnotation.pages[j].property.detectedLanguages")
        Do While k < count_k
            json.K = k
            languageCode = json.StringOf("responses[i].fullTextAnnotation.pages[j].property.detectedLanguages[k].languageCode")
            k = k + 1
        Loop
        k = 0
        count_k = json.SizeOfArray("responses[i].fullTextAnnotation.pages[j].blocks")
        Do While k < count_k
            json.K = k
            blockType = json.StringOf("responses[i].fullTextAnnotation.pages[j].blocks[k].blockType")

            ' json1 is a Chilkat_9_5_0.JsonObject
            Set json1 = json.ObjectOf("responses[i].fullTextAnnotation.pages[j].blocks[k]")
            i1 = 0
            count_i1 = json1.SizeOfArray("property.detectedLanguages")
            Do While i1 < count_i1
                json1.I = i1
                languageCode = json1.StringOf("property.detectedLanguages[i].languageCode")
                i1 = i1 + 1
            Loop

            ' json1 is a Chilkat_9_5_0.JsonObject
            Set json1 = json.ObjectOf("responses[i].fullTextAnnotation.pages[j].blocks[k]")
            i1 = 0
            count_i1 = json1.SizeOfArray("boundingBox.vertices")
            Do While i1 < count_i1
                json1.I = i1
                x = json1.IntOf("boundingBox.vertices[i].x")
                y = json1.IntOf("boundingBox.vertices[i].y")
                i1 = i1 + 1
            Loop

            ' json1 is a Chilkat_9_5_0.JsonObject
            Set json1 = json.ObjectOf("responses[i].fullTextAnnotation.pages[j].blocks[k]")
            i1 = 0
            count_i1 = json1.SizeOfArray("paragraphs")
            Do While i1 < count_i1
                json1.I = i1
                j1 = 0
                count_j1 = json1.SizeOfArray("paragraphs[i].property.detectedLanguages")
                Do While j1 < count_j1
                    json1.J = j1
                    languageCode = json1.StringOf("paragraphs[i].property.detectedLanguages[j].languageCode")
                    j1 = j1 + 1
                Loop
                j1 = 0
                count_j1 = json1.SizeOfArray("paragraphs[i].boundingBox.vertices")
                Do While j1 < count_j1
                    json1.J = j1
                    x = json1.IntOf("paragraphs[i].boundingBox.vertices[j].x")
                    y = json1.IntOf("paragraphs[i].boundingBox.vertices[j].y")
                    j1 = j1 + 1
                Loop
                j1 = 0
                count_j1 = json1.SizeOfArray("paragraphs[i].words")
                Do While j1 < count_j1
                    json1.J = j1
                    k1 = 0
                    count_k1 = json1.SizeOfArray("paragraphs[i].words[j].property.detectedLanguages")
                    Do While k1 < count_k1
                        json1.K = k1
                        languageCode = json1.StringOf("paragraphs[i].words[j].property.detectedLanguages[k].languageCode")
                        k1 = k1 + 1
                    Loop
                    k1 = 0
                    count_k1 = json1.SizeOfArray("paragraphs[i].words[j].boundingBox.vertices")
                    Do While k1 < count_k1
                        json1.K = k1
                        x = json1.IntOf("paragraphs[i].words[j].boundingBox.vertices[k].x")
                        y = json1.IntOf("paragraphs[i].words[j].boundingBox.vertices[k].y")
                        k1 = k1 + 1
                    Loop
                    k1 = 0
                    count_k1 = json1.SizeOfArray("paragraphs[i].words[j].symbols")
                    Do While k1 < count_k1
                        json1.K = k1
                        text = json1.StringOf("paragraphs[i].words[j].symbols[k].text")
                        propertyDetectedBreakType = json1.StringOf("paragraphs[i].words[j].symbols[k].property.detectedBreak.type")

                        ' json2 is a Chilkat_9_5_0.JsonObject
                        Set json2 = json1.ObjectOf("paragraphs[i].words[j].symbols[k]")
                        i2 = 0
                        count_i2 = json2.SizeOfArray("property.detectedLanguages")
                        Do While i2 < count_i2
                            json2.I = i2
                            languageCode = json2.StringOf("property.detectedLanguages[i].languageCode")
                            i2 = i2 + 1
                        Loop

                        ' json2 is a Chilkat_9_5_0.JsonObject
                        Set json2 = json1.ObjectOf("paragraphs[i].words[j].symbols[k]")
                        i2 = 0
                        count_i2 = json2.SizeOfArray("boundingBox.vertices")
                        Do While i2 < count_i2
                            json2.I = i2
                            x = json2.IntOf("boundingBox.vertices[i].x")
                            y = json2.IntOf("boundingBox.vertices[i].y")
                            i2 = i2 + 1
                        Loop

                        k1 = k1 + 1
                    Loop
                    j1 = j1 + 1
                Loop
                i1 = i1 + 1
            Loop

            k = k + 1
        Loop
        j = j + 1
    Loop
    i = i + 1
Loop

Response.Write "<pre>" & Server.HTMLEncode( "Success.") & "</pre>"

%>
</body>
</html>

 

© 2000-2019 Chilkat Software, Inc. All Rights Reserved.