9

我正在使用这些代码...我的表格粘在文档的左侧,因为我没有在文档中提供任何填充...

Document document = new Document(PageSize.A4, 0, 0, 0, 0);

但现在我想给我的桌子留出边距和右边的边距......我用过

outerTable.SpacingBefore = 20f;

它没有用,然后我试图给我的单元格留下填充它也没有用..

outerCell.PaddingLeft = 20f;

现在我的桌子粘在左边……我要怎么移动它们?如果您尝试在 itextsharp 中移动表格,请提供帮助...

请检查附加的屏幕以供参考

在此处输入图像描述

4

2 回答 2

14

获得带有“左边距”的表格的最简单方法可能是将表格包装在一个段落中并在该段落上设置一个左缩进

Paragraph p = new Paragraph();
p.IndentationLeft = 100;
outerTable.HorizontalAlignment = Element.ALIGN_LEFT;
p.Add(outerTable);
document.Add(p);
于 2015-10-15T11:59:10.557 回答
-1

我试图从 document.left 位置移动表格,但它没有用,然后我试图在单元格中提供填充,即使它也不起作用....

然后我改变了 RoundRectangle 类

**rect.Left + 40f,**我在 RoundRectangle() 函数中更改了这一行,它对我有用.......

public class RoundedBorderLeft : IPdfPCellEvent
{
    public void CellLayout(PdfPCell cell, Rectangle rect, PdfContentByte[] canvas)
    {
        PdfContentByte cb = canvas[PdfPTable.BACKGROUNDCANVAS];
        cb.SetRGBColorStroke(42, 177, 195);
        cb.RoundRectangle(
         **rect.Left + 40f,**
         rect.Bottom + 1.5f,
        rect.Width - 20,
        rect.Height - 3, 4
         );

        cb.Stroke();
    }
}
于 2015-10-14T19:00:55.770 回答