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
(PowerBuilder) 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.
integer li_rc oleobject loo_Json integer li_Success oleobject loo_Sb oleobject loo_Bd loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") if li_rc < 0 then destroy loo_Json MessageBox("Error","Connecting to COM object failed") return end if // Load the JSON. li_Success = loo_Json.LoadFile("qa_data/json/JSR5U.json") if li_Success <> 1 then Write-Debug loo_Json.LastErrorText destroy loo_Json return end if // The JSON we loaded contains this: // { // ... // ... // "data": { // "content": "JVBERi0xLjQ..." // } // ... // ... // } loo_Sb = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_Sb.ConnectToNewObject("Chilkat.StringBuilder") loo_Json.StringOfSb("data.content",loo_Sb) 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_Bd.AppendEncodedSb(loo_Sb,"base64") li_Success = loo_Bd.WriteFile("qa_output/a0015.pdf") destroy loo_Json destroy loo_Sb destroy loo_Bd |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.