PowerBuilder
PowerBuilder
PDF File Encoding to Base64
See more Base64 Examples
Demonstrates how to encode a PDF file to base64, and then decode.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_PdfData
string ls_B64
oleobject loo_PdfData2
li_Success = 0
loo_PdfData = create oleobject
li_rc = loo_PdfData.ConnectToNewObject("Chilkat.BinData")
if li_rc < 0 then
destroy loo_PdfData
MessageBox("Error","Connecting to COM object failed")
return
end if
li_Success = loo_PdfData.LoadFile("qa_data/helloWorld.pdf")
if li_Success <> 1 then
Write-Debug "failed to load PDF file."
destroy loo_PdfData
return
end if
// Encode the PDF to base64
// Note: to produce base64 on multiple lines (as it would appear in the MIME of an email),
// pass the string "base64_mime" instead of "base64".
ls_B64 = loo_PdfData.GetEncoded("base64")
Write-Debug ls_B64
// Decode from base64 PDF.
loo_PdfData2 = create oleobject
li_rc = loo_PdfData2.ConnectToNewObject("Chilkat.BinData")
loo_PdfData2.AppendEncoded(ls_B64,"base64")
li_Success = loo_PdfData2.WriteFile("qa_output/helloWorld2.pdf")
if li_Success <> 1 then
Write-Debug "failed to write PDF file."
destroy loo_PdfData
destroy loo_PdfData2
return
end if
destroy loo_PdfData
destroy loo_PdfData2