Announcement

Collapse
No announcement yet.

PDF Document Writer and base 64 encoded images

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PDF Document Writer and base 64 encoded images

    Hello,

    I've a channel that uses raw HTML code extracted from an Alfresco CMIS repository.
    It generates a PDF document using Document Writer.

    The HTML content embeds base 64 encoded images like the following :

    HTML Code:
    <img src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEBGAEYAAD/4QgARXhpZgAASUkqAAgAAAAQAP4ABAABAAAAAAAAAAABAwABAAAAYwEAAAEBAwABAAAAywEAAAIBAwADAAAAzgAAAAMBAwABAAAAAQAAAAYBAwABAAAA/wBHQ6knvZuxkrJWdH4+d1g7BwWxuWs9JXKgqKOquUboZmljhunkfQspuOFgiq8Fu62ucotNvbbpyNVtYqo67SdoqoTmOWqje3zEFWSwjcbkjkqqq6rRFVp6ms8t7nNLTv32O3jvjnwzu8uK6+/o/PDVd0HX/Lu/wrDScUiWnYX9OrKo6TepLr4fQ3V0/PPac/I3.../eHFbDTWk7BpiF0dgtNHQNd8IwRBpd5zzKA62znTEOjtFWqxwEO70hDZHj48hOXH1kqoe7M/IvTn+t2f7N69BLWX/T9o1DTxQX220lwhif0sbKmISBr8Y3gDyOCUB3Lf/MKb9U36gvusNaGNDWgBoGAB1BZQH//2Q==" style="height: 153px; width: 118px;"/>
    Everything works fine except images that do not appear in the PDF document.

    Is there a solution to make them displayed ?

    beforehand, thks

    PS : I'm using mirth 3.4.2


    Edit : I already asked for this 2 years ago in this thread :https://www.mirthproject.org/communi...ad.php?p=47180
    Last edited by lionelroux; 02-17-2017, 03:48 AM.

  • #2
    It doesn't look like Mirth supports the Data URI method like this, but you could always write a temp file then reference it:

    Code:
    var data = "[base64-encoded data]";
    var decoded = FileUtil.decode(data);
    var fileName = "temp.jpg";
    FileUtil.write(fileName, false, decoded);
    Code:
    <html>
    <img src="temp.jpg"/>
    </html>
    Note #1: The base64 data that you posted doesn't seem to be valid.
    Note #2: When you don't put a path to the filename that is written to/read from, it will write in your Mirth path, so you might want to use /tmp/file.jpg or similar.

    -= Jack Haines : Founder/CEO of Healthcare Integrations, LLC
    -= [email protected]
    -= Mirth Connect (Advanced)-certified
    -= Gold member of HL7.org
    -= Available for Mirth Connect channel development and consultation! Schedule a FREE call with me at https://calendly.com/jackhaines

    Comment

    Working...
    X