Hi Community,
I'm building an HTML-to-PDF generation flow and need to embed an employee photo (stored as an Appian Document) directly into an <img> tag as a Base64 data URL, like this:
<img>
<img src="data:image/png;base64,{BASE64_STRING}" />
I want to construct the value in an Appian expression as:
"data:image/png;base64," & base64Data
My question: Is there a built-in Appian expression function to convert a Document to a Base64 string?
Using the Appian document URL directly in <img src> does not work.
<img src>
Thank you
Discussion posts and replies are publicly visible
Meme02 said:Is there a built-in Appian expression function to convert a Document to a Base64 string?
There is no OOTB way to convert an Appian Document to Base64 not via expression functions, Web API, or Integration calls. The best and simplest approach is to use the documentToBase64String function from the More Document Tools plugin
Shubham Aware said:use the documentToBase64String function from the More Document Tools plugin
Thanks, I had somehow missed that there is (again) a plug-in that allows us to do this. I know there are system overhead implications but there are some corner use cases that will be much easier with this sort of capability present.
Shubham Aware Mike Schmitt
Thank you for your support. I tried this plugin and it worked successfully.
Meme02 said:I tried this plugin and it worked successfully
Thanks for confirming / verifying. I haven't stress-tested this plugin yet, but please note that it claims to support binary files only up to ~820 KB, which would be a pretty modestly-sized picture in general (though for a JPG this can vary greatly depending on resolution and compression factor).
Edit: despite what the plug-in disclaimers about size, I just successfully used it on a ~1.3MB test mp3 file as well as a ~3MB text file, and successfully decoded the resulting base64 values in an online converter - so there is probably some flexibility with respect to the total size it accepts (though this could have engine performance implications, so I suggest treading lightly).
Thank you for sharing the information—it was very helpful. In my case, the use case involves uploading user profile photos, so I believe the file sizes will not be very large.
Since there may be various use cases going forward, I'll keep this in mind.