Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Hisham Zoghbi
Convert my HTML code in PDF Liferay 7
August 19, 2017 8:18 AM
Answer

Hisham Zoghbi

Rank: Junior Member

Posts: 32

Join Date: March 28, 2017

Recent Posts

Hello Guys,

Can I convert my Code from view.jsp to PDF und then send it per E-Mail? If so then plz with an example oder links that could help.

Thanks a lot

Sent from my iPhone with Liferay.com Forums
Jorge Díaz
RE: Convert my HTML code in PDF Liferay 7
August 19, 2017 2:11 PM
Answer

Jorge Díaz

LIFERAY STAFF

Rank: Expert

Posts: 490

Join Date: January 9, 2014

Recent Posts

In the past, in some projects, before using Liferay, I used following java library to transform from HTML to PDF: https://github.com/flyingsaucerproject/flyingsaucer/blob/master/README.md

But it seems it is not longer maintained, it only supports CSS 2.1
Neil Griffin
RE: Convert my HTML code in PDF Liferay 7
August 19, 2017 4:11 PM
Answer

Neil Griffin

LIFERAY STAFF

Rank: Liferay Legend

Posts: 2499

Join Date: July 26, 2005

Recent Posts

The Liferay Faces project maintains the jsf-export-pdf-portlet demo which utilizes the following dependency to convert HTML to PDF:
1        <dependency>
2            <groupId>org.xhtmlrenderer</groupId>
3            <artifactId>core-renderer</artifactId>
4            <version>R8</version>
5        </dependency>


The code in PDFUtil.java shows how to do the conversion.
Hisham Zoghbi
R: Convert my HTML code in PDF Liferay 7
August 19, 2017 5:27 PM
Answer

Hisham Zoghbi

Rank: Junior Member

Posts: 32

Join Date: March 28, 2017

Recent Posts

Thanks for the reply and the infos. But how can I import the dependencies if I'm using Liferay 7GA with Gradle Tool?


Sent from my iPhone with Liferay.com Forums
Jorge Díaz
RE: Convert my HTML code in PDF Liferay 7
August 20, 2017 7:53 AM
Answer

Jorge Díaz

LIFERAY STAFF

Rank: Expert

Posts: 490

Join Date: January 9, 2014

Recent Posts

For gradle tool, include following dependence:
1compile group: 'org.xhtmlrenderer', name: 'core-renderer', version: 'R8'

More info see: http://mvnrepository.com/artifact/org.xhtmlrenderer/core-renderer/R8

The library used in that jsf-export-pdf-portlet example (org.xhtmlrenderer) is the same library I said in my previous comment (flying saucer).

See:
So you will have problems with CSS3 or not xhtml code.

If you have problems with non xhtml code you can always use jtidy library to convert html to xhtml (http://jtidy.sourceforge.net/)
Hisham Zoghbi
R: Convert my HTML code in PDF Liferay 7
August 20, 2017 2:54 PM
Answer

Hisham Zoghbi

Rank: Junior Member

Posts: 32

Join Date: March 28, 2017

Recent Posts

Thank you all for the perfect information.

Sent from my iPhone with Liferay.com Forums