Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PowerBuilder Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
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
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(PowerBuilder) Extract data:image/png;base64 from HTML

Demonstrates how to extract base64 image data from HTMl and save to files.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

integer li_rc
oleobject loo_Sb
oleobject loo_Bd
oleobject loo_SbFilename
integer li_Index
integer li_Success
integer li_MayHaveMore
string ls_SBase64
integer li_Count

loo_Sb = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_Sb.ConnectToNewObject("Chilkat.StringBuilder")
if li_rc < 0 then
    destroy loo_Sb
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Bd = create oleobject
// Use "Chilkat_9_5_0.BinData" for versions of Chilkat < 10.0.0
li_rc = loo_Bd.ConnectToNewObject("Chilkat.BinData")

loo_SbFilename = create oleobject
// Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0
li_rc = loo_SbFilename.ConnectToNewObject("Chilkat.StringBuilder")

li_Index = 1

li_Success = loo_Sb.LoadFile("qa_data/html/oresp body.txt","utf-8")
// Assume success.
Write-Debug "length = " + string(loo_Sb.Length)

li_MayHaveMore = 1
do while li_MayHaveMore = 1

    // Get the base64 between the 1st occurrence "data:image/png;base64," and "'"
    ls_SBase64 = loo_Sb.GetBetween("data:image/png;base64,","'")

    // If nothing is found, then we'll exit the loop because there are no more.
    li_MayHaveMore = loo_Sb.LastMethodSuccess

    if loo_Sb.LastMethodSuccess = 1 then
        // Found something.
        // Load into bd and save.
        li_Success = loo_Bd.LoadEncoded(ls_SBase64,"base64")

        loo_SbFilename.SetString("qa_output/png_")
        loo_SbFilename.AppendInt(li_Index)
        loo_SbFilename.Append(".png")

        loo_Bd.WriteFile(loo_SbFilename.GetAsString())

        // Replace "data:image/png;base64" with "data:image-png;base64" so the next iteration finds the next occurrence.
        loo_Sb.ReplaceFirst("data:image/png;base64","data:image-png;base64")
    end if

    li_Index = li_Index + 1
loop

// Restore our replacements..
li_Count = loo_Sb.Replace("data:image-png;base64","data:image/png;base64")

Write-Debug "All done."


destroy loo_Sb
destroy loo_Bd
destroy loo_SbFilename

 

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