Jump to content
JasperReports Library 7.0 is now available ×

can"t fill report with jpg image


Recommended Posts

By: karibouxe - karibouxe

can"t fill report with jpg image

2006-05-12 06:45

hi,

 

I even tried the JasperReports.jpg on and I get

the following exception.

 

java.lang.IllegalArgumentException: Width (-1) and height (-1) cannot be <= 0

at java.awt.image.DirectColorModel.createCompatibleWritableRaster(DirectColorModel.java:999)

at java.awt.image.BufferedImage.<init>(BufferedImage.java:250)

at net.sf.jasperreports.engine.util.JRImageLoader.loadImageDataFromAWTImage(JRImageLoader.java:199)

at net.sf.jasperreports.engine.JRImageRenderer.getInstance(JRImageRenderer.java:207)

at net.sf.jasperreports.engine.fill.JRFillImage.evaluateImage(JRFillImage.java:434)

at net.sf.jasperreports.engine.fill.JRFillImage.evaluate(JRFillImage.java:403)

at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:275)

at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:399)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillTitle(JRVerticalFiller.java:279)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:220)

at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:750)

at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:647)

at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:63)

at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:402)

at reporting.generation.execute(generation.java:101)

at reporting.generation.main(generation.java:36)

Exception in thread "main"

 

I want insert a .jpg with code:

HashMap params = new HashMap();

java.awt.Toolkit toolkit = java.awt.Toolkit.getDefaultToolkit();

Image image = Toolkit.getImage(reportSrcPath+"logo.jpg");

params.put("logo", image);

 

print = JasperFillManager.fillReport(report,params,connection);

 

and in my .jrxml it is that:

<title>

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

<frame> <reportElement

mode="Opaque" x="72"

y="0"

width="363" height="49" forecolor="#FF3333" backcolor="#FF0033" key="frame-1"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/> <staticText>

<reportElement

x="0"

y="8"

width="362"

height="36"

forecolor="#FFFFFF" backcolor="#D4D0C8"

key="staticText-1"/>

 

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<textElement textAlignment="Center"> <font size="24"/>

</textElement>

<text><![CDATA[my report]></text>

</staticText>

</frame>

 

<image evaluationTime="Now" hyperlinkType="None" hyperlinkTarget="Self" >

<reportElement

x="0"

y="0"

width="59"

height="50"

key="image-1"/>

<box topBorder="None" topBorderColor="#000000" leftBorder="None" leftBorderColor="#000000" rightBorder="None" rightBorderColor="#000000" bottomBorder="None" bottomBorderColor="#000000"/>

<graphicElement stretchType="NoStretch"/>

 

<imageExpression class="java.awt.Image"><![CDATA[$P{logo}]]></imageExpression>

</image>

</band>

</title>

 

 

 

 

 

 

By: karibouxe - karibouxe

RE: can"t fill report with jpg image

2006-05-12 07:52

i change my type parameters and now it's java.lang.String and my error become :

 

java.lang.ClassCastException

at net.sf.jasperreports.engine.export.JRHtmlExporter.exportReport(JRHtmlExporter.java:351)

 

i understand nothing :'-(

 

Thanks for any advices

 

 

 

 

By: karibouxe - karibouxe

RE: can"t fill report with jpg image

2006-05-12 07:58

Sorry, for the spam :-S

I remove my parameters and i just have a image.

I use Ireport to insert this image. And i fixed its type to java.lang.String. And i fixed the "image expression" to "/reporting/images/logo.jpg".

 

and i always have :

java.lang.ClassCastException

at net.sf.jasperreports.engine.export.JRHtmlExporter.exportReport(JRHtmlExporter.java:351)

 

 

 

 

By: Teodor Danciu - teodord

RE: can"t fill report with jpg image

2006-05-12 08:03

 

Hi,

 

This has nothing to do with images.

Remove them all and you'll see.

 

What version of JR are you using?

It seems you are not configuring correctly

the HTML exporter and supply the wrong parameter

values, probably for the OUTPUT_STREAM parameter.

 

I hope this helps.

Teodor

 

 

 

 

 

By: karibouxe - karibouxe

RE: can"t fill report with jpg image

2006-05-12 08:09

i used the JR 1.2.2.

 

and my code is:

if(formatRapport.equals("web"))

{

JRHtmlExporter exporter = new JRHtmlExporter();

exporter.setParameter(JRHtmlExporterParameter.JASPER_PRINT, print);

exporter.setParameter(JRHtmlExporterParameter.OUTPUT_STREAM, fluxLectureTexte);

exporter.setParameter(JRHtmlExporterParameter.CHARACTER_ENCODING, "iso-8859-1");

exporter.setParameter(JRHtmlExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE); exporter.setParameter(JRHtmlExporterParameter.IS_USING_IMAGES_TO_ALIGN, new Boolean(false));

exporter.exportReport();

 

 

 

 

By: karibouxe - karibouxe

RE: can"t fill report with jpg image

2006-05-12 08:24

i want integrated jasper in my JSP and

my OUTPUT_STREAM is :

OutputStream fluxLectureTexte= response.getOutputStream();

 

I hope this helps to help me

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