web stats
[MC3.2.X] Flying saucer and base64 encoded images support - Mirth Community

Go Back   Mirth Community > Mirth Connect > Support

Reply
 
Thread Tools Display Modes
  #1  
Old 04-02-2015, 01:54 AM
lionelroux lionelroux is offline
OBX.2 Kenobi
 
Join Date: Apr 2013
Posts: 82
lionelroux is on a distinguished road
Smile [MC3.2.X] Flying saucer and base64 encoded images support

Hello,

I try to generate reports based on an institutionnal template which contains images (logo and barcodes).

In the template, images are embedded using data: base64 encoding.

Everything works fine except images. I've read on flying saucer forums that data: is supported (as part of CSS2.X), but we have to register a special protocol handler.

From http://stackoverflow.com/questions/1...ucer-from-html :

Quote:
Flying-Saucer supports the data: protocol natively. All you have to do is register a protocol handler:

-Djava.protocol.handler.pkgs=org.xhtmlrenderer.prot ocols
Is there a way to activate such a protool in mirth or could we envisage to add this setting somewhere in Mirth Connect ?
Maybe I could just start MC using this -D options in the command line ?

Thx.
Lionel
Reply With Quote
  #2  
Old 04-02-2015, 07:25 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

You can try adding that to mcserver.vmoptions or mcservice.vmoptions.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
  #3  
Old 04-03-2015, 06:57 AM
lionelroux lionelroux is offline
OBX.2 Kenobi
 
Join Date: Apr 2013
Posts: 82
lionelroux is on a distinguished road
Default

I did it, it's not working.
Reply With Quote
  #4  
Old 04-03-2015, 07:56 AM
narupley's Avatar
narupley narupley is online now
Mirth Employee
 
Join Date: Oct 2010
Posts: 7,126
narupley is on a distinguished road
Default

Quote:
Originally Posted by lionelroux View Post
I did it, it's not working.
That -D switch that you read online probably doesn't do what you think it does then, not sure.

Instead, you may have to use a URL to embed the image. There are several ways you can do that. First, if you place the logo in public_html/images, then they will be accessible via the URL "http://localhost:8080/images/logo.png". Or, you can use an HTTP Listener channel with static resources to host images, or directories of images.

Or, you can point the URL to a file accessible by the server. If the images you need to embed are dynamic and can change from message to message, you can use a transformer to write the image to a temp file:

Code:
var file = java.io.File.createTempFile('image', '.png');
var imageBytes = FileUtil.decode(imageBase64);
org.apache.commons.io.FileUtils.writeByteArrayToFile(file, imageBytes);
$c('imageFile', file);
Then use the file URL in the Document Writer:

Code:
<img src="${imageFile.toURI().toURL()}"/>
Then in the postprocessor, delete the file:

Code:
org.apache.commons.io.FileUtils.deleteQuietly($('imageFile'));
If the images you're embedding are static and won't change, you could alternatively only do that once in the deploy script, so that you don't have to write the file out for every message.
__________________
Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

Nicholas Rupley
Work: 949-237-6069
Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


- How do I foo?
- You just bar.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -8. The time now is 02:49 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Mirth Corporation