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

Image Size as field?


2004 IR Help

Recommended Posts

By: Andreas Mitterer - mitterea

Image Size as field?

2004-12-23 02:25

I have a rather complex report with images. The number and the size of the images is variable. I put my images into the report using a field which looks like this:

<imageExpression class="java.lang.String"><![CDATA[$F{imageURL}]]></imageExpression>

That works fine.

Is there a possibility to tell the report the size of an image using a field? If not, is such a feature planned for future releases of JR?

 

The only possibility I see until now is reading in the .jrxml design, set the dimensions of each image directly into the design and then compile it.

 

But this would not correspond to my report-generation structure.

 

Any ideas that would help?

 

Andreas

 

 

 

 

By: macoute - macoute

RE: Image Size as field?

2004-12-23 07:22

when you design a report, you don't know the size of the image.

But you design your detail without data, and in the filling process Jasper put

the image in the field according to the field's parameters.

 

If you want to modify the size of the field due to image size,

you must move all fields. Because if you increase size, an other field can be under.

 

 

 

 

By: Andreas Mitterer - mitterea

RE: Image Size as field?

2005-01-05 01:32

Thanks for your reply.

 

This means I have to know the exact number and dimensions of all images _before_ generating the design?

 

So the only possibility I see is to dynamically generate the report design (i.e. parse the xml and modify it) according to the settings made for the current report. However, this is what I wanted to avoid by using fields...

Link to comment
Share on other sites

  • 3 years later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

this works:

Code:
			BufferedImage img = ImageIO.read(new File(wo_image_path));			height = img.getHeight();			width = img.getWidth();						jasperSubDesign = JasperManager.loadXmlDesign(context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jrxml"));			JRDesignImage image = (JRDesignImage)jasperSubDesign.getPageHeader().getElementByKey("wo_image");			image.setX(3);			image.setY(69);			image.setHeight(new Long(height - Math.round(height*.35)).intValue());			image.setWidth(new Long(width - Math.round(width*.35)).intValue());			JasperCompileManager.compileReportToFile(jasperSubDesign, context.getRealPath("/WEB-INF/reports/decoration_sheet_header.jasper"));
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...