1
Hello,
I have a problem generating a report with Jasper Reports in spring.
I did the implementation exactly as stated in method 4 of this explanation: https://stackoverflow.com/a/27532493
When I click the button to generate the report, I am redirected to the link as @Requestmapping and the browser loads the report into the browser’s internal pdf reader.. then the problem begins..
On the desktop, as the browsers have the internal pdf reader, it is loaded but when I save, the file doesn’t even have a name defined (it always stays as Document.pdf).
If I try to generate this same report by a mobile phone (I’m testing on an android), opens the pdf reader that is installed and then error saying that the format is not supported. When I force a link download, a format-free file is downloaded (if I put the . pdf extension in the file it opens normally).
I can change something in this implementation so that when you click the generate report button, it is directed directly to the file. pdf generated to work on both desktop and mobile or for this case I have to do a more "raw" implementation like link method 1 (which I think should work because it defines the name and type of file in Sponse) ?
vlw!
putting these properties (added also
p.setProperty("Content-Type", "application/pdf");
, solved the issue of the file name, and if you force the download downloads the file correctly with the extension and everything. by cell phone when it tries to load the pdf reader directly, still error saying that it could not open the pdf file because it is in an invalid format. But there was still a doubt, putting these properties in the solution, I couldn’t change the name of the file according to the report, right? or I can pass that name by the controller?– Fillipe Duoli
I did some research on
Content-disposition
here and found that see in place of theinline
placeattachment
the browser forces the file to download. Doing this started to work on mobile also, as it starts to force the download instead of trying to load the browser. The question remains even if I can pass this file name through the controller. If you could put the filename to match the filename of the file. Jasper would also be a good way out.– Fillipe Duoli