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

Sometimes Corrupted pdf are generated and sometimes not ? why ?


dhruvil.27392

Recommended Posts

Whenever I generate PDF reports, they are corrupted. But, luckily i dont know how, but sometimes they are not corrupted and generated perfectly ? why ?

there are no errors or exceptions while generating them.(400 page reports are being generated).

does anyone has experienced this problem or anyone have solved this issue ?

 

i dont understad how can i debug or solve this problem. it is very annoying to keep on generating report until a proper report is generated.

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Even I am generating pdf from my Program. but I don't know, where exactly is the bug because there are no errors or exception.

Let me know , what was your bug and and how did you solved it. or you can even check problem in my program.

 

I am creating a file stream. and forwarding it to frontend to download

 


public File createPDFReport(File fillReportInFile, String JASPER_FILE_PATH, Map<String, Object> parameters) {
 
/* Get Jasper file from resource folder */
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream projectInputStream = classloader.getResourceAsStream(JASPER_FILE_PATH);
File generatedFile = fillReportInFile;
/* parameters for reports */
// System.out.println(parameters);
 
/* printing reports */
try {
JasperPrint jasperPrint = JasperFillManager.fillReport(projectInputStream, parameters,
new JREmptyDataSource());
 
/*
* Exporting generated reports as PDF Stream into 'generatedReport'
*/
JasperExportManager.exportReportToPdfStream(jasperPrint, new FileOutputStream(generatedFile));
System.out.println(" REPORT NAME "+generatedFile.getName());
 
} catch (JRException e) {
e.printStackTrace();
}
catch (FileNotFoundException e) {
log.error("ERROR : Unable to create file");
}
 
return generatedFile;
 
}

 

 

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