2011-06-10 89 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