Convert PDF to Base64
Convert PDF to Base64
Hey guys.
Does anyone have an example of how to convert a PDF file to Base64 String.
Many Thanks.
Does anyone have an example of how to convert a PDF file to Base64 String.
Many Thanks.
Pedro Alexandre
Re: Convert PDF to Base64
Load the File (Memoread, FileStr) as a binary string, apply a conversion function (xbBase64Encode from Xb2.Net, Xbase++ has a function aswell) to that string, that's it.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Convert PDF to Base64
Tom, I did that, too, but it's not that simple.
This sample does not work.
xBase 2.0.1176.
Can you check if it works with your version?
Something doesn't work well
This sample does not work.
xBase 2.0.1176.
Can you check if it works with your version?
Code: Select all
//=====================================================================
Function PDF2Base64()
Local cFile := Dc_popFile()
MsgBox(cFile,'The PDF' File)
cStream := FileStr(cFile)
MsgBox( cStream,'FileStr() do PDF' )
cB64 := Bin2Base64( cStream )
MsgBox( 'CB64 ' + cB64 ,'PDF to Base64')
Return NIL
Pedro Alexandre
Re: Convert PDF to Base64
Hi!
I do it thisway:
cFile = PDF file...
Base64Coded:=ToBase64(MEMOREAD(cFile))
then you can use this "Base64Coded" how you want (in XML, SOAP, etc...)
Goran
I do it thisway:
cFile = PDF file...
Base64Coded:=ToBase64(MEMOREAD(cFile))
then you can use this "Base64Coded" how you want (in XML, SOAP, etc...)
Goran
Goran Radosic
Re: Convert PDF to Base64
Hi,
Tobase64() ?? It is Alaska xbase ??
I think the problem is in the way of reading the Pdf.
Memoread () and FileStr () don't seem to be the right way ...
Tobase64() ?? It is Alaska xbase ??
I think the problem is in the way of reading the Pdf.
Memoread () and FileStr () don't seem to be the right way ...
Pedro Alexandre
Re: Convert PDF to Base64
It's ot4xb library, you can find it on https://www.dll-files.com/ot4xb.dll.html..
this is working 100%, we send thousands of PDF files thisway.
br
this is working 100%, we send thousands of PDF files thisway.
br
Goran Radosic
Re: Convert PDF to Base64
Or use the functions from Xb2.Net.
Code: Select all
cBase64 := xbBase64Encode(FileStr(cFileName))
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Convert PDF to Base64
Goran,
Can you post (in a Txt file) the result of ToBase64() the anexed pdf?
Can you post (in a Txt file) the result of ToBase64() the anexed pdf?
- Attachments
-
- FATURA_FT_1_768.rar
- (165.55 KiB) Downloaded 739 times
Pedro Alexandre
Re: Convert PDF to Base64
Hi, Pedro.
See Attachment. Result of xbBase64Encode(FileStr("FATURA_FT_1_768.pdf")).
See Attachment. Result of xbBase64Encode(FileStr("FATURA_FT_1_768.pdf")).
- Attachments
-
- base64.zip
- (171.86 KiB) Downloaded 743 times
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Convert PDF to Base64
Hi, Tom.
Many Thanks .
The result of your sample is correct. But I have not Xb2net.
I cannot get this result with the Alaska Function Bin2Base64().
Have you tried this feature in your Alaska version?
Just for confirm..
cB64 := Bin2Base64(FileStr("FATURA_FT_1_768.pdf"))
Thanks..
Many Thanks .
The result of your sample is correct. But I have not Xb2net.
I cannot get this result with the Alaska Function Bin2Base64().
Have you tried this feature in your Alaska version?
Just for confirm..
cB64 := Bin2Base64(FileStr("FATURA_FT_1_768.pdf"))
Thanks..
Pedro Alexandre