[英]itextsharp html to pdf creates no borders
我使用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">
但是这些没有用。 我只是无法让iTextSharp创建任何边框。
更新 :还有可能只在特定的一侧定义边框吗?
使用此代码。
<table border="1">
肯定它正在徘徊。 但solid和px在html到pdf中不起作用。
您可以使用桌子边框,并在此处提供一些示例: http : //demo.itextsupport.com/xmlworker/
XMLWorker CSS和HTMLsupport文档http://demo.itextsupport.com/xmlworker/itextdoc/index.html
如果要仅使用css设置表的左边框,请使用以下代码:
td.black-left-border {
border: 0; /*First set all the borders to 0, then set the desired borders width*/
border-color: black;
border-left-width: 1px; /*PDF*/
border-left-style: solid;
}
您还可以设置不同颜色的边框:
td.black-left-border-blue-bottom-border {
border: 0;
border-left-color: black;
border-bottom-color: blue;
border-left-width: 1px;
border-bottom-width: 1px;
border-left-style: solid;
border-bottom-style: solid;
}
也许浏览器不会应用这些样式,但iTextSharp会应用。 如您所见,您必须在css属性中非常明确。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.