如何在itextsharp中给表留下余量

ank*_*rma 7 c# itextsharp pdfptable

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

Document document = new Document(PageSize.A4, 0, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)

但现在我想给我的桌子留下保证金和保证金......我用了

outerTable.SpacingBefore = 20f;
Run Code Online (Sandbox Code Playgroud)

它不起作用然后我试图给我的细胞留下填充它也没有工作..

outerCell.PaddingLeft = 20f;
Run Code Online (Sandbox Code Playgroud)

现在我的桌子贴在左侧......我会怎样移动它们?如果你在itextsharp中尝试移动表,请帮助...

请查看附加屏幕以供参考

在此输入图像描述

rhe*_*ens 10

获取具有"左边距"的表的最简单方法可能是将表包装在段落中并在该段落上设置左缩进

Paragraph p = new Paragraph();
p.IndentationLeft = 100;
outerTable.HorizontalAlignment = Element.ALIGN_LEFT;
p.Add(outerTable);
document.Add(p);
Run Code Online (Sandbox Code Playgroud)


ank*_*rma -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();
    }
}
Run Code Online (Sandbox Code Playgroud)