Chilkat Examples

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

PowerBuilder Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
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
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
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(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
li_rc = loo_Sb.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")
if li_rc < 0 then
    destroy loo_Sb
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Bd = create oleobject
li_rc = loo_Bd.ConnectToNewObject("Chilkat_9_5_0.BinData")

loo_SbFilename = create oleobject
li_rc = loo_SbFilename.ConnectToNewObject("Chilkat_9_5_0.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-2021 Chilkat Software, Inc. All Rights Reserved.