Web Connection
How to convert a PDF file to Base64 in West Wind Web Connection
Gravatar is a globally recognized avatar based on your email address. How to convert a PDF file to Base64 in West Wind Web Connection
  Marco Antonio Sepulveda Valbuena
  All
  Nov 12, 2025 @ 12:57pm

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!

Gravatar is a globally recognized avatar based on your email address. re: How to convert a PDF file to Base64 in West Wind Web Connection
  Rick Strahl
  Marco Antonio Sepulveda Valbuena
  Nov 12, 2025 @ 07:37pm

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")
© 1996-2025