我正在尝试使用 ITextSharp 将以下 HTML 导出到 PDF 中,但无论我尝试多少方式,边框都不会显示。
HTML 显示底部边框,但一旦导出为 PDF,它就会在翻译中丢失。我可以伪造底部边框的任何想法或方法?
谢谢
HTML:
<Table >
<tr>
<td class="test123">Test</td>
<td>Test</td>
</tr>
<tr>
<td>Test</td>
<td>Test</td>
</tr>
<tr>
<td>Test</td>
<td>Test</td>
</tr>
<tr>
<td>Test</td>
<td>Test</td>
</tr>
<tr>
<td>Test</td>
<td>Test</td>
</tr>
</Table>
C#:
string htmWrite = File.ReadAllText(Server.MapPath("~/Sample/Test.html"));
Document document = new Document();
StyleSheet css = new StyleSheet();
css.LoadStyle("test123", HtmlTags.HR, "1");
css.LoadStyle("test123", "border-bottom-style", "solid");
css.LoadStyle("test123", "border-bottom-width", "2px");
PdfWriter.GetInstance(document, new FileStream(@"C:\test\MySamplePDF.pdf", FileMode.Create));
document.Open();
iTextSharp.text.html.simpleparser.HTMLWorker hw =
new iTextSharp.text.html.simpleparser.HTMLWorker(document);
hw.SetStyleSheet(css);
hw.Parse(new StringReader(htmWrite));
document.Close();