문제

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