iText generated PDF not shown correctly in Chrome

前端 未结 2 629
萌比男神i
萌比男神i 2021-01-27 13:10

I am using the iText library in Java to generate a pdf file. The idea is that a user fills in some information and that when the user clicks on the generate button the pdf is sh

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-27 13:34

    The way that I have achieved this in the past is by creating a seperate Servlet to serve PDF documents directly. In the web.xml file you would specify the servlet mapping to *.pdf.

    What you can do then is rather than override the FacesServlet response bytes to server the PDF file you just redirect the response to filename.pdf, passing needed parameters in the URL.

    Your PDF servlet can actually do the work of building the necessary PDF, it will open in a seperate tab and the URL will match the response redirect.

提交回复
热议问题