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

export pdf cause outofmemory,but in Ireport not


sctom123

Recommended Posts

I meet a strange problem.I export a pdf file which nearly 8M.about 32 pages.when I export it in Ireport ,I can work normaly.but when I write a simple program to export it .a outofmemory Error occurs.I have debug source code of IReport about exporting.but I find nothing diffrent.why? This is my export code:

Code:

Connection connection = null;
try {
connection = getConnection();
JRFileVirtualizer virtualizer = new JRFileVirtualizer (2, "c:\test"«»);
virtualizer.setReadOnly(false);
map.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);
String fileName = "D:\temp\report\chart.jasper";
JasperReport jr = (JasperReport) JRLoader.loadObject(fileName);
JasperPrint jp = JasperFillManager.fillReport(jr, map, connection);
net.sf.jasperreports.engine.JRExporter exporter = new net.sf.jasperreports.engine.export.JRPdfExporter();
exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME,"c://test//test.pdf"«»);
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
exporter.exportReport();

I have speed a week time on this problem.but I haven't find solution.can someone can help me .apprecieate for your reply.

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

I have find a solution.

JRFileVirtualizer virtualizer = new JRFileVirtualizer (2, "c:\test");

the max size was setted too small.I modified it as below:

JRFileVirtualizer virtualizer = new JRFileVirtualizer (100, "c:\test");

the pdf document can be export normally.I will continue to do more test.

Thanks anyone. espiecly redbeans.:P

Link to comment
Share on other sites

  • 2 years later...

Sorry, but this problem is still alive (at least for me).

I'm getting "out of memory" while filling out the report, even passing a JRFileVirtualizer to the JasperReport object. Well, I'm printing images the size of about 2MB each. They are not stored in the database, so I think it's not a problem with JRDataSource. Only a reference to the folder and name of the image is provided by the JRDataSource. The message appears after retrieving image number 24, with or without JRVirtualizer (I wonder! Is there some else to do than simply passing the virtualizer as REPORT_VISTUALIZER to the report?)

No problems using iReport instead.

I'm using jasperreports-3.5.0.jar.

There must be something I'm missing and I don't know what! (live's hard indeed) 

Any ideas out there?

Thanks

 

Code:
List images = new DocumentoArrollamiento(  ).fotosTramo( tramo, ronda );System.out.println( "----------Nro.images = " + images.size(  ) );JRFileVirtualizer fileVirtualizer = new JRFileVirtualizer( 3, "c:\\TEMP" );//tried 100 pages too, but didn't workMap _params = new HashMap(  );_params.put( JRParameter.REPORT_VIRTUALIZER, fileVirtualizer );File tempFile = File.createTempFile( "jasper_", ".pdf" );JasperReport jasperReport = (JasperReport) JRLoader.loadObject(_jrxmlFileName );System.out.println( "---------->jasperReport loaded" );JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, _parametrosInforme, _jasperReport );System.out.println( "---------->I never get here!!" );JasperExportManager.exportReportToPdfFile(jasperPrint,tempFile.getAbsolutePath());...
Link to comment
Share on other sites

  • 1 year later...
  • 4 months later...

When trying to execute the following line of code:

JasperReport jr = (JasperReport) JRLoader.loadObject(sourceFile);

I get the following exception: net/sf/jasperreports/engine/JasperPrint incompatible with net/sf/jasperreports/engine/JasperReport .   I am using jasperrports-3.5.3.jar.  Any ideas?

The documentation for that class tells me that an Object is being returned for that method loadObject(File).

Code:
JasperReport jr = (JasperReport) JRLoader.loadObject(sourceFile);net/sf/jasperreports/engine/JasperPrint incompatible with net/sf/jasperreports/engine/JasperReport
Link to comment
Share on other sites

  • 1 year later...

Re: "The Virtualizer doesn't help until you set the jasper report properties "isUsingCache" to false and "isLazy" to true."

 I don't know for sure, but I believe the properties she is referring to get set on the image element(s) in the report.  



Post Edited by darbvin at 05/24/2012 01:34
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...