(Lianja) PDF File Encoding to Base64
Demonstrates how to encode a PDF file to base64, and then decode.
loPdfData = createobject("CkBinData")
llSuccess = loPdfData.LoadFile("qa_data/helloWorld.pdf")
if (llSuccess <> .T.) then
? "failed to load PDF file."
release loPdfData
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".
lcB64 = loPdfData.GetEncoded("base64")
? lcB64
// Decode from base64 PDF.
loPdfData2 = createobject("CkBinData")
loPdfData2.AppendEncoded(lcB64,"base64")
llSuccess = loPdfData2.WriteFile("qa_output/helloWorld2.pdf")
if (llSuccess <> .T.) then
? "failed to write PDF file."
release loPdfData
release loPdfData2
return
endif
release loPdfData
release loPdfData2
|