Tal*_*eeb 2 c# pdfsharp migradoc
我正在尝试使用MigraDoc创建PDF文档,并且当表包含左缩进时,我遇到表边框问题.
我将数据传递给以下函数来呈现表.
public void AddTable(int _iNumberOfColumns, double leftInd)
{
table = section.AddTable();
if (leftInd != 0d)
{
table.Format.LeftIndent = leftInd;
}
for (int i = 0; i < _iNumberOfColumns; i++)
{
Column col = table.AddColumn();
}
}
Run Code Online (Sandbox Code Playgroud)
在上面的方法中,我传递参数的double值leftInd.我认为,这是问题的原因.
添加单元格的代码如下.我正在通过bool变量来判断是否需要显示单元格边框...(要添加一行我只是调用row = table.AddRow();)
public void AddColumn(int _iCellNum, int iColspan, double dCellWidthInPt, System.Drawing.Color color, bool bTopBorder, bool bLeftBorder, bool bBottomBorder, bool bRightBorder)
{
cell = row.Cells[_iCellNum];
if (iColspan > 0)
{
cell.MergeRight = iColspan-1;
for (int i = 0; i < iColspan; i++)
{
row.Cells[_iCellNum + i].Column.Width = new Unit(dCellWidthInPt, UnitType.Point);
}
}
else
{
cell.Column.Width = new Unit(dCellWidthInPt, UnitType.Point);
}
//bRightBorder = bLeftBorder = bTopBorder = bBottomBorder = true;
cell.Borders.Right.Visible = bRightBorder;
cell.Borders.Left.Visible = bLeftBorder;
cell.Borders.Top.Visible = bTopBorder;
cell.Borders.Bottom.Visible = bBottomBorder;
if (color!=null)
{
cell.Format.Shading.Color = new Color(color.A, color.R, color.G, color.B);
}
}
Run Code Online (Sandbox Code Playgroud)
如果我删除左缩进,则表格正确呈现(即左缩进不会将表格边框移动到左侧).
我无法更改页面的页边距,因为此表是具有不同页边距的文档的一部分.同样,我不能添加新的部分,因为这将添加一个新的页面.
版本:
Migradoc:1.32.3885.0
pdfSharp:1.32.2608.0
关于我可能遗失的任何建议?
编辑
这就是我想要实现的目标.与段落相比,了解表格从左侧开始的方式.要实现这一点,我正在尝试使用table.Format.LeftIndent

要缩进表格,请设置table.Rows.LeftIndent.负值也有效.
如在注释中所写,table.Format.LeftIndent设置表格单元格中所有段落的默认缩进,因此它会移动文本,但不会移动边框.
| 归档时间: |
|
| 查看次数: |
3324 次 |
| 最近记录: |