如何在浏览器中显示PDF文件 [英] How to display PDF file in browser
本文介绍了如何在浏览器中显示PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的servlet中,我使用下面的代码在浏览器中打开PDF文件,而是显示一个下载对话框。
In my servlet I am using the code below to open a PDF file in a browser, but instead, it shows a download dialog box.
我在做什么错误?
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();
推荐答案
你可以尝试用
u can try to do the same with
response.setHeader("Content-Disposition", "attachment;filename="+filepath+";");
这篇关于如何在浏览器中显示PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文