Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Offer report as download
kurent
How can I make it so that the generated report is offered to the user as a download (save as)?
Find more posts tagged with
Comments
mwilliams
Hi kurent,
With the birt-viewer, the user can already export and save a report in several different formats. Please see the attached screenshot.
kurent
But can it be done so the user get's the save as dialog? Don't really need the viewer.
mwilliams
kurent,
Where are you displaying the generated report? BIRT requires a viewer of some sort, whether it's the designer, the deployed BIRT viewer, or your own custom viewer.
kurent
I would like to display it in Adobe Acrobat Reader.
I guess I need to study this BIRT viewer, but I would still like to know how to make it so that the user get's the save as dialog with the pdf.
mwilliams
kurent,
As PDF is one of the standard outputs for BIRT, when the report is generated in PDF, it will automatically open in Adobe and the user will be able to choose save as like they normally would.
kurent
I am using a servlet and sending an ajax request to the doGet method where the engine starts up and generates. Now how do I set the output?
One way to set output is this:
options.setOutputFileName("c:/birt/report.pdf");
Which saves on the local hard drive, not what I want.
Ok what about this:
resp.setContentType("application/pdf");
options.setOutputStream(resp.getOutputStream());
Then on the client side I tried doing JavaScript document.write(responseText); but it just writes binary data and doesn't realize it's a pdf.
Virgil Dodson
I think your servlet just needs setoutputformat set like below.
response.setContentType( "application/pdf" );
response.setHeader ("Content-Disposition","inline; filename=test.pdf");
...
options.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
options.setOutputStream(response.getOutputStream());
task.setRenderOption(options);