Jump to content

How to embed a HTML-Page in Report?


jaroslaw.nawrot

Recommended Posts

Hi Everyone,

 

I'm trying to include a simple HTML page (a small table) from a remote server in my report, unfortunately it looks not so simple, as I thought...

 

I'm using jasper-htmlcomponent in this way:

<componentElement>    <reportElement x="129" y="50" width="300" height="350" uuid="b346885c-8588-427f-b9f3-e262c34ce1ed"/>    <hc:html xmlns:hc="http://jasperreports.sourceforge.net/htmlcomponent" xsi:schemaLocation="http://jasperreports.sourceforge.net/htmlcomponent http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd" scaleType="RetainShape" horizontalAlign="Left" verticalAlign="Middle">        <hc:htmlContentExpression><![CDATA["<p>It works!</p>"]]></hc:htmlContentExpression>    </hc:html></componentElement>[/code]

 

That works. Then I thought, I could try something like:

"<frameset cols='100%'><frame src='http://myserver.com/test.html'></frameset>" [/code]

 

Unfortunately I get an empty page, though I can see in the Apache-Logs on the remote server, that the file "test.html" is being successfully downloaded from Jasper.

 

I've also tried with:

<iframe src="http://myserver.com/test.html"></iframe>[/code]

and with

textFieldExpression / textElement markup="html"[/code]

but it's the same.

 

The only way I've found is to use

(new java.util.Scanner(new java.io.FileInputStream(new java.io.File("/opt/www/test.html"))))[/code]

 

but the real page I want to use is dynamically generated on a remote server, so this is no solution for me.

 

Can You please help?

 

Thank you in advance!

 

Best regards,

 

Jaracz

 
Link to comment
Share on other sites

  • 2 weeks later...
  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Problem solved!

 

For those, who also want to include some remote HTML in report:

 

<hc:htmlContentExpression><![CDATA[(new java.util.Scanner(new java.io.BufferedReader(new java.io.InputStreamReader(new java.net.URL("http://path.to.server/page").openStream())))).useDelimiter("\A").next()]]></hc:htmlContentExpression>[/code]

 

Best regards,

 

Jaracz

Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...

On jasperreport server 6.2.0 i have a "net.sf.jasperreports.engine.JRException: Error loading object from file" when i add a html component like this one but i have no error in jaspersoft studio

<componentElement> <reportElement x="20" y="40" width="580" height="140" uuid="b346885c-8588-427f-b9f3-e262c34ce1ed"/> <hc:html xmlns:hc="http://jasperreports.sourceforge.net/htmlcomponent" xsi:schemaLocation="http://jasperreports.sourceforge.net/htmlcomponent http://jasperreports.sourceforge.net/xsd/htmlcomponent.xsd" scaleType="RetainShape" horizontalAlign="Left" verticalAlign="Middle"> <hc:htmlContentExpression><![CDATA[$F{INFORMATION_PROJET}]]></hc:htmlContentExpression> </hc:html> </componentElement>
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...