How to display PDF from Java

0

I would like to know how I can show a pdf file generated in servlet and show it a new tab / window html or jsp, I still do not make the document but I do not see that it is very complicated.

Is it possible to do something like what I have in mind? I've searched through some forums but I do not find anything guided to what I need.

I thank you in advance ...

    
asked by Jonathan 08.06.2018 в 05:18
source

2 answers

0

If you want to open a pdf in a java web application, there are quite a few quick tutorials on how to do it if you know how to search for them well, here is a video that I have found and I hope it will help you.

link

Greetings

    
answered by 08.06.2018 в 09:37
0

you have to know if you use jasper or some other report generator

because from jsp the only thing you would have to use would be a response to show the typical pdf output format ..

    File pdfFile = new File(application.getRealPath("/reportes/pdf/") + "/reporteFicha.pdf");
byte[] pdfByteArray = FileUtils.readFileToByteArray(pdfFile);
response.setContentType("application/pdf");
response.setHeader("Content-Length", String.valueOf(pdfFile.length()));
response.setHeader("Content-Disposition", "inline; filename=\"" + pdfFile.getName() + "\"");
response.getOutputStream().write(pdfByteArray);
response.getOutputStream().flush();
    
answered by 08.06.2018 в 09:41