- John Vanleeuwe
- PowerBuilder
- Wednesday, 23 January 2019 11:06 AM UTC
HI all,
I am consuming a rest webservice api which gives me a back an XML reply message , with one of the XML elements a base64 encoded string.
This base64 encoded string is a PDF file , which i need to decode and then write as a PDF file in a certain folder.
The webservice call works fine , i receive the base64 encoded string perfectly and i when i code to encode the decoded string , i end up having the same string as my initial retrieve. So i know this part works fine.
I am stuck at the simple function to write this blob to a PDF file , the PDF file is created with 219 KB , but gives an adobe error when opening.
I tried filewrite , filewriteex , with blobs and strings , encodingutf8! , encodingansi! and so on... Not sure what i am missing here ...
string ls_historyreport
//ls_historyreport contains the base64 encoded string we receive from the webservice)
blob blob_a
CoderObject lnv_CoderObject
lnv_CoderObject = Create CoderObject
blob_a = lnv_coderobject.Base64Decode(ls_historyreport)
fnr = FileOpen("d:\abc.pdf", StreamMode!, Write!,Shared!,Replace!,EncodingUTF8!)
FileWriteEx(fnr, string( blob_a, EncodingUTF8!))
FileClose(fnr)
fnr = FileOpen("d:\abcs.pdf", StreamMode!, Write!,Shared!,Replace!,EncodingANSI!)
FileWriteEx(fnr, string(blob_a,EncodingAnsi!))
FileClose(fnr)
fnr = FileOpen("d:\abc.pdf", StreamMode!, Write!,Shared!,Replace!,EncodingANSI!)
FileWriteEx(fnr, STRING(blob_a))
FileClose(fnr)
fnr = FileOpen("d:\abc1.pdf", StreamMode!, Write!,Shared!,Replace!,EncodingUTF8!)
FileWrite(fnr, string( blob_a, EncodingUTF8!))
FileClose(fnr)
fnr = FileOpen("d:\abcs2.pdf", StreamMode!, Write!,Shared!,Replace!,EncodingANSI!)
FileWrite(fnr, string(blob_a,EncodingAnsi!))
FileClose(fnr)
fnr = FileOpen("d:\abc3.pdf", StreamMode!, Write!,Shared!,Replace!,EncodingANSI!)
FileWrite(fnr, STRING(blob_a))
FileClose(fnr)
Not 1 of above filewrites works, ok the 3 filewrites in the end are just tests
What am i missing here please ?
I need more sleep ... I need more coffee....
TIA
John
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.