Jump to content
We've recently updated our Privacy Statement, available here ×

Generated PDF file is empty.


2004 IR Help

Recommended Posts

By: [ale] - acastro2703

Generated PDF file is empty.

2005-01-28 07:28

[using jr v 0.6.4, itext 1.01 and also test it with 1.2 and the jrxml was generated with ireport 0.4.0]

 

Hello,

 

I'm trying to generate a PDF report from a servlet. The user will have several options, HTML, PDF and XLS. Now, HTML works fine, the report is generated and it's filled with data. But if I try to generate the PDF version of the report, the resulting PDF contains only a blank page. I don't know if it has to do with the size of the report (45 column) but there is no data on the PDF. I have tried several ways of sending the response to the user (using JasperRunManager.runReportToPdfStream, or using an exporter, getting the bytes and writting them to the response output, which i guess are the same thing).

 

I have no exceptions, the only weird thing is that the report is genereted fine on HTML but is not generated at all on PDF.

 

Can someone help me with this ? Any idean on what might be going on...

 

 

 

 

By: [ale] - acastro2703

RE: Generated PDF file is empty.

2005-01-28 09:32

Thanks for your answer, but that did just the same. The PDF is still with no data on it (not even the title or the static text) while it is generated correctly on HTML....

 

 

 

 

By: Gregory A. Swarthout - gswarthout

RE: Generated PDF file is empty.

2005-01-28 09:37

If we could see the template, maybe the solution would be obvious.

 

 

 

 

By: Michael Bauer - mbabauer

RE: Generated PDF file is empty.

2005-01-28 10:50

I know that I had some problems with some reports I generated with iReport. It sets the action by default print an empty page if there is data. I usually change that to print all bands if there is no data.

 

 

 

 

By: [ale] - acastro2703

RE: Generated PDF file is empty.

2005-01-28 14:21

Ok, here's a _short_ version of the template (actually, the real template is about 2000 lines since iReport generates a lot of stuff there, so, i removed most of the attributes and this is the result, i hope this shorter version helps...)

 

<?xml version="1.0" encoding="UTF-8" ?>

<!-- Created with iReport - A designer for JasperReports -->

<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">

 

<jasperReport name="SPReport" columnCount="45" pageWidth="4560" pageHeight="28346" columnWidth="100" columnSpacing="0" leftMargin="30" rightMargin="30">

<reportFont name="Arial_Normal" isDefault="true" fontName="Arial" size="10" isBold="false" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<reportFont name="Arial_Bold" isDefault="false" fontName="Arial" size="10" isBold="true" isItalic="false" isUnderline="false" isStrikeThrough="false" pdfFontName="Helvetica-Bold" pdfEncoding="Cp1252" isPdfEmbedded="false"/>

<parameter name="title" class="java.lang.String">

</parameter>

<field name="CPY" class="java.lang.Integer"/>

<title>

<band height="20">

<textField isBlankWhenNull="true">

<reportElement x="0" y="0" width="100" height="20"/>

<textElement textAlignment="Center">

<font reportFont="Arial_Bold" size="14"/>

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$P{title}]]></textFieldExpression>

</textField>

</band>

</title>

<columnHeader>

<band height="20">

<staticText>

<reportElement x="0" y="0" width="100" height="20"/>

<textElement textAlignment="Center">

<font reportFont="Arial_Bold" size="12"/>

</textElement>

<text><![CDATA[CPY]]></text>

</staticText>

</columnHeader>

<detail>

<band height="20" isSplitAllowed="true" >

<textField isStretchWithOverflow="true">

<reportElement x="0" y="0" width="100" height="20"/>

<textElement textAlignment="Left">

<font reportFont="Arial_Normal" size="10"/>

</textElement>

<textFieldExpression class="java.lang.Integer"><![CDATA[$F{CPY}]]></textFieldExpression>

</textField>

</band>

</detail>

</jasperReport>

 

 

 

 

By: Michael Bauer - mbabauer

RE: Generated PDF file is empty.

2005-01-28 07:48

I am doing something similar from withing a STRUTS/J2EE application.

 

The way I handle the PDF is to use the JasperPrintManager.printReportToPdfStream() method. The code looks like:

 

public byte[] getPDFDownload(HashMap properties, HashMap parameters) throws Exception {

ByteArrayOutputStream bout = new ByteArrayOutputStream();

 

JasperPrintManager.printReportToPdfStream(getJasperPrint(properties,parameters),bout);

 

return bout.toByteArray();

}

 

This works fine for me. This way, you end up with a byte array that is the PDF file, and can easily send that back via the HttpResonse object in the servlet.

 

 

 

 

By: rcastillo - rcastillog

RE: Generated PDF file is empty.

2005-02-03 17:43

Hi mbabauer.

 

I have the same problem but the thing are that the jasper or the pdf are ok, if you try to redirect the out to a one file you will see that the pdf is created fine, my case if a want to print the report, the servlet where is generated, do two request, but i still cant print de jasper in the explorer with only one request, you can try pass the report like a download file and not like and pdf.

 

forgive the bad english.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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