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

Converting jrxml file to jpeg..possible???


karenper

Recommended Posts

  • Replies 11
  • Created
  • Last Reply

Top Posters In This Topic

Do you mean export your report to a jpeg, or actually take a capture of the report file text and store it as a jpeg?

 

I am not sure of an exporter which exports directly to jpeg, gif etc. But if you export to pdf, there are many ways to convert to an image file. Although pdf itself is a pretty universal format.

 

You can always print-screen the jrxml file in a text editor of your choosing to capture that text.

 

Hth,

Robin

Link to comment
Share on other sites

I guess that your question is whether you can export a filled report to an jpeg image..

 

You can, for example by creating a buffered image, using JRGraphics2DExporter to export a filled report page to the buffered image and then use something like Sun's Image I/O APIs or JAI APIs to encode the buffered image into a jpeg. If you want to export all the report pages into a single image, you need to think how the pages will be concatenated into a single image and use export offsets for JRGraphics2DExporter.

 

HTH,

Lucian

Link to comment
Share on other sites

also all methods of JRGraphics2DExporter return void. so how can i export the report to a BufferedImage?by report do you mean the pdf file or the compiled jrxml file?

My requirement is that from a web application when a report is created it has to be converted to a jpeg image so that this image can be used for certain other reports.all this then has to be done at the server end and cannot involve the client doing anything like saving the image....plllls reply asap...

regards,

karen

 

Post edited by: karenper, at: 2006/10/13 05:44

Post edited by: karenper, at: 2006/10/13 05:45

Link to comment
Share on other sites

rsilver@bfm.bm wrote:

Do you mean export your report to a jpeg, or actually take a capture of the report file text and store it as a jpeg?

I am not sure of an exporter which exports directly to jpeg, gif etc. But if you export to pdf, there are many ways to convert to an image file. Although pdf itself is a pretty universal format.

You can always print-screen the jrxml file in a text editor of your choosing to capture that text.

Hth,
Robin

I mean mean export my report to a jpeg. I found this tool called ImageMagick which runs a command line function to convert files.but will this help me?

 

this is wat i found -

In my program, I start a minimized command prompt and need to wait until the

process is finished. This can be done like this:

 

 

System.out.println("invoking convert...");

 

Process proc = Runtime.getRuntime().exec("cmd /c start /wait /MIN

c:\ImageMagick2\convert test1.pdf toto.jpg");

try

{

proc.waitFor();

}

catch (InterruptedException intex)

{

}

 

System.out.println("done convert...");

 

 

pls reply asap....

Link to comment
Share on other sites

I'm not sure any more what's this thread about, but maybe this will help..

 

This is sample code for exporting a report page to a BufferedImage:

Code:

JasperPrint print = ..;
int pageIndex = ..;

BufferedImage pageImage = new BufferedImage(print.getPageWidth() + 1, print.getPageHeight() + 1, BufferedImage.TYPE_INT_RGB«»);
JRGraphics2DExporter exporter = new JRGraphics2DExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
exporter.setParameter(JRGraphics2DExporterParameter.GRAPHICS_2D, pageImage.getGraphics());
exporter.setParameter(JRExporterParameter.PAGE_INDEX, new Integer(pageIndex));
exporter.exportReport();

 

And this is some code that uses Sun's Image I/O APIs to encode the buffered image as jpeg:

Code:
[code]
String jpegFilename = ..;
Iterator writers = ImageIO.getImageWritersByFormatName("jpeg"«»);
ImageWriter writer = (ImageWriter) writers.next();
ImageOutputStream ios = ImageIO.createImageOutputStream(new File(jpegFilename));
writer.setOutput(ios);
writer.write(pageImage);

 

If this looks useful, you should adapt the code for your particular needs.

 

HTH,

Lucian

Link to comment
Share on other sites

  • 3 years later...
  • 10 months later...
  • 1 year later...

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