Jump to content

Rendering HTML to PDF in JASPER


erctheanda

Recommended Posts

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
4.indentation
5. Justify, align

Code:
	<detail>		<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"/>				</textElement>				<textFieldExpression class="java.lang.String"><![CDATA["<html>" +"<body>" +(($F{htmlContent} != null) ? String.valueOf($F{htmlContent}) : "") +"</body>" +"</html>"]]></textFieldExpression>			</textField>		</band>	</detail>
Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...
  • 5 months later...

Got the same problem.

Unfortunately, the issue at http://jasperforge.org/projects/jasperreports/tracker/bug_view_page.php?bug_id=4842 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.

Link to comment
Share on other sites

Hi,

 

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:

http://jasperforge.org/projects/jasperreports/tracker/view.php?id=4256

 

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.

 

Thanks,

Teodor

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...