Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Satish Babu Anupoju
How to download PDF from Liferay 6.1 document library
17 aprile 2012 1.50
Risposta

Satish Babu Anupoju

Punteggio: Junior Member

Messaggi: 58

Data di Iscrizione: 19 febbraio 2011

Messaggi recenti

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
17 aprile 2012 7.47
Risposta

David H Nebinger

Punteggio: Liferay Legend

Messaggi: 7024

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

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
25 aprile 2012 3.40
Risposta

Sharath Babu A

Punteggio: Regular Member

Messaggi: 141

Data di Iscrizione: 18 maggio 2009

Messaggi recenti

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
25 aprile 2012 6.42
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7990

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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
25 aprile 2012 7.40
Risposta

Ravi Kumar Gupta

Punteggio: Liferay Legend

Messaggi: 1146

Data di Iscrizione: 23 giugno 2009

Messaggi recenti

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
25 aprile 2012 16.41
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7990

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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
25 aprile 2012 20.53
Risposta

Ravi Kumar Gupta

Punteggio: Liferay Legend

Messaggi: 1146

Data di Iscrizione: 23 giugno 2009

Messaggi recenti

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
26 aprile 2012 4.42
Risposta

Sharath Babu A

Punteggio: Regular Member

Messaggi: 141

Data di Iscrizione: 18 maggio 2009

Messaggi recenti

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
26 aprile 2012 4.48
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7990

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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
26 aprile 2012 5.52
Risposta

Sharath Babu A

Punteggio: Regular Member

Messaggi: 141

Data di Iscrizione: 18 maggio 2009

Messaggi recenti

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
26 aprile 2012 5.55
Risposta

Hitoshi Ozawa

Punteggio: Liferay Legend

Messaggi: 7990

Data di Iscrizione: 23 marzo 2010

Messaggi recenti

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
26 aprile 2012 21.28
Risposta

Sharath Babu A

Punteggio: Regular Member

Messaggi: 141

Data di Iscrizione: 18 maggio 2009

Messaggi recenti

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,