Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Extract PDF from JSONDemonstrates how to extract a PDF file contained within JSON. The file is represented as a base64 string within the JSON. Note: This example can extract any type of file, not just a PDF file.
Use ChilkatAx-win32.pkg Procedure Test Handle hoJson Boolean iSuccess Variant vSb Handle hoSb Handle hoBd String sTemp1 Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End // Load the JSON. Get ComLoadFile Of hoJson "qa_data/json/JSR5U.json" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoJson To sTemp1 Showln sTemp1 Procedure_Return End // The JSON we loaded contains this: // { // ... // ... // "data": { // "content": "JVBERi0xLjQ..." // } // ... // ... // } Get Create (RefClass(cComChilkatStringBuilder)) To hoSb If (Not(IsComObjectCreated(hoSb))) Begin Send CreateComObject of hoSb End Get pvComObject of hoSb to vSb Get ComStringOfSb Of hoJson "data.content" vSb To iSuccess Get Create (RefClass(cComChilkatBinData)) To hoBd If (Not(IsComObjectCreated(hoBd))) Begin Send CreateComObject of hoBd End Get pvComObject of hoSb to vSb Get ComAppendEncodedSb Of hoBd vSb "base64" To iSuccess Get ComWriteFile Of hoBd "qa_output/a0015.pdf" To iSuccess End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.