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

DataFlex 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
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

 

 

 

(DataFlex) Extract PDF from General Ledger Transactions XML

See more Office365 Examples

Demonstrates how to extract the base64 data representing a PDF file from a General Ledger Transactions XML.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-9.5.0-win32.pkg

Procedure Test
    Handle hoXml
    Boolean iSuccess
    String sPdfFilename
    Variant vBinaryDataElem
    Handle hoBinaryDataElem
    String sTemp1
    Boolean bTemp1

    // The General Ledger Transactions XML contains the following:

    // <?xml version="1.0" encoding="utf-8" ?>
    // <eExact xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="eExact-XML.xsd">
    //     <GLTransactions>
    //         <GLTransaction entry="100000095">
    //             <TransactionType number="20" />
    //             <Journal type="20" code="VK">
    //                 <Description termid="90003">Verkopen</Description>
    //                 <GLAccount type="20" code="400000" />
    //                 <Currency code="EUR" />
    //             </Journal>
    //             <Date>2022-04-05</Date>
    //             <Document>
    //                 <Subject>100000095</Subject>
    //                 <DocumentType number="10" />
    //                 <Account code="0001" status="C" />
    //                 <Amount>
    //                     <Currency code="EUR" />
    //                     <Value>1382.91</Value>
    //                 </Amount>
    //                 <References>
    //                     <InvoiceNumber>100000095</InvoiceNumber>
    //                 </References>
    //                 <Attachments>
    //                     <Attachment>
    //                         <Name>F_100000095.PDF</Name>
    //                         <BinaryData>BASE64_ENCODED_PDF_BYTES_HERE</BinaryData>
    //                     </Attachment>
    //                 </Attachments>
    //             </Document>
    //             <GLTransactionLine type="20" status="20" line="0" linetype="0">
    //                 <Date>2022-04-05</Date>
    //                 <VATType>S</VATType>
    //                 <FinYear number="2022" />
    //                 <FinPeriod number="4" />
    //                 <GLAccount type="20" code="400000" />
    //                 <Description>100000095</Description>
    //                 <DueDate>2022-05-05</DueDate>
    //                 <Account code="0001" status="C">
    //                     <Name>90 Degrees &amp; co</Name>
    //                 </Account>
    //                 <Amount>
    //                     <Currency code="EUR" />
    //                     <Value>1382.91</Value>
    //                 </Amount>
    //                 <ForeignAmount>
    //                     <Currency code="EUR" />
    //                     <Value>1382.91</Value>
    //                     <Rate>1</Rate>
    //                 </ForeignAmount>
    //                 <References>
    //                     <InvoiceNumber>100000095</InvoiceNumber>
    //                 </References>
    //             </GLTransactionLine>
    //             <PaymentTerms>
    //                 <PaymentTerm entry="100000095" type="20" line="0" paymentMethod="B">
    //                     <Description>20</Description>
    //                     <GLAccount type="20" code="400000" />
    //                     <Amount>
    //                         <Currency code="EUR" />
    //                         <Debit>1382.91</Debit>
    //                         <Credit>0</Credit>
    //                     </Amount>
    //                     <ForeignAmount>
    //                         <Currency code="EUR" />
    //                         <Debit>1382.91</Debit>
    //                         <Credit>0</Credit>
    //                     </ForeignAmount>
    //                     <Reference />
    //                     <YourRef />
    //                     <InvoiceNumber>100000095</InvoiceNumber>
    //                     <InvoiceDate>2022-04-05</InvoiceDate>
    //                     <DueDate>2022-05-05</DueDate>
    //                     <PaymentDate>2022-05-05</PaymentDate>
    //                 </PaymentTerm>
    //             </PaymentTerms>
    //         </GLTransaction>
    //     </GLTransactions>
    // </eExact>

    Get Create (RefClass(cComChilkatXml)) To hoXml
    If (Not(IsComObjectCreated(hoXml))) Begin
        Send CreateComObject of hoXml
    End

    Get ComLoadXmlFile Of hoXml "c:/temp/example.xml" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoXml To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComGetChildContent Of hoXml "GLTransactions|GLTransaction|Document|Attachments|Attachment|Name" To sPdfFilename
    Get ComLastMethodSuccess Of hoXml To bTemp1
    If (bTemp1 = False) Begin
        Showln "No XML element at the given path."
        Procedure_Return
    End

    Showln "PDF Filename = " sPdfFilename

    Get ComGetChildWithTag Of hoXml "GLTransactions|GLTransaction|Document|Attachments|Attachment|BinaryData" To vBinaryDataElem
    If (IsComObject(vBinaryDataElem)) Begin
        Get Create (RefClass(cComChilkatXml)) To hoBinaryDataElem
        Set pvComObject Of hoBinaryDataElem To vBinaryDataElem
    End
    Get ComLastMethodSuccess Of hoXml To bTemp1
    If (bTemp1 = False) Begin
        Showln "No XML element at the given path."
        Procedure_Return
    End

    // Decode the base64 data and save to a file.
    Get ComSaveBinaryContent Of hoBinaryDataElem sPdfFilename False False "" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoBinaryDataElem To sTemp1
        Showln sTemp1
    End
    Else Begin
        Showln "Success."
    End

    Send Destroy of hoBinaryDataElem


End_Procedure

 

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