Question
· Mar 3

base64 data to pdf

hi there , when i convert a pdf to base64 data, and then restore the data to pdf,i find that ,i must read the same  as length of base64 data every time convert ,or i can't get the right pdf. the code is:

s pdf= ##class(%FileBinaryStream).%New()
pdf.Filename = $g(path)
len=24*30*2
byteList = pdf.Read(len)
while(byteList'=""){
baseStr = ##class(%SYSTEM.Encryption).Base64Encode(byteList)

length of baseStr  is 1970,

if len=24*30 length of baseStr  is 984,

 

when i covert the base64 data to pdf, the code is: 

pdf= ##class(%FileBinaryStream).%New()
pdf.Filename = $g(path)
while ('sgc.AtEnd){
baseStr = sgc.Read(len1)
byteList = ##class(%SYSTEM.Encryption).Base64Decode(baseStr)
img.Write(byteList)

when len is 24*30*2, len1 is 1970,when len is 24*30,len1 is 984, and i can get the right pdf,if the base64 data comes from others, how can i know the num of len1?

Product version: Ensemble 2016.1
$ZV: Cache for Windows (x86-64) 2016.2.3 (Build 907_11_20446U) Thu Nov 12 2020 16:56:45 EST
Discussion (3)2
Log in or sign up to continue