Xbase++
Xbase++
PDF File Encoding to Base64
See more Base64 Examples
Demonstrates how to encode a PDF file to base64, and then decode.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oPdfData
LOCAL cB64
LOCAL oPdfData2
nSuccess := 0
oPdfData := CreateObject("Chilkat.BinData")
nSuccess := oPdfData:LoadFile("qa_data/helloWorld.pdf")
IF (nSuccess != 1)
? "failed to load PDF file."
oPdfData:destroy()
RETURN
ENDIF
// 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".
cB64 := oPdfData:GetEncoded("base64")
? cB64
// Decode from base64 PDF.
oPdfData2 := CreateObject("Chilkat.BinData")
oPdfData2:AppendEncoded(cB64, "base64")
nSuccess := oPdfData2:WriteFile("qa_output/helloWorld2.pdf")
IF (nSuccess != 1)
? "failed to write PDF file."
oPdfData:destroy()
oPdfData2:destroy()
RETURN
ENDIF
oPdfData:destroy()
oPdfData2:destroy()