Jump to content
Changes to the Jaspersoft community edition download ×

poblem in jasper when shown as html file


Radheesh

Recommended Posts

Hi friends,

 

I am getting empty spaces,incomplete line

when i save jasperreport as Html also font size,

image,font style are diffrent in Html format

 

I won't prefer Applet Viewer because

it was slow while accessing through dialup

 

Please give me the solution

 

Following are the Codes , Expecting ur Solution

 

 

 

<%@ page errorPage="error.jsp" %>

 

<%@ page import="net.sf.jasperreports.engine.*" %>

<%@ page import="net.sf.jasperreports.engine.util.*" %>

<%@ page import="net.sf.jasperreports.engine.export.*" %>

<%@ page import="net.sf.jasperreports.j2ee.servlets.*" %>

<%@ page import="java.util.*" %>

<%@ page import="java.io.*" %>

 

<% String contextPath=request.getContextPath();

JasperPrint jasperPrint = (JasperPrint)session.getAttribute("jasperPrint");

session.setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);

// }

 

JRHtmlExporter exporter = new JRHtmlExporter();

 

int pageIndex = 0;

int lastPageIndex = 0;

if (jasperPrint.getPages() != null)

{

lastPageIndex = jasperPrint.getPages().size() - 1;

}

 

String pageStr = request.getParameter("page");

try

{

pageIndex = Integer.parseInt(pageStr);

}

catch(Exception e)

{

}

 

if (pageIndex < 0)

{

pageIndex = 0;

}

 

if (pageIndex > lastPageIndex)

{

pageIndex = lastPageIndex;

}

 

StringBuffer sbuffer = new StringBuffer();

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER, sbuffer);

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "../servlets/image?image=");

exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));

exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");

exporter.setParameter(JRHtmlExporterParameter.BETWEEN_PAGES_HTML, "");

exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");

 

exporter.exportReport();

%>

 

<html>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<head>

<style type="text/css">

a {text-decoration: none}

</style>

</head>

<body text="#000000" link="#000000" alink="#000000" vlink="#000000">

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<tr>

<td width="50%"> </td>

<td align="left">

<hr size="1" color="#000000">

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<tr>

<td><a href="<%=contextPath%>/transactions/viewhtml.jsp?reload=true"><img src="../imagesweb/reload.GIF" border="0"></a></td>

<td>   </td>

<%

if (pageIndex > 0)

{

%>

<td><a href="<%=contextPath%>/transactions/viewhtml.jsp?page=0"><img src="../imagesweb/first.GIF" border="0"></a></td>

<td><a href="<%=contextPath%>/transactions/viewhtml.jsp?page=<%=pageIndex - 1%>"><img src="../imagesweb/previous.GIF" border="0"></a></td>

<%

}

else

{

%>

<td><img src="../imagesweb/first_grey.GIF" border="0"></td>

<td><img src="../imagesweb/previous_grey.GIF" border="0"></td>

<%

}

 

if (pageIndex < lastPageIndex)

{

%>

<td><a href="<%=contextPath%>/transactions/viewhtml.jsp?page=<%=pageIndex + 1%>"><img src="../imagesweb/next.GIF" border="0"></a></td>

<td><a href="<%=contextPath%>/transactions/viewhtml.jsp?page=<%=lastPageIndex%>"><img src="../imagesweb/last.GIF" border="0"></a></td>

<%

}

else

{

%>

<td><img src="../imagesweb/next_grey.GIF" border="0"></td>

<td><img src="../imagesweb/last_grey.GIF" border="0"></td>

<%

}

%>

<td width="100%"> </td>

</tr>

</table>

<hr size="1" color="#000000">

</td>

<td width="50%"> </td>

</tr>

<tr>

<td width="50%"> </td>

<td align="center">

 

<%=sbuffer.toString()%>

 

</td>

<td width="50%"> </td>

</tr>

</table>

</body>

</html>

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

there is no problem with your jsp...

 

I think you need to make some small changes in in the .jrxml, you have set isBlankWhenNull property true for the textField.. its do well with .PDF and HTML in App. Viewer . but it will give you formatting problem in real html(that you are facing).

Just make te following modification:

Your code before::S

 

<textField ... >

<reportElement ..../>

<box ..../>

<textElement>

<font/>

</textElement>

<textFieldExpression ...>

<![CDATA[($F{Your_Field}]>

</textFieldExpression>

</textField>

New Code::)

<textField ... >

<reportElement ..../>

<box ..../>

<textElement>

<font/>

</textElement>

<textFieldExpression ...>

<![CDATA[($F{Your_Field}==null) ?

new YourDataType(0) : F{Your_Field}]]>

</textFieldExpression>

</textField>

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