iText(锋利)边缘宽度

Vel*_*vic 14 c# margin itext itextsharp

看起来我不能将左边距设置为小于42pt宽度.我将它设置为0f但它总是以42pt结束.如果我将保证金设置为大于0的任何数字,它只会将其加到初始保证金42pt.我正在设置文档对象的边距:

iTextSharp.text.Rectangle docRect = new iTextSharp.text.Rectangle(pageWidth, pageHeight);
DC = new Document(docRect);
DC.SetMargins(0f, 0f, 0f, 0f);
Run Code Online (Sandbox Code Playgroud)

页面宽度和高度为6x9英寸.

最后我说:

42pt保证金|内容

我将不胜感激任何帮助.谢谢.

Vel*_*vic 13

我正在使用PdfPTable,问题是默认的PdfPTable水平对齐,这是CENTER.一旦我将对齐表格设置为左侧问题就消失了.

PdfPTable bTable = new PdfPTable(2);
bTable.HorizontalAlignment = Element.ALIGN_LEFT;
Run Code Online (Sandbox Code Playgroud)

谢谢,Velja


小智 9

好吧,我认为问题不同了.默认情况下,PdfPTable.LockedWidthproperty设置为false,PdfPTable.WidthPercentage等于80f.只要默认表格对齐,Center您就会得到您的保证金不被尊重的印象......但它们是!你需要设置PdfPTable.WidthPercentage = 100f.