Jump to content
Changes to the Jaspersoft community edition download ×

Missing Images in on-the-fly HTML Report


Recommended Posts

By: kcyxa - kcyxa

Missing Images in on-the-fly HTML Report

2006-04-27 22:52

Hi,

 

What do I need to do exactly to get the images of the report to show up in the HTML file that I convert it to on-the-fly??? I'm using the code below in my servlet. Your help would be greatly appreciated!!!

 

File reportFile = new File(getServletConfig().getServletContext().getRealPath("/reports/ImageReport.jasper"));

 

Map parameters = new HashMap();

 

JasperPrint jasperPrint = JasperFillManager.fillReport(reportFile.getPath(), parameters, new JREmptyDataSource());

 

Map imagesMap = new HashMap();

 

request.getSession().setAttribute(ImageServlet.DEFAULT_JASPER_PRINT_SESSION_ATTRIBUTE, jasperPrint);

 

JRHtmlExporter exporter = new JRHtmlExporter();

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);

 

exporter.setParameter(JRExporterParameter.OUTPUT_WRITER,out);

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_MAP, imagesMap);

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "image?image=");

 

exporter.exportReport();

out.close();

 

 

 

 

 

 

By: frankrtg - francisco_rdz

RE: Missing Images in on-the-fly HTML Report

2006-04-28 08:29

Greets

 

You can add the following parameters just before exporter.exportReport();

 

 

String destino = getServletConfig().getServletContext().getRealPath("/reports/");

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,destino);

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,destino);

 

 

 

 

 

 

By: frankrtg - francisco_rdz

RE: Missing Images in on-the-fly HTML Report

2006-04-28 08:29

Greets

 

You can add the following parameters just before exporter.exportReport();

 

 

String destino = getServletConfig().getServletContext().getRealPath("/reports/");

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,destino);

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,destino);

 

 

 

Francisco Rodríguez

 

 

 

 

By: kcyxa - kcyxa

RE: Missing Images in on-the-fly HTML Report

2006-04-28 09:51

Thanks for your reply!

 

If I use:

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "/reports/images/");

 

...then the space of the HTML report that's occupied by "px" image is filled (because I have that "px" image in the specified folder), but because other images of the report are converted to other names like image_0_0_1, for example, having the original image in that folder (named logo) doesn't help.

 

Does image servlet or image.jsp HAVE to be used? I've tried to include it, but it didn't seem to help. Do the original images have to be renamed?? Please help.

 

 

 

 

By: frankrtg - francisco_rdz

RE: Missing Images in on-the-fly HTML Report

2006-04-28 10:50

Hi again.

 

I think I forgot to give you another parameter needed. You have to tell the exporter to put images into a DIR as TRUE.

 

Here you are:

 

PrintWriter out = response.getWriter();

 

JRHtmlExporter exporter = new JRHtmlExporter();

 

exporter.setParameter(JRExporterParameter.JASPER_PRINT,jasperPrint);

 

exporter.setParameter(JRExporterParameter.OUTPUT_WRITER, out);

 

exporter.setParameter

(JRHtmlExporterParameter.IS_OUTPUT_IMAGES_TO_DIR, Boolean.TRUE);

 

destino = //my absolute path;

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_DIR_NAME,destino);

 

exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI,destino);

 

exporter.exportReport();

 

 

I hope this help you!

 

greets

Francisco Rodríguez

 

 

 

 

By: kcyxa - kcyxa

RE: Missing Images in on-the-fly HTML Report

2006-04-28 11:13

Great! Thanks, Francisco. That worked. I will use that.

 

I was wondering, is it possible to produce HTML on-the-fly without actually outputting the renamed images to a file? Is that where the IMAGE_MAP and image servlet comes in? That's what didn't work for me... Do you have any suggestions? Thanks for your help!

 

 

 

 

 

By: kcyxa - kcyxa

RE: Missing Images in on-the-fly HTML Report

2006-04-28 11:20

The reason I'm wondering about that is that I'm trying to build a web application (for many users), so if this solution might work for static pictures in a standard report, then something like a pie chart created on-the-fly from that particual report's data might get in conflict with simultaneous requests from other users. I hope I wasn't too confusing :)

 

 

 

 

By: kcyxa - kcyxa

RE: Missing Images in on-the-fly HTML Report

2006-04-28 11:12

Great! Thanks, Francisco. That worked. I will use that.

 

I was wondering, is it possible to produce HTML on-the-fly without actually outputting the renamed images to a file? Is that where the IMAGE_MAP and image servlet comes in? That's what didn't work for me... Do you have any suggestions? Thanks for your help!

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