[#5729] - Jasper exported html when sent as email isn't rendering well on Gmail

Bug report
Project: Severity:
Component: Reproducibility:
Assigned to:

Jasper reports exported to html when sent as email renders perfectly fine on all major email providers except on gmail. The whole layout is distorted because pixel image embedded to align the layout are displayed abnormally large. Moreover the text is displayed in blue font.

ajaydeshwal's picture
Joined: May 2 2012 - 2:38am
Last seen: 8 years 7 months ago

1 Comment:


Gmail handles images and other elements in HTML-formatted emails in a different way. Few points to note are :

1) Gmail does not support cascading styles i.e. It ignores style definitions that are not "inline" which means anything specified between <style type="text/css"> </style> won't be applied. So we've to move our "a {text-decoration: none;}" to style attribute of each anchor tag.

2) To get the expected behavior specify image element, especially when rendering inside table, as:

<img alt="something" src="http://somedomain.com/image.png" width="35" height="35" border="0" style="display:block;" />


<img alt="something" src="http://somedomain.com/image.png" style="width:35px; height:35px;" />

i.e. set width and height in corresponding attributes instead of style and that too without px suffix. Set border to 0 and style should be display:block; as i mentioned earlier that only in-line styles will be detected.

3) The style="color: #000000;" or a { color: black; } ,which i think in our case is caused by style "text-decoration: none;" to display texts and headings in black text, is stripped off and displayed in blue font. So anchors will always be displayed in blue when you want them to be displayed in black. I solved it by setting the anchor element style to use a link color that's black, but not quite black.

<a style="text-decoration:none; color: #000001;">

After applying all the fixes to the jasper exported html, it rendered perfectly fine on Gmail.

I will make required changes in JRHtmlExporter and submit a patch soon.