PowerShell
PowerShell
Extract PDF from JSON
See more JSON Examples
Demonstrates 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.Chilkat PowerShell Downloads
Add-Type -Path "C:\chilkat\ChilkatDotNet47-x64\ChilkatDotNet47.dll"
$success = $false
$json = New-Object Chilkat.JsonObject
# Load the JSON.
$success = $json.LoadFile("qa_data/json/JSR5U.json")
if ($success -ne $true) {
$($json.LastErrorText)
exit
}
# The JSON we loaded contains this:
# {
# ...
# ...
# "data": {
# "content": "JVBERi0xLjQ..."
# }
# ...
# ...
# }
$sb = New-Object Chilkat.StringBuilder
$json.StringOfSb("data.content",$sb)
$bd = New-Object Chilkat.BinData
$bd.AppendEncodedSb($sb,"base64")
$success = $bd.WriteFile("qa_output/a0015.pdf")