Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Satish Babu Anupoju
How to download PDF from Liferay 6.1 document library
April 17, 2012 1:50 AM
Answer

Satish Babu Anupoju

Rank: Junior Member

Posts: 60

Join Date: February 19, 2011

Recent Posts

Hi Friends


Currently I am working with Liferay 6.1.
As per my requirement I have to upload bunch of all types of documents(like .txt, .doc, .pdf etc.,)

I am successfully uploading all the documents, But when I am trying to download, especially pdf and jpeg it is not giving any popup(like open and save ) and opening in the same window. It's not happening for remaining file extensions.


As per my requirement When I click on the download I want to ask one popup (link open and save ).

Can any one provide some suggestions to solve this issue.


Thanks in advance

Regards
Satish Babu
David H Nebinger
RE: How to download PDF from Liferay 6.1 document library
April 17, 2012 7:47 AM
Answer

David H Nebinger

Rank: Liferay Legend

Posts: 7451

Join Date: September 1, 2006

Recent Posts

Your browser is determining that it can handle the display of the PDF which is why it is not prompting.

I believe there are headers that you can set to force the download, but you'll have to google for that information. Note that I do not believe there is a standard cross-browser solution.
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
April 25, 2012 3:40 AM
Answer

Sharath Babu A

Rank: Regular Member

Posts: 141

Join Date: May 18, 2009

Recent Posts

Hi David H Nebinger,

Could you please be more clear, as even i am also looking for the same..


Regards,
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
April 25, 2012 6:42 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

Well, it's possible to download pdf file by right clicking on "Download" and selecting "Save target as..."

Or set the following property in portal-ext.properties
mime.types.content.disposition.inline=flv,swf,wmv
Ravi Kumar Gupta
RE: How to download PDF from Liferay 6.1 document library
April 25, 2012 7:40 AM
Answer

Ravi Kumar Gupta

Rank: Liferay Legend

Posts: 1230

Join Date: June 23, 2009

Recent Posts

There is one more thing. Reading that should be useful. http://www.jguru.com/faq/view.jsp?EID=252010
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
April 25, 2012 4:41 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

In other words, to use
portal-service/src/com/liferay/portal/kernel/servlet/ServletResponseUtil.java

to call #531
protected static void setHeaders(
HttpServletRequest request, HttpServletResponse response,
String fileName, String contentType) {


even though, it's just doing this

String extension = GetterUtil.getString(
FileUtil.getExtension(fileName)).toLowerCase();

String[] mimeTypesContentDispositionInline = null;

try {
mimeTypesContentDispositionInline = PropsUtil.getArray(
"mime.types.content.disposition.inline");
}
catch (Exception e) {
mimeTypesContentDispositionInline = new String[0];
}

if (ArrayUtil.contains(
mimeTypesContentDispositionInline, extension)) {

contentDisposition = StringUtil.replace(
contentDisposition, "attachment; ", "inline; ");
}

response.setHeader(
HttpHeaders.CONTENT_DISPOSITION, contentDisposition);
}
Ravi Kumar Gupta
RE: How to download PDF from Liferay 6.1 document library
April 25, 2012 8:53 PM
Answer

Ravi Kumar Gupta

Rank: Liferay Legend

Posts: 1230

Join Date: June 23, 2009

Recent Posts

Thanks Hitoshi for sharing the code snippet. I was thinking the same but just was lazy enough to look into it. emoticon And its good to know that Liferay is taking care by itself.
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
April 26, 2012 4:42 AM
Answer

Sharath Babu A

Rank: Regular Member

Posts: 141

Join Date: May 18, 2009

Recent Posts

Hi Hitoshi,

Thanks for sharing your idea. What ultimately we need a popup to download the pdf & jpeg files.

If it is possible with hooks, Could you please explain me with more clear steps, So that i can do the same in my machine.


Regards,
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
April 26, 2012 4:48 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

This is just for pdf.

Just set the following property in portal-ext.properties:

mime.types.content.disposition.inline=flv,swf,wmv
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
April 26, 2012 5:52 AM
Answer

Sharath Babu A

Rank: Regular Member

Posts: 141

Join Date: May 18, 2009

Recent Posts

I have already set the properties in portal-ext.properties. But didn't found any luck.

Thanks for prompt response.

Regards,
Hitoshi Ozawa
RE: How to download PDF from Liferay 6.1 document library
April 26, 2012 5:55 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7954

Join Date: March 23, 2010

Recent Posts

Can you tell me which browser and version you're using? Right click on the "Download" doesn't work either?
Sharath Babu A
RE: How to download PDF from Liferay 6.1 document library
April 26, 2012 9:28 PM
Answer

Sharath Babu A

Rank: Regular Member

Posts: 141

Join Date: May 18, 2009

Recent Posts

Hi Hitoshi,

I am able to right click on the "download" and "saveAs". But i need is a popup should open as its opening while downloading txt,ppt,doc etc.


Regards,