• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to open a PDF in a Portlet

 
Saurabh Joshi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cameron,

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

Thanks,
Saurabh.
 
Sanjay Kannan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sanjay,
Thanks for this information, I will surely try this and update you.
Thanks,
Saurabh.
 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm usingRegards, Jan
 
Saurabh Joshi
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jan,

Thanks for that information.
IT WORKED FOR ME.

Saurabh.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic