Web Connection
How to convert a PDF file to Base64 in West Wind Web Connection
Hello Rick,
I’m working with Visual FoxPro 9 and West Wind Web Connection, and I need to convert a PDF file into a Base64-encoded string within my Web Connection application.
I’ve checked wwUtils.prg but couldn’t find any built-in functions like EncodeBase64() or DecodeBase64().
Could you please let me know if there’s an existing utility in Web Connection that performs Base64 encoding for binary files (such as PDFs), or if I should implement my own helper function using MSXML2.DOMDocument?
Ideally, I’d like to stay within the West Wind framework and use its utility functions if possible.
Thanks in advance for your help!
You can use FoxPro's native STRCONV() function:
*** Convert to base64
lcB64 = STRCONV(FILETOSTR("c:\temp\test.pdf"),13)
*** Convert from base64
STRTOFILE( STRCONV(lcB64,14), "c:\temp\test2.pdf")