【发布时间】:2013-11-15 10:31:18
【问题描述】:
我有 iTextSharp 5.4.4 (nuget) 并且有一张漂亮的桌子,上面有条形码 (ean13) 和下面的文字。 我有特定的表格单元格高度(和单元格宽度),因为我想将 pdf 打印到带有贴纸的 A4 纸上。 这是当前的布局:
如您所见,ean13 代码与下面的文本之间存在相当大的差距。 这是我的 C# 代码:
PdfPCell c = new PdfPCell();
c.FixedHeight = 21.2f * postScriptPointsPerMilimeter; // to get to accurate milimeters
c.HorizontalAlignment = Element.ALIGN_CENTER;
Paragraph p = new Paragraph();
p.Font.Size = 6;
Chunk code = new Chunk(dr["productcode"].ToString());
p.Alignment = Element.ALIGN_CENTER;
p.Add(code);
BarcodeEAN ean13 = new BarcodeEAN();
ean13.CodeType = BarcodeEAN.EAN13;
ean13.Code = dr["ProductEan13"].ToString();
ean13.BarHeight = 4.0f * postScriptPointsPerMilimeter;
var a = ean13.CreateImageWithBarcode(cb, null, null);
a.ScalePercent(90);
c.AddElement(a);
c.AddElement(p);
t.AddCell(c);
我的问题是减少条形码和文本之间的空间。我看不出它是否与条形码的页边距或段落的页边距或两者有关......很难排除故障。
【问题讨论】:
标签: layout pdf-generation itextsharp