日期:2014-05-18 浏览次数:21405 次
<div class="texte-libre-rose" style="text-align: right; margin-right: -25px;">
<h1 style="color: rgb(34, 34, 34); text-transform: none; line-height: normal; text-indent: 0px; letter-spacing: normal; font-family: Arial, Verdana, sans-serif; font-style: normal; font-variant: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">
<img alt="" src="http://a.cksource.com/c/1/inc/img/demo-little-red.jpg" style="width: 120px; height: 168px; margin-right: 10px; margin-left: 10px; float: left; cursor: default;" />Little Red Riding Hood</h1>
<table align="right" border="1" cellpadding="1" cellspacing="1" style="font: 12px/normal Arial, Verdana, sans-serif; width: 200px; color: rgb(34, 34, 34); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; font-size-adjust: none; font-stretch: normal; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">
<caption>
<strong>International Names</strong></caption>
<tbody>
<tr>
<td>
Chinese</td>
<td>
<i>小紅帽</i></td>
</tr>
<tr>
<td>
Italian</td>
<td>
<i>Cappuccetto Rosso</i></td>
</tr>
<tr>
<td>
Spanish</td>
<td>
<i>Caperucita Roja</i></td>
</tr>
</tbody>
</table>
<p style="font: 12px/normal Arial, Verdana, sans-serif; color: rgb(34, 34, 34); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; white-space: normal; orphans: 2; widows: 2; font-size-adjust: none; font-stretch: normal; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;">
</p>
</div>
<p>
</p>
public static void Generate(string htmlText)
{
Document pdfDocument = new Document(PageSize.A4, 50, 25, 15, 10);
PdfWriter wri = PdfWriter.GetInstance(pdfDocument, new FileStream("test.pdf", FileMode.Create));
//wri.PageEvent = new PageEvent("");
pdfDocument.Open();
HTMLWorker htmlWorker = new HTMLWorker(pdfDocument);
TextReader htmlReader = new StringReader(htmlText);
htmlWorker.Parse(htmlReader);
pdfDocument.Close();
System.Diagnostics.Process.Start("test.pdf");
}