- Dynamic pdf file create but all tag should be proper in html other wise it give the exception
- itextpdf-5.5.8.jar
- xmlworker-5.5.8.jar
package com.kartik.pdf;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import com.itextpdf.text.Document;
import com.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.PdfWriter;
import com.itextpdf.tool.xml.XMLWorkerHelper;
/**
*
* @author kmandal
*
*/
public class PdfCreateTest {
public static void main(String[] args) throws DocumentException,
IOException {
Document document = new Document();
PdfWriter writer = PdfWriter.getInstance(document,
new FileOutputStream("C:\\Users\\kmandal\\Desktop\\pdf.pdf"));
document.open();
XMLWorkerHelper.getInstance().parseXHtml(writer, document,
new FileInputStream("C:\\Users\\kmandal\\Desktop\\dfff.html"));
document.close();
System.out.println("PDF Created!");
}
}
- <html>
<head></head>
<body style="padding:0px 0px 0px 15px; margin: 0; width: 550px; font-family:arial, sans-serif;">
<table cellpadding="0" cellspacing="0" width="760" style="padding:0!important;margin:0!important;">
<tr>
<td width="740">
<table cellpadding="0" cellspacing="0">
<tr>
<td >
<img src="https://Kartik.Example.com/Kartik/images/new_Example_logo.gif" alt="Example Kartik Alerts" ></img>
</td>
<td style="padding:0;margin:0">
<img src="https://Kartik.Example.com/Kartik/images/sapgreengradient.gif" width="620" height="78"></img>
</td>
</tr>
</table>
</td>
<td width="20" style="background:#6EA0CA;"></td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="760">
<tr>
<td width="20" style="background:#265E72;"></td>
<td style="padding:0px 10px 0px 10px; font-family:arial, sans-serif;">
<div xmlns:exsl="http://exslt.org/common" style="width: 620px; background-color: #ffffff">
<div style="margin: auto; width: 85%; padding: 10px;">
<p style="width: 90px; height: 22px; font-family: ProximaNova;font-size: 18px;font-weight: 600;color: #1e1d1c;">
Hi ,
</p>
<p style=" width: 300px;height: 22px;font-family: ProximaNova;font-size: 18px;color: #1e1d1c;">
Here's your
Weekly financial snapshot.
</p>
</div>
<div style="width: 100%; border-radius: 3px; background-color: #ffffff; border: solid 1px #cdcac9; margin: auto; padding: 10px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td style="height: 41px;border-radius: 3px; background-color: #57a7fb;" bgcolor="#3498db" height="40" width="755" align="center"><span style="width:100%;height: 17px;font-family: ProximaNova;font-size: 14px;font-weight: 600;letter-spacing: 0.3px;color: #ffffff;"> Where Your Money Is Going
- </span></td>
</tr>
</table>
<table style="text-align:center;" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="text-align:center;" height="250" width="100%"><img height="200" width="200" style="display: block; margin-left: auto; margin-right: auto;" src="http://in-l1669:3000/1496998812156/99:resources:-1/finapp/img/alert-services/failure.png"></img></td>
</tr>
</table>
<p style="width: 485px;height: 36px; font-family: ProximaNova; font-size: 13px; line-height: 1.38; text-align: left; color: #1e1d1c;">
<font style="font-size: 14px; font-family: Arial;font-weight: bold;">
We don't have any events to show you this
week or next.
</font>
Make sure you have linked all your accounts and added all your recurring bills.
<table align="center" cellpadding="0" cellspacing="0">
<tr>
<td style="-webkit-border-radius: 25px; -moz-border-radius: 25px; border-radius: 25px; ms-border-radius: 25px; khtml-border-radius: 25px; color: #ffffff; display: block;" bgcolor="#3498db" height="40" width="170" align="center"><a style="font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; color: #FFFFFF; display:inline-block" href="https://Kartik.Example.com/"><span style="color: #FFFFFF">LOG IN</span></a></td>
</tr>
</table>
</p>
</div>
<div style=" margin: auto; width: 85%; padding: 10px; height: 16px; font-family: ProximaNova; font-size: 13px; letter-spacing: -0.1px; text-align: left; color: #77716f;">
* The projected balance is based on the most recent account information available.
</div>
<div style="width: 100%; border-radius: 3px; background-color: #ffffff; border: solid 1px #cdcac9; margin: auto; padding: 10px;">
<table cellpadding="0" cellspacing="0">
<tr>
<td style="height: 41px;border-radius: 3px; background-color: #57a7fb;" bgcolor="#3498db" height="40" width="755" align="center"><span style="width: 100%;height: 17px;font-family: ProximaNova;font-size: 14px;font-weight: 600;letter-spacing: 0.3px;color: #ffffff;"> Where Your Money Is Going
Jun 02 -
Jun 09</span></td>
</tr>
</table>
<div>
<table style="table-layout: fixed;" width="100%">
<tr>
<th></th><th></th><th></th><th></th><th></th><th></th><th></th>
</tr>
<tr>
<td colspan="7"> You spent
US$0.0 this month
</td>
</tr>
<tr>
<td colspan="3" rowspan="10"><img height="200" width="200" style="display: block; margin-left: auto; margin-right: auto;" src="cid:ea-image"></img></td><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
<tr>
<th></th><th></th><th></th><th></th>
</tr>
</table>
</div>
<hr></hr>
<p style="font-size:13px;font-family:arial; padding-top:10px;">
You spending last week include these transactions:
</p>
<div>
<table width="100%">
<tr>
<td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top">Jun 08</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;"><font style="font-size: 14px; font-family: Arial;font-weight: bold;">DELAWARE RETAIL PYT</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">Uncategorized</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">ACC-SC1 |
xxxx1234</font>
</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top"><font style="font-size: 14px; font-family: Arial;font-weight: bold; padding-left:10px;">-
US$59.0</font></td>
</tr>
<tr>
<td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top">Jun 08</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;"><font style="font-size: 14px; font-family: Arial;font-weight: bold;">PHARMACIES AFFILIEES</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">Healthcare/Medical</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">ACC-SC1 |
xxxx1234</font>
</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top"><font style="font-size: 14px; font-family: Arial;font-weight: bold; padding-left:10px;">-
US$59.0</font></td>
</tr>
<tr>
<td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top">Jun 08</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;"><font style="font-size: 14px; font-family: Arial;font-weight: bold;">ESSENTIAL CATERING REPAIRS</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">Restaurants/Dining</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">ACC-SC1 |
xxxx1234</font>
</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top"><font style="font-size: 14px; font-family: Arial;font-weight: bold; padding-left:10px;">-
US$59.0</font></td>
</tr>
<tr>
<td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top">Jun 08</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;"><font style="font-size: 14px; font-family: Arial;font-weight: bold;">AGRIMI PTY LTD</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">Uncategorized</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">ACC-SC1 |
xxxx1234</font>
</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top"><font style="font-size: 14px; font-family: Arial;font-weight: bold; padding-left:10px;">-
US$59.0</font></td>
</tr>
<tr>
<td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top">Jun 08</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;"><font style="font-size: 14px; font-family: Arial;font-weight: bold;">KENNEBECASIS VALLEY HIGH SCHOOL</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">Education</font>
<font style="font-size: 14px; font-family: Arial;color: #808080;">ACC-SC1 |
xxxx1234</font>
</td><td style="border-bottom: 2px solid #bcbaba; padding-top:10px; padding-bottom:10px;" vAlign="top"><font style="font-size: 14px; font-family: Arial;font-weight: bold; padding-left:10px;">-
US$59.0</font></td>
</tr>
<tr>
<td></td><td style="-webkit-border-radius: 25px; -moz-border-radius: 25px; border-radius: 25px; ms-border-radius: 25px; khtml-border-radius: 25px; color: #ffffff;" bgcolor="#3498db" height="40" width="170" align="center"><a style="font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; color: #FFFFFF;" href="https://Kartik.Example.com/">VIEW ALL EXPENSES</a></td><td></td>
</tr>
</table>
</div>
</div>
</div>
<div style="color: #666;">
<p style="margin-top:50px;margin-left:20px;color:#000;font-size:11px;font-family:arial;">Copyright © 2016 Example Inc. All rights reserved.</p>
<p style="margin-top:20px;margin-left:20px;color:#000;font-size:11px;font-family:arial;">
You have received this e-mail because you have subscribed to the Example Kartik service or a subscriber of the service wants to change sharing of accounts with you.
To access Example Kartik, please go to <a href="https://Kartik.Example.com/">https://Kartik.Example.com/</a>.</p>
<p style="margin-left:20px;color:#000;font-size:11px;font-family:arial;">
Do not reply to this e-mail. To contact customer support, please log into your Example Kartik account and use the "Submit Service Request" option.
</p>
</div>
<table cellspacing="0" cellpadding="0">
<tr>
<td><img src="https://Kartik.Example.com/Kartik/images/footerGradient1.gif" width="720" height="58" ></img></td>
</tr>
</table>
</td>
<td width="20" style="background:#6EA0CA;margin-left:-2px;"></td>
</tr>
</table>
</body>
</html>