简体   繁体   中英

Display PDF in browser

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>

我认为您可以尝试一个名为XPDF的库,我可以将PDF转换为HTML页面,或者第二种选择是让用户打开该页面的链接(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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM