Page 1 of 1

Export Report without opening Viewer in web application

Posted: Tue Jan 28, 2014 6:47 am
by prakashn
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

Re: Export Report without opening Viewer in web application

Posted: Wed Jan 29, 2014 6:58 am
by HighAley
Hello.

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

Posted: Wed Jan 29, 2014 7:52 am
by Vadim
Hello.
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

Posted: Thu Jan 30, 2014 9:57 am
by prakashn
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

Posted: Thu Jan 30, 2014 11:56 am
by Vadim
Hello.
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);
than you can use rendered report.
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

Posted: Thu Feb 06, 2014 5:58 am
by prakashn
Thanks Vadim. Its working fine now.

Re: Export Report without opening Viewer in web application

Posted: Thu Feb 06, 2014 8:40 am
by Andrew
Great!

Thank you.