我正在使用Itextsharp。
doc.SetMargins(36, 36, 36, 36);
doc.NewPage();
writer.PageEvent = new PDFPageEvent();
int horizontalMarginForColumn = 54;
int bottomMarginForColumn = 72;
int topMarginForColumn = 112;
int interval = 8;
Rectangle pageNumberLeftLocation = new Rectangle(horizontalMarginForColumn, doc.PageSize.Height - 36, horizontalMarginForColumn + 36, doc.PageSize.Height);
paragraph = new Paragraph();
paragraph.SpacingBefore = 0;
paragraph.Alignment = Element.ALIGN_LEFT;
line = new LineSeparator(1f, 100f, BaseColor.BLACK, 0, 0f);
line.Alignment = Element.ALIGN_CENTER;
paragraph.Add(new Chunk(line));
paragraph.Add(Chunk.NEWLINE);
chunk = new Chunk(" Index", FontFactory.GetFont("Arial", 15, Font.BOLD));
chunk.setLineHeight(23);
paragraph.Add(chunk);
paragraph.Add(Chunk.NEWLINE);
paragraph.Add(new Chunk(line));
doc.Add(paragraph);
writer.DirectContent.SetColorStroke(BaseColor.BLUE);
writer.DirectContent.Rectangle(pageNumberLeftLocation.Left, pageNumberLeftLocation.Bottom, pageNumberLeftLocation.Width, pageNumberLeftLocation.Height);
writer.DirectContent.Stroke();
页面的上边距是36,矩形的高度是36.所以我假设矩形的底线和段落的开头是黑线,sholud在同一垂直位置。但是你可以看到,两者之间有一些空间。为什么是这样?谢谢。