Hello everybody, recently I written a code for converting HTML to PDF. Initially, I thought of using iText PDF library to generate PDF file as an attachment while sending emails to the user. When I started working on it one of my team members told me that iText is no more open source. Without even knowing the actual details like from which version iText is not Open Source, I started using PDFBox jars for PDF related operations.
Even though PDFBox is one of the good libraries, I felt difficult to align the things inside PDF if content is changing dynamically. So, I thought of using some techniques like converting Image to PDF or HTML to PDF to avoid alignment problems but of no luck.
Finally, I started reading about iText license, based on information provided in wikipedia, I came to know that till 2.1.7 iText is available under LGPL, then again I started using iText for HTML to PDF convertion.
Following are the Code snippets for HTML to PDF Conversion :
- Maven Dependency Details:
<dependency> <groupId>commons-io</groupId> <artifactId>commons-io</artifactId> <version>0.1</version> </dependency> <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</artifactId> <version>2.1.7</version> </dependency> <dependency> <groupId>org.xhtmlrenderer</groupId> <artifactId>flying-saucer-pdf</artifactId> <version>9.0.1</version> </dependency>
- Code to convert HTML to PDF:
Content in this post has been moved, please Click Here… for new location of the actual content
Sorry for the inconvenience. Please click the above link to continue to read.This is all because the content has been moved to the new website www.dailypaper.in/technical/.
Please follow me in the new website www.dailypaper.in/technical for more technical stuff.