Rendering HTML to PDF in JASPER

Hi all,

Currently there is a requirement to embed custom HTML code into a JASPER report and then to export it as a PDF with the HTML rendered.

The HTML is well formed and does not use all the tags.

To fufil this requirement, the JRXML i am using has this particular piece of code.

The HTML i am using is also attached.

The tags that don't get rendered are the following

1. Table related
2. italic
3. bold
5. Justify, align

		<band height="239" splitType="Stretch">
			<textField isStretchWithOverflow="true" evaluationTime="Auto" pattern="" isBlankWhenNull="true">
				<reportElement key="element-1" mode="Opaque" x="0" y="0" width="487" height="239" isPrintWhenDetailOverflows="true" forecolor="#000000" backcolor="#FFFFFF"/>
								<textElement textAlignment="Left" verticalAlignment="Top" rotation="None" lineSpacing="Single" markup="html">
					<font fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>
				<textFieldExpression class="java.lang.String"><![CDATA["<html>" +
"<body>" +
(($F{htmlContent} != null) ? String.valueOf($F{htmlContent}) : "") +
"</body>" +
stupified's picture
Joined: Aug 24 2010 - 8:03pm
Last seen: 12 years 9 months ago

4 Answers:


stupified's picture
Joined: Aug 24 2010 - 8:03pm
Last seen: 12 years 9 months ago
BUMP for awareness.
If anyone can help?
stupified's picture
Joined: Aug 24 2010 - 8:03pm
Last seen: 12 years 9 months ago

Got the same problem.

Unfortunately, the issue at was left unanswered as well. So no luck there.

I'm currently leaning towards implementing an XSLT stylesheet which transforms my HTML into Jasper's own styled text markup tags. Does anyone have experience in this?

IMHO, there should be a simpler way to render justified/indented HTML text fields in a PDF. Sigh.

birnbuazn's picture
Joined: Jun 23 2010 - 12:07am
Last seen: 1 year 9 months ago



In a future version, we'll probably try to do something else about indenting and alignment. I have replied to that tracker you mentioned, but also pointed to this other tracker which is probably more in line with what people expect:


Unfortunately for us, the JR team, we are not going to see an end to this story because only the sky is the limit in terms of what HTML tags folks think we should support. Think of only the fact that people want CSS styling to work, so we would keep adding to this feature for years from now.





teodord's picture
Joined: Jun 30 2006 - 9:00am
Last seen: 3 days 14 hours ago