pdfptable format problem?
- by raj
Hi,
I am using the code below to convert Html string to PDF.I notice that at times, it does print the tables in PDF but no styles(no border, color etc..).Below is the html string:
Can anyone suggest me where am I missing something?
Hi userThe Message ID 56456 has been assigned to you for Edition.
AUTO VERIFY FOR CONGROUP cccccccc FAILEDSSID ssss message, RPTD BY
rrrrSSID ssss RLD ll message, RPTD BY rrrrSSID
ssss DEV ddd message, RPTD BY rrrr Table 12 EMC9998W message format
<table style="border: medium solid #00FF00; width:100%; table-layout: auto; visibility: visible;"
title="EMC9998W message format">
<tr>
<td>
<b>Exception code</b></td>
<td>
<b>Meaning</b></td>
<td>
<b>Message format</b></td>
</tr>
<tr>
<td >
1460
</td>
<td>
DYNAMIC SPARING INVOKED</td>
<td>
1</td>
</tr>
<tr>
<td >
147D REMOTE
</td>
<td >
LINK DIRECTOR PROBLEM/FAILURE</td>
<td>
2</td>
</tr>
</table>
Where
MSG FORMAT 1
EMC9998W SSID ssss message, RPTD BY rrrr
MSG FORMAT 2
EMC9998W SSID ssss message, RPTD BY rrrr
MSG FORMAT 3
EMC9998W SSID ssss message, RPTD BY rrrr
private void HtmltoPdf(string s, Paragraph p,Document doc)
{
string strLine = s;
byte[] byteArray = Encoding.ASCII.GetBytes(strLine);
MemoryStream stream = new MemoryStream(byteArray);
StreamReader reader2 = new StreamReader(stream);
StringReader sr2 = new StringReader(reader2.ReadToEnd());
iTextSharp.text.html.simpleparser.HTMLWorker worker = new HTMLWorker(doc);
ArrayList elementlist = HTMLWorker.ParseToList(sr2, null);
Phrase ph = new Phrase();
for (int k = 0; k < elementlist.Count; ++k)
{
IElement ielement = (IElement)elementlist[k];
ArrayList chunks = ielement.Chunks;
if (ielement.Type == Element.PTABLE)
{
PdfPTable pt = (PdfPTable)ielement;
pt.DefaultCell.Border = 2;
PdfPTable t = new PdfPTable(1);//(new float[] {1f,1f,1f});
ph.Add(t);
PdfPCell pcell = new PdfPCell(new Paragraph(ph));
t.AddCell(pcell);
p.Add(t);
foreach (PdfPRow row in t.Rows)
{
}
}
else if (ielement.Type == Element.LIST)
{
}
else
{
ph.Clear();
ph.Add((IElement)elementlist[k]);
p.Add(new Paragraph(ph));
}
}
sr2.Close();
reader2.Close();
stream.Close();
}