Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8779943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:55:23+00:00 2026-06-13T19:55:23+00:00

I have a simple Java program that takes a .jrxml file, compiles it, then

  • 0

I have a simple Java program that takes a .jrxml file, compiles it, then fills it. The data for the report is supplied in an XML file. After the fill is done, the data is exported to PDF.

// Parse input document
Document document = JRXmlUtils.parse(new File(xmlFile));

// Set it as the data source in the parameters
parameters.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);

// Create and set the virtualizer
JRFileVirtualizer virtualizer = new JRFileVirtualizer(2, "/tmp");
virtualizer.setReadOnly(true);
parameters.put(JRParameter.REPORT_VIRTUALIZER, virtualizer);

// Fill the report
String jasperFile = designFile.replaceAll(".jrxml",".jasper");
print = JasperFillManager.fillReport(jasperFile, parameters);

// Export the report to PDF
ArrayList<JasperPrint> jasperPrints = new ArrayList<JasperPrint>();
jasperPrints.add(print);
JRPdfExporter exp = new JRPdfExporter();
exp.setParameter (JRExporterParameter.JASPER_PRINT_LIST, jasperPrints);
exp.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName );
exp.exportReport();

My confusion is about the export

That fill line above works great for small reports, but once I get an XML source file approaching 1/2 MB, it will spin for over a day, regardless of setting the file virtualizer (which I do).

I see there is another method called fillReportToSteam. My confusion is that with fillReport, I have to do an extra step to export to PDF. What sort of stream is fillReportToStream writing to, and how do I specify that? Will fillReportToStream write to a PDF file?

I haven’t been able to find any examples. I was hoping I could take advantage of the stream so that I could measure the progress and get these PDFs to complete in a normal span of time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T19:55:24+00:00Added an answer on June 13, 2026 at 7:55 pm

    Calling fillReportToStream still produces a JasperPrint object, but it writes it directly to an output stream instead of passing it back to you. The JasperFillManager cannot output the report in any other format, so the export step cannot be skipped. To generate a PDF, you would still need to use JRPdfExporter and read the filled report from wherever the output stream wrote it to.

    I think the problem here is your file virtualizer. You mention that “it will spin for over a day, regardless of setting the file virtualizer” but the virtualizer will actually make the process take longer. It is a basic time/memory tradeoff to avoid out of memory errors, but will make the filling much slower. In a benchmark I’ve seen, adding a file virtualizer quadrupled the filling time!

    If you really need the virtualiser, try increasing the maxSize parameter you are passing. 2 seems awfully low. You could also try switching to a JRSwapFileVirtualizer as I’ve heard they have much better performance.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple java code that reads text csv file that contains sentences
I have a simple file transfer application that is run as a standalone Java
I have an Ant task to call a java process that takes a file
I have a simple parsing program that takes a few files and combines them.
I have an existing java command-line program, that takes a bazillion of arguments and
I have a very simple program, that loads an wavefront obj file, rotate and
I have a program written in Java that reads in a file that is
I have Simple java program named MainController.java. Wehn I try to compile it from
i found many related questions here. I have a simple java program . it
I have been trying to call a mapreduce job from a simple java program

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.