I am developing a Java Web Application (jsp/servlet) using tomcat. I need to display pdf file from local machine. can you suggest what is best way to display it?

有帮助吗?

解决方案

I used iframe to display pdf file.

  <iframe src="resume.pdf" width="100%" style="height:60em">
        [Your browser does <em>not</em> support <code>iframe</code>,
        or has been configured not to display inline frames.
        You can access <a href="../latin9.pdf">the document</a>
        via a link though.]
    </iframe>

其他提示

I think you can try a Library called XPDF , I think you can convert from PDF to HTML page , or the second option is just let the user open a link to the page (www.yourwebsite.com/pdffolder/somepdf.pdf)

If you need display a pdf file using tomcat, you can access directly to the file using the specific url where the file is located in your navigator, depending on the path where you put the file, so you can access using 127.0.0.1/files/test.pdf for example. If you need generate a pdf, the best tool I think is iText, this is an easy example how to use id: Introducing PDF and iText

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top