How to embed a HTML-Page in Report?

0

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>

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

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

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>

and with

textFieldExpression / textElement markup="html"

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"))))

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

jaroslaw.nawrot's picture
Joined: Nov 17 2014 - 4:38am
Last seen: 3 years 1 month ago

3 Answers:

0

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>

Best regards,

Jaracz

jaroslaw.nawrot's picture
Joined: Nov 17 2014 - 4:38am
Last seen: 3 years 1 month ago
0

Hi Jaracz,

Which version of Jaspersoft Server are You using? Trying with 6.1 and 6.2, when I publish a report with an Html component I get an error of "invalid JRXML" and it seems a kind of bug of the Server.

best regards,

Mirco

 

mirco.marchitiello's picture
Joined: Jun 16 2014 - 11:10am
Last seen: 3 years 8 months ago
0

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>
siick's picture
24
Joined: Jul 3 2017 - 8:35am
Last seen: 1 year 12 months ago
Feedback
randomness