Jump to content
Changes to the Jaspersoft community edition download ×

Jasper Report download file name


ag201

Recommended Posts

guys,

 

i have this implementation, when the user clicks on a show report button, a PDF report is generated and the user is able to view it internally within the IE browser using the PDF viewer.

 

now when the user clicks on save a copy on the adobe toolbar, it always saves the report as app.pdf.

 

can i set up my report in such a way, that when the user clicks on save a copy, a meaningfull name shows up.

 

i have this so far,

response.setHeader ("Content-Disposition", "inline;filename="pdf-" + getCurrentTime() + ".pdf"");

 

but this doesnt help me set the name. any help guys. thanks.

Link to comment
Share on other sites

  • 1 month later...
  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

 

I made some tests and it seems like the response header you tries works, but only if the user save the PDF using the Save As ... option of the browser and not the save button in the Acrobat plugin and only in Firefox.

I don't have a solution for you, but you might get better luck on the iText mailing list.

 

I hope this helps.

Teodor

Post edited by: teodord, at: 2007/04/04 14:08

Link to comment
Share on other sites

  • 4 years later...

Hi Teodor -

I have a similar issue.  It's my experience that the exported (pdf/xls) file DOES come down with a meaningful name, if it is set in the <jasperReport name="foo"> tag.

However, there is a related problem:  Consider the case where the user requests the report again, but with slightly different parameters.  In a web-based application, calling the JasperReportServer webapi to generate a report, the filename is the same as before, so the results are improperly cached.

Is there a way that the jasperReport name can be set at runtime, so that I can make it unique (and therefore not cached)?  In other systems, we have just attached a sufficiently unique timestamp to the URL parameters but in this case it's just the report name that comes back down.

Link to comment
Share on other sites

http://www.whitemagicsoftware.com/software/java/rif/

http://www.whitemagicsoftware.com/software/java/rif/api/com/whitemagicsoftware/report/Parameters.html#PARAM_REPORT_FILENAME

The idea is that you make the file name part of a parameter that is filled in by the HTTP FORM POST action.

If you need to include a programmatic item (such as the date), you override a single method to provide the appropriate value.

If you have questions, let me know.



Post Edited by thangalin at 04/13/2011 23:47
Link to comment
Share on other sites

Ah, I thought you were using JasperReports, not JasperServer. The integration framework isn't so much a new technology as a layer of abstraction that simplifies integrating JasperReports with web development. (Essentially, people around the world are all hard-coding the same problems -- including some fairly severe security issues -- into their web applications; this API shields the web application from such tight coupling.)




Post Edited by thangalin at 04/14/2011 19:51
Link to comment
Share on other sites

Indeed, I have other applications where the web pages are accessing JasperReportsLibrary, and your approach would be a nice evolution for that someday.  But for this problem, yes, the web pages are accessing the reports via requests to JasperReportsServer - that is where I need to make the filename unique to defeat caching on report reruns (with different parameters).

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