4

有没有办法使用 iTextSharp 更改 PDF 中第二页的页边距?

我现在有:

Document document = new Document(PageSize.A4, 144f, 72f, 144f, 90f);

PdfWriter.GetInstance(document, ms);

/* first page content */

document.NewPage();
document.SetMargins(72f, 72f, 72f, 100f);

/* second page content */

但是,第二页上的边距是为第一页设置的边距。

4

1 回答 1

15

切换两行:

document.SetMargins(72f, 72f, 72f, 100f);
document.NewPage();

如文档所述,NewPage() 函数执行大量初始化,其中包括设置边距。因此,您需要在触发新页面之前而不是之后更改边距。

于 2012-09-07T15:54:00.957 回答