How do I convert a Base64 string to a downloadable image and storable object?

0
Related to my previous question, I'm looking for an answer to convert a base64 string to an image object that is both downloadable by the user (mainly for testing purposes, honestly) and usable by a PDF template, thus (non-persistent) storable.  The Base64 string is generated by the ChartJS Widget (see below). I've tried multiple combinations of both the System.Image and System.FileDocument entity, as well as the java actions StringToFile and Base64DecodeToFile. If I use the image inside a PDF Template, the result is blank. When I open the image locally, Windows says "Cannot read file format", no matter if I open it with or without an extension (either JPEG (as seen below) or any other format). Nonetheless, when I open it in Photoshop the image, albeit not correctly, does show a graph. So an image is produced.  But at this point I'm not able to produce an image that is either 'readable' by the user or useable in a PDF template. The latter is the actual requirement.  So in short: How do I convert a base64 string to an image that is useable in a PDF (and downloadable separately). Reduced for readability. data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgICAgMCAgIDAwMDBAYEBAQEBAgGBgUGCQgKCgkICQkKDA8MCgsOCwkJDRENDg8QEBEQCgwSExIQEw8QEBD/2wBDAQMDAwQDBAgEBAgQCwkLEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBD/wAARCANsBpYDASIAAhEBAxEB/8QAHgABAQEAAwADAQEAAAAAAAAAAAMCBQYHAQQJCAr/xABhEAABAwECBwoJCgQEBAIHBQkAAQIDBAURBhITITNysQ..............................................AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH/2Q==  
asked
1 answers
3

As the answer was given in the comments I have copied this here so that the question is marked as answered.

 

If this is the literal string you are feeding to the Base64DecodeToFile action, you may want to remove the first part up until the `/9j/...`and try again.

Reinout van Schouwen

answered