aspose file tools*
The moose likes Servlets and the fly likes How to display PDF file only in a portion of the browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to display PDF file only in a portion of the browser" Watch "How to display PDF file only in a portion of the browser" New topic
Author

How to display PDF file only in a portion of the browser

james rod mantaring
Greenhorn

Joined: Oct 30, 2013
Posts: 2
Hi,

I want to display PDF file on the object tag or iframe tag of the html. The PDF file is from the local of my computer. I tried using this code:

by accessing through this link:

the user can access this controller

and should display the PDF file in the object tag:

but instead of displaying the PDF file in the object tag it display it on the whole page. What am I doing wrong?
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1162
    
    1

Welcome to Javaranch !!!

I have never used object tags but can you try reducing width and height to let us say 50%. Better if we can give width and height in pixels (for example - width=300 , height=200) . try this change and let us know if this has resolved your problem or not.

Rendering PDF in HTML Page may not work on all browsers. It depends on how the browser handles PDF files. Some browsers can render PDF directly in HTML page and some browser try to download it.

You can check PDFObject JS library http://pdfobject.com/ specially meant for displaying PDF in HTML Page. This website say that this library take care of browser compatibility issues.

~ abhay


Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I
james rod mantaring
Greenhorn

Joined: Oct 30, 2013
Posts: 2
Thank you for your warm welcome.

I try to give it a specific width and height looks good to me. Can you give a simple example of the link you gave me? with back end? I'm not that familiar with the samples they include there. Thanks
Abhay Agarwal
Ranch Hand

Joined: Feb 29, 2008
Posts: 1162
    
    1

glad to know that your problem is solved.
Apologises I have not used JS library.
I got this JS library info from google.
So please search on google about its code sample and examples.

~ abhay
 
Consider Paul's rocket mass heater.
 
subject: How to display PDF file only in a portion of the browser