Jump to content
Changes to the Jaspersoft community edition download ×

when am trying to get pdf i got empty pdf. anyone can help me


udumanajmeer

Recommended Posts

When am clicking button from jsp, i want to show welcome message in title location of the jasper like "Welcome to Jasper Report". but current time i can view pdf without message, where i did mistake can anyone help me.

My Action class is:

public String profile(){
        byte[] bytes = null;
        java.sql.Connection conn = null;
        try{
            File f = new File("D:\TestDrive\TestPdf.jasper");
            bytes = JasperRunManager.runReportToPdf(f.getPath(), new HashMap(),conn);
            ServletOutputStream op= response.getOutputStream();
            response.reset();
            response.setContentType("application/pdf");
            response.setHeader("Content-disposition","attachment; filename=" +"TestPdf.pdf");
            System.out.println("byte:"+bytes);
            op.write(bytes,0,bytes.length);
            op.flush();
            op.close();
        }catch (Exception e) {
            e.printStackTrace();
        }
        return SUCCESS;
    }

My jrxml:

<?xml version="1.0" encoding="UTF-8"?>
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="TestPdf" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="18bc00fc-082e-4a7b-b6f5-71dbb3646a45">
    <property name="ireport.zoom" value="1.0"/>
    <property name="ireport.x" value="0"/>
    <property name="ireport.y" value="11"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="79" splitType="Stretch">
            <staticText>
                <reportElement uuid="0eff255c-1238-4ebc-8876-75c47942fd29" x="0" y="13" width="555" height="52"/>
                <textElement textAlignment="Center">
                    <font fontName="Arial" size="24" isBold="true"/>
                </textElement>
                <text><![CDATA[Welcome to Jasper Report]]></text>
            </staticText>
        </band>
    </title>
    <pageHeader>
        <band height="35" splitType="Stretch"/>
    </pageHeader>
    <columnHeader>
        <band height="61" splitType="Stretch"/>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch"/>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch"/>
    </columnFooter>
    <pageFooter>
        <band height="54" splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>
 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

have you compiled your jrxml file into jasper object.
secondly why are u using this implementation of JasperRunManager.runReportToPdf when your Connection object is null, instead use a JREmptyDataSource.(possibly JasperEngine is trying to use Connection object to open a connection and getting a null pointer exception)

 

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