Jump to content
Changes to the Jaspersoft community edition download ×

Display JPG, GIF or BMP dynamically


Recommended Posts

By: Andrew Arrow - andrewarrow

Display JPG, GIF or BMP dynamically

2002-07-12 19:43

I have a report that lists filenames. For example you might have:

 

1. readme.txt

2. Game.exe

3. Story.doc

4. Boat.jpg <actual image needs to be displayed>

5. test.txt

 

If the file is of type JPG, GIF or BMP instead of just printing the name of the file, I need to actually display the image! If the file is of any other type I just need to display the name, size, and date. The images must be displayed dynamically within the list of other filenames and we do not know the width and height of the images. Can I get your advice on the best way to handle this? Should I stored the width and height of the image in the database and have that send in as as two fields? Is this even possible to do? Thanks.

 

-Andrew

 

 

 

 

By: Teodor Danciu - teodord

RE: Display JPG, GIF or BMP dynamically

2002-07-16 01:49

 

Hi,

 

You don't have to store the image size.

You can always retrieve them if you want after

loading the image.

I don't know if they are of any use for

JasperReports, since you cannot control the image

size in the report at runtime.

 

I think you will obtain the best results if you choose

scaleType="RetainShape" for your image element

in the report.

 

Pay attention to the image types supported by the

Java platform and the iText library that we use to

generate PDF.

 

Thank you,

Teodor

 

 

 

By: Andrew Arrow - andrewarrow

RE: Display JPG, GIF or BMP dynamically

2002-07-16 07:52

I'm using <reportElement x="0" y="0" width="760" height="400">

<printWhenExpression>new Boolean($F{0}.indexOf(".jpg") > -1)</printWhenExpression>

</reportElement>

 

in a break group. The trouble I'm having is I'm now burried so far down into sub-sub-sub-sub-report that all the top-margins and bottom-margins and band heights, etc are making it very hard to get the image to just show on it's own new page.

 

I have:

 

1. Master.xml with a sub-report called

2. s1013.xml with a sub-report called

3. Phase.xml with a sub-report called

4. PhaseItem.xml with a sub-report called

5. File.xml with a sub-report called

6. Image.xml which displays the image

 

I have a break-group in File.xml with a group expression of the filename so it breaks on every file. Then I do that printwhen expression trick to only call the Image sub-report if the filename is an JPG. Trouble is making the break group isStartNewPage = true doesn't give me a new page like I want. I get the image in the middle of the page, or written on top of the other text. I've been playing with all the margins and sizes etc but I can't seem to get each image on it's own page. Any advice?

Thanks.

 

-Andrew

 

 

By: Teodor Danciu - teodord

RE: Display JPG, GIF or BMP dynamically

2002-08-08 01:55

 

Hi,

 

I think this is the same problem:

 

http://sourceforge.net/forum/forum.php?thread_id=714685&forum_id=113529

 

Thank you,

Teodor

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