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


    • #3
      lionelroux You almost had it in your original thread (updated link https://forums.mirthproject.io/forum...images-support)

      You were right about adding the protocol handler. The plugin libraries are loaded later during mirth startup, but the protocol handler that comes with flying saucer needs to be accessible by the same classloader that loads the java.net.URL class.

      If you add the following two lines to your mcservice.vmoptions or mcserver.vmoptions file, depending on which one you use, it will enable data urls in the document writer.

      Code:
      -Djava.protocol.handler.pkgs=org.xhtmlrenderer.protocols
      -classpath/a extensions/doc/lib/flying-saucer-core-9.0.1.jar
      The first line adds the "data" protocol handler to the search path used by the URL class.
      The second line appends the jar to the end of the classpath at startup. This is an option used by the install4j launcher and not directly passed to the jvm.

      Comment

      Working...
      X