iTextSharp XMLWorker 不适用于 css border-collapse: collapse;
iTextSharp XMLWorker does not work on css border-collapse: collapse;
HTML代码是:
<html>
<head>
<title>test</title>
<style type="text/css">
table {
border-collapse: collapse;
}
table tr td {
border: 2px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<td>row 1 cell 1</td>
<td>row 1 cell 2</td>
</tr>
<tr>
<td>row 2 cell 1</td>
<td>row 2 cell 2</td>
</tr>
</table>
</body>
</html>
但在输出的 PDF 文件中,内边框宽度加倍。
我正在使用最新的 iTextSharp 5.5.6 & XML Worker 5.5.6.
有人知道为什么吗?
谢谢!
狮子座
border-collapse: collapse;
看起来实际上并没有折叠边框,只是把它们真正地靠在一起,如果你仔细看,你会发现粗边框中间有一条细线。我只有在 Chrome 中打开我的 pdf 时才能看到它,而不是在我的 pdf-reader 中打开它。这是显示我的意思的屏幕截图:
所以我最终设置了 table 的上边框和左边框,以及 table 中单元格的右边框和下边框,这给了我想要的只有 1px 的细线而不是 2px,(又名:只有一行,而不是两行)
.tableborder {
border-collapse: collapse;
border-spacing: 0;
border-top-color: black;
border-top-width: 1px;
border-top-style: solid;
border-left-color: black;
border-left-width: 1px;
border-left-style: solid;
}
.tableborder th, .tableborder td {
border-collapse: collapse;
border-spacing: 0;
border-right-color: black;
border-right-width: 1px;
border-right-style: solid;
border-bottom-color: black;
border-bottom-width: 1px;
border-bottom-style: solid;
}
不漂亮,但它完成了工作 ;-)
之前:
之后:
@user538220,您在评论中提到了一个简单的解决方法,它是这样的,还是更好的解决方案?
下面的代码对我有用。
table th,td {
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-width: 0px;
}
HTML代码是:
<html>
<head>
<title>test</title>
<style type="text/css">
table {
border-collapse: collapse;
}
table tr td {
border: 2px solid black;
}
</style>
</head>
<body>
<table>
<tr>
<td>row 1 cell 1</td>
<td>row 1 cell 2</td>
</tr>
<tr>
<td>row 2 cell 1</td>
<td>row 2 cell 2</td>
</tr>
</table>
</body>
</html>
但在输出的 PDF 文件中,内边框宽度加倍。 我正在使用最新的 iTextSharp 5.5.6 & XML Worker 5.5.6.
有人知道为什么吗?
谢谢! 狮子座
border-collapse: collapse;
看起来实际上并没有折叠边框,只是把它们真正地靠在一起,如果你仔细看,你会发现粗边框中间有一条细线。我只有在 Chrome 中打开我的 pdf 时才能看到它,而不是在我的 pdf-reader 中打开它。这是显示我的意思的屏幕截图:
所以我最终设置了 table 的上边框和左边框,以及 table 中单元格的右边框和下边框,这给了我想要的只有 1px 的细线而不是 2px,(又名:只有一行,而不是两行)
.tableborder {
border-collapse: collapse;
border-spacing: 0;
border-top-color: black;
border-top-width: 1px;
border-top-style: solid;
border-left-color: black;
border-left-width: 1px;
border-left-style: solid;
}
.tableborder th, .tableborder td {
border-collapse: collapse;
border-spacing: 0;
border-right-color: black;
border-right-width: 1px;
border-right-style: solid;
border-bottom-color: black;
border-bottom-width: 1px;
border-bottom-style: solid;
}
不漂亮,但它完成了工作 ;-)
之前:
之后:
@user538220,您在评论中提到了一个简单的解决方法,它是这样的,还是更好的解决方案?
下面的代码对我有用。
table th,td {
border-right-width: 0px;
border-bottom-width: 0px;
border-left-width: 0px;
border-top-width: 0px;
}