在我的servlet中,我使用下面的代碼在瀏覽器中打開PDF文件,但是卻顯示一個下載對話框。如何在瀏覽器中顯示PDF文件
我做錯了什麼?
response.setContentType("application/pdf");
out = response.getWriter();
String filepath = "D:/MyFolder/PDF/MyFile.pdf";
response.setHeader("Content-Disposition", "inline; filename=" + filepath + ";");
FileOutputStream fileOut = new FileOutputStream("D:/MyFolder/PDF/MyFile.pdf");
fileOut.close();
out.close();
http://stackoverflow.com/questions/291813/recommended-way-to-embed-pdf-in-html? – gates
我有一個解決方案,但沒有太多fessible即使用apache poi api並將pdf文件中的每個頁面轉換爲圖像,然後顯示它 –
我怎麼能在servlet中做到這一點? –