Hi Team,
We integrated Stimulsoft Reports.Fx for Java with our web application and generating reports.
Now we got new requirement like, need to directly export the report to PDF or Excle without opening the viewer or at runtime we need to disable/hide few export options from viewer.
Please let me know how can we achieve this. Its a bit urgent requirement.
Thanks in advance.
Regards,
Prakash
Export Report without opening Viewer in web application
Re: Export Report without opening Viewer in web application
Hello.
Sorry for the delay with answer.
We need some additional time to prepare answer for you.
Thank you.
Sorry for the delay with answer.
We need some additional time to prepare answer for you.
Thank you.
Re: Export Report without opening Viewer in web application
Hello.
For direct open file in browser you can use servlet that generate with custom settings & return file (example for PDF file):
For direct open file in browser you can use servlet that generate with custom settings & return file (example for PDF file):
Code: Select all
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
try {
StiDocument document = StiSerializeManager.deserializeDocument(new File(
"c:\\TwoSimpleLists.mdc"));
response.setContentType("application/pdf");
StiPdfExportSettings settings = new StiPdfExportSettings();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
StiExportManager.exportPdf(document.getReport(), settings, bos);
byte[] binaryData = bos.toByteArray();
response.addHeader("Content-Length", String.valueOf(binaryData.length));
//response.addHeader("Content-Disposition", "attachment;filename=\"test.pdf\""); uncomment it if you don't want to open file in browser - want to download it
StiIOUtil.writeInputStream(response.getOutputStream(), new ByteArrayInputStream(
binaryData));
} catch (Exception e) {
e.printStackTrace();
}
}
Re: Export Report without opening Viewer in web application
Hi Vadim,
This is working fine for .mdc files. But for .mrt files, the response is null and returns corrupt file.
Is there some other way for .mrt files?
Thanks,
Prakash
This is working fine for .mdc files. But for .mrt files, the response is null and returns corrupt file.
Is there some other way for .mrt files?
Thanks,
Prakash
Re: Export Report without opening Viewer in web application
Hello.
You must render .mrt file (see our Samples forlder), for example:
than you can use rendered report.
You must render .mrt file (see our Samples forlder), for example:
Code: Select all
StiReport renderReport = StiSerializeManager.deserializeReport(new File("Reports/SimpleList.mrt"));
//add neccessary databases
renderReport.getDictionary().getDatabases().add(new StiXmlDatabase("Demo", "Demo.xsd", "Demo.xml"));
//render report
renderReport.Render(false);
prakashn wrote:Hi Vadim,
This is working fine for .mdc files. But for .mrt files, the response is null and returns corrupt file.
Is there some other way for .mrt files?
Thanks,
Prakash
Re: Export Report without opening Viewer in web application
Thanks Vadim. Its working fine now.
Re: Export Report without opening Viewer in web application
Great!
Thank you.
Thank you.