*
The moose likes Portals and Portlets and the fly likes How to open a PDF in a Portlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "How to open a PDF in a Portlet" Watch "How to open a PDF in a Portlet" New topic
Author

How to open a PDF in a Portlet

Saurabh Joshi
Ranch Hand

Joined: Nov 15, 2007
Posts: 37
Hi,

I am new to portlet environment.
My aim is to let the PDF open at user's end/make him save it.

As portal sets the content type (e.g, text/html) and encoding as the portal page starts rendering. In my case, the setContentType() would be useless since the servlet container won't let me change it. I can either use a popup browser window for the pdf as, or use an iframe if I want to render the pdf inside the portlet window.

This is my present code, but it is not good enough to do the above thing.



Please guide me in this, as I am not knowing how to do it??
Thanks & Regards,
Saurabh.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968
    
    1

IBM has a special document viewer portlet:

IBM Document Viewer Portlet

Which portal are you using? If it's IBM, maybe you can open up some of the JSP files and see what they're doing in this portlet.

-Cameron McKenzie
Saurabh Joshi
Ranch Hand

Joined: Nov 15, 2007
Posts: 37
Hi Cameron,

I am using Liferay portal.
Please give me some help with this, I am stuck here.

Thanks,
Saurabh.
Sanjay Kannan
Greenhorn

Joined: Nov 25, 2007
Posts: 16
You cannot push binary in portlet like you do in web application. What you have to do is to generate the PDF on the server and pass the path info to the portlet so that it can read the pdf as a normal client.
you might have to use the <EMBED> tag to display the pdf in the portlet.

<EMBED TYPE="application/pdf" SRC="<%=filename%>" WIDTH='<%=width%>' HEIGHT='<%=portletRequest.getAttribute("height")%>' HREF='<%=filename%>' PLUGINSPAGE="http://www.adobe.com/products/acrobat/readstep.html" ></EMBED>

If you had used WebSphere portal, the document viewer portlet comes out of the box, but looks like you are using liferay. But its easy, you should be able to achieve the functionality.
[ December 01, 2007: Message edited by: Sanjay Kannan ]
Saurabh Joshi
Ranch Hand

Joined: Nov 15, 2007
Posts: 37
Hi Sanjay,
Thanks for this information, I will surely try this and update you.
Thanks,
Saurabh.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

I'm usingRegards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
Saurabh Joshi
Ranch Hand

Joined: Nov 15, 2007
Posts: 37
Hi Jan & Sanjay,

I tried with both of your suggestions, But I think I am making some mistake.
When I tried with tag in my .jsp, I get a empty portlet with nothing in it.
And when I tried


It's not showing me the
Click Here
hyperlink.

Please suggest me where I am going wrong??
It's urgent.

Thanks for your support.
Saurabh.
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

c:/ccqr.pdf
Your href should point to a location within your web application,not to a windows directory format.

In your web app, try to create a directory named: pdfs
Put your ccqr.pdf there.
Than change c:/ccqr.pdf in your page to: /pdfs/ccqr.pdf

Regards, Jan
Saurabh Joshi
Ranch Hand

Joined: Nov 15, 2007
Posts: 37
Hi Jan,

Thanks for that information.
IT WORKED FOR ME.

Saurabh.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to open a PDF in a Portlet
 
Similar Threads
Error while running in ecllipse.
tomcat connection
Store portlet preferences in struts portlet
iReports - HTML format in JSP
Trying to call Jasper iReport through portlet & getting error