Foren

How to download PDF from Liferay 6.1 document library

thumbnail
Satish Babu Anupoju, geändert vor 12 Jahren.

How to download PDF from Liferay 6.1 document library

Junior Member Beiträge: 79 Beitrittsdatum: 20.02.11 Neueste Beiträge
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
thumbnail
David H Nebinger, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Liferay Legend Beiträge: 14919 Beitrittsdatum: 02.09.06 Neueste Beiträge
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.
simon tuffle, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Regular Member Beiträge: 150 Beitrittsdatum: 18.05.09 Neueste Beiträge
Hi David H Nebinger,

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


Regards,
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
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
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
There is one more thing. Reading that should be useful. http://www.jguru.com/faq/view.jsp?EID=252010
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
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);
}
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
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.
simon tuffle, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Regular Member Beiträge: 150 Beitrittsdatum: 18.05.09 Neueste Beiträge
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,
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
This is just for pdf.

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

mime.types.content.disposition.inline=flv,swf,wmv
simon tuffle, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Regular Member Beiträge: 150 Beitrittsdatum: 18.05.09 Neueste Beiträge
I have already set the properties in portal-ext.properties. But didn't found any luck.

Thanks for prompt response.

Regards,
thumbnail
Hitoshi Ozawa, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Liferay Legend Beiträge: 7942 Beitrittsdatum: 24.03.10 Neueste Beiträge
Can you tell me which browser and version you're using? Right click on the "Download" doesn't work either?
simon tuffle, geändert vor 12 Jahren.

RE: How to download PDF from Liferay 6.1 document library

Regular Member Beiträge: 150 Beitrittsdatum: 18.05.09 Neueste Beiträge
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,