Fórumok

Error application/pdf mime type

thumbnail
Elisa Bracaloni, módosítva 12 év-val korábban

Error application/pdf mime type

Junior Member Bejegyzések: 43 Csatlakozás dátuma: 2011.04.21. Legújabb bejegyzések
Hello,
I developed a custom portlet for Liferay 6.
Clicking on a link should open the popup to open/save a pdf file generated using Jasper Reports.
I use response.setContentType ("application/pdf"), where response is RenderResponse.
But I am returned the following error:

ERROR [jsp] java.lang.IllegalArgumentException: application / pdf is not a supported mime type
at com.liferay.portlet.MimeResponseImpl.setContentType (MimeResponseImpl.java: 159)........

I also tried to add the tag in the file portlet.xml
<supports>
<mime-type> application/pdf </mime-type>
<portlet-mode> view </portlet-mode>
</supports>
addition to that already existing
<supports>
<mime-type> text / html </mime-type>
<portlet-mode> view </portlet-mode>
</supports>
but I always get the same error.

Do you have suggestions?

Thanks.
Elisa
thumbnail
Thiago Leão Moreira, módosítva 12 év-val korábban

RE: Error application/pdf mime type

Liferay Legend Bejegyzések: 1449 Csatlakozás dátuma: 2007.10.10. Legújabb bejegyzések
Hi Elisa,

Are you using the serveResource method to generate the pdf? You must put your "generate pdf logic" inside the serverResource method and there set the content Type to application/pdf. Don't worry about the mime-type tag settings.

Hoep this helps
thumbnail
Elisa Bracaloni, módosítva 12 év-val korábban

RE: Error application/pdf mime type

Junior Member Bejegyzések: 43 Csatlakozás dátuma: 2011.04.21. Legújabb bejegyzések
Thiago Leão Moreira:
Hi Elisa,

Are you using the serveResource method to generate the pdf? You must put your "generate pdf logic" inside the serverResource method and there set the content Type to application/pdf. Don't worry about the mime-type tag settings.

Hoep this helps


I use to generate pdf

ByteArrayOutputStream out = new ByteArrayOutputStream();
try {

JRExporter exporter = new JRPdfExporter();
exporter.setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);
exporter.exportReport();
}
thumbnail
Thiago Leão Moreira, módosítva 12 év-val korábban

RE: Error application/pdf mime type

Liferay Legend Bejegyzések: 1449 Csatlakozás dátuma: 2007.10.10. Legújabb bejegyzések
That sounds good but where is this code put on? You should put it inside of your serveResource method of your portlet.

New Feature: Resource Serving in JSR 286
thumbnail
nicolas saubi, módosítva 11 év-val korábban

RE: Error application/pdf mime type

Junior Member Bejegyzések: 43 Csatlakozás dátuma: 2009.10.28. Legújabb bejegyzések
Hey there, sorry to get back to life such an old post, but I'm stuck with a

java.lang.IllegalArgumentException
at com.liferay.portlet.MimeResponseImpl.setContentType(MimeResponseImpl.java:264)


Fact is we use Struts with liferay, so I can't use the answer you gave before (or don't know how).
I'm loading a pdf from some ftp connection, and then I would like to display it on screen when a user click the pdf link, but fact is it only displays characters, like the code of the pdf...

I'm lost. I know we can go around this by forcing the portlet to be fullscreen (Maximized), but don't know how to do it with my struts+liferay configuration.


Any help really welcome, 2 days lost already =(