2011-06-10 153 views
0

如何显示网页中的一个PDF文件(不seprately,只是里面的网页),使用JSP或Servlet?显示PDF文档

+0

通常这不是浏览器决定的事情吗? – 2011-06-10 11:54:14

回答

0

您需要使用<object><embed>标记来包含adobe阅读器并指向您的pdf文件。

类似:<embed src="YourFile.pdf" width="500" height="375">

另一个答案在这里:EMBED vs. OBJECT

0

您需要设置内容类型本上响应。 call response.setContentType(“aplication/pdf”);在写任何流之前。

+0

请参阅示例[here](http://stackoverflow.com/questions/5968328/question-on-java-servlet-to-open-a-pdf-file-using-itext)或[Here](http:// stackoverflow.com/questions/5040776/i-cant-open-a-pdf-in-my-browser-by-java) – sudmong 2011-06-10 12:00:32