Jump to content

Text and Lines not showing in HTML output


markrgli

Recommended Posts

Hi guys,

I have some reports that need to be exported into different outputs. Exporting to PDF and RTF work fine but when exporting to HTML, some text and line elements do not appear. I checked the source code of the HTML outputs and the text are not there. I'm clueless as to what's causing the problem.

Im exporting them from my code running in a web server.

Attached are screenshots of the exports showing one without the problems (sample_ok.png) and one with the problems (sample_ng.png). sample_ok.png is from iReport's preview but I get the same output when exporting to PDF or RTF. sample_ng.png is the actual HTML export, as viewed in Firefox.

I also included a snippet of my code for exporting to HTML.

I hope you guys can shed some light into this. Thank you in advance.

Regards,

Mark

Code:
-------------------------------------------------JRAbstractExporter exporter = new JRHtmlExporter();response.setContentType("text/html");exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, false);exporter.setParameter(JRHtmlExporterParameter.SIZE_UNIT, JRHtmlExporterParameter.SIZE_UNIT_POINT);		exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);// Set the output streamByteArrayOutputStream baos = new ByteArrayOutputStream();exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, baos);exporter.exportReport();// Set the content-lengthbyte[] reportAsBytes = baos.toByteArray();response.setContentLength(reportAsBytes.length);if (filename != null) {	filename = filename.trim();	if (!filename.isEmpty())		response.setHeader("Content-Disposition", "inline; filename=" + filename);}// Write to the response's output streamOutputStream os = response.getOutputStream();os.write(reportAsBytes, 0, reportAsBytes.length);os.flush();os.close();-------------------------------------------------
Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for the response, guys.

Attached are my JRXML files (zipped). The main report (EmpDetails.jrxml) is composed of several subreports (EmpDetails_*.jrxml). They just have to be on the same directory.

Kindly replace the SUBREPORT_DIR parameter in EmpDetails.jrxml.

<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">

<defaultValueExpression><![CDATA["D:\\workspaces\\Payroll\\com.sbiz.payroll.sv\\WebContent\\WEB-INF\\reports\\"]]></defaultValueExpression>

</parameter>

Thanks a lot guys. Hope you can shed light.

Link to comment
Share on other sites

1. Delete this and you'll have no problems with lines:

<rectangle>
                <reportElement mode="Transparent" x="0" y="0" width="356" height="20" backcolor="#FFFFFF"/>
 </rectangle>

 

2. Though, you may still experience stange behaviour cause almost all your field are overvlaping each others.

Try to avoid this when you're exporting to formats other than PDF and internal JR.

 

3. I bet you'll find interesting this information from FAQ



Post Edited by andfedotov at 12/05/2009 11:21 PM



Post Edited by andfedotov at 12/05/2009 11:21 PM
Link to comment
Share on other sites

Hi andfedotov,

Thanks for the insights.

I tried what you suggested in #1 but it didn't work for me. Just to clarify, I removed the entire <rectangle> ... </rectangle> section. This is correct, right?

Thanks for the link in #3. I will try the tips posted there. I might have to modify my design file to remove the overlaps.

Mark

andfedotov
Wrote:

1. Delete this and you'll have no problems with lines:

<rectangle>
                <reportElement mode="Transparent" x="0" y="0" width="356" height="20" backcolor="#FFFFFF"/>
 </rectangle>

 

2. Though, you may still experience stange behaviour cause almost all your field are overvlaping each others.

Try to avoid this when you're exporting to formats other than PDF and internal JR.

 

3. I bet you'll find interesting this information from FAQ



Post Edited by andfedotov at 12/05/2009 11:21 PM



Post Edited by andfedotov at 12/05/2009 11:21 PM
Link to comment
Share on other sites

Hmm, I've got much better result after removing this rectangle (btw, what was it's purpose?).

 

After that I got all lines on place, even though, as I said before, don't be surprised with an odd behaviour of html exporter when you have so much field overlapped..

Link to comment
Share on other sites

I rechecked my design file and I can't seem to find the any use for that. I'm using iReport (mainly on the design view) and I didn't notice it inserted that section into the xml.

 

I've removed the section already, but the lines still don't show up in Firefox and IE. They show up in Google Chrome. Some of the borders on my grids however, still don't appear. This probably has more to do with how the browsers render HTML. :(

 

As for the missing text problem, I've fixed it by modifying my report to remove overlaps between fields.

 

Thank you andfedotov, your responses have been a great help. :)

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...