itextsharp html 到 pdf 创建没有边框

Kir*_*chi 1 html c# border itextsharp

我使用 iTextSharp(在 SharePoint 上,但我希望这无关紧要)将 HTML 文档转换为 PDF。到目前为止,我无法在元素周围获得任何边框。我该怎么做呢?这不支持吗?

我尝试过的事情:

  // in c# code
StyleSheet styles = new iTextSharp.text.html.simpleparser.StyleSheet();
styles.LoadStyle("borderCls", "border-style", "solid"); // <td class="borderCls">
styles.LoadStyle("borderCls", "border-width", "1px");
styles.LoadStyle("borderCls", "border-color", "#000");
  //
styles.LoadStyle("borderCls", "border", "solid 1px #000");

  // in html
<td style="border:solid 1px #000">
  //
<td border="1">
  //
<td style="border-style:solid;border-width:1px">
Run Code Online (Sandbox Code Playgroud)

但这些都不起作用。我只是无法让 iTextSharp 创建任何边框。

更新:也可以只在特定的一侧定义一个边框吗?

Man*_*rma 5

使用此代码。

<table border="1">
Run Code Online (Sandbox Code Playgroud)

确定其工作。但是solid 和px 在html 到pdf 中不起作用。