Which is the appropriate View class to render existing PDF? AbstractView?
I am fetching PDF via a webservice ,so I'm not looking to subclass AbstractPdfView to render PDF.
I'd like to stay with the Spring controller classes which return a ModelAndView which means writing my own subclass of AbstractView to just write the PDF to a ServletOutputStream. Any other built in support available in Spring MVC?
Thanks
I agree with @Biju Kunjummen's answer but using iText would be also nice to generate the PDF.
here is the code snippet of the controller method.
Hope this helps you. Cheers.
I think the best way is to simply stream it out using HttpServletResponse:
There is no such class.
You have to manually write that file. Please see answer here: Display the PDF file stored on the webserver on Browser new window using Spring MVC
I have changed that code to:
Also, see the answer for not downloading the pdf and putting the inputStream in the finally block.