我正在使用 iTextSharp 生成大型文档。在本文档中,我想要一些横向的特定页面。其余的都是肖像。有谁知道我该怎么做? 开始一个新文档不是一种选择。
谢谢!
最佳答案
您可以设置文档大小,它会影响下一页。一些片段:
在某处设置您的文档(您已经知道):
var document = new Document();
PdfWriter pdfWriter = PdfWriter.GetInstance(
document, new FileStream(destinationFile, FileMode.Create)
);
pdfWriter.SetFullCompression();
pdfWriter.StrictImageSequence = true;
pdfWriter.SetLinearPageMode();
现在遍历你的页面(你可能已经这样做了)并决定每页你想要的页面大小:
for (int pageIndex = 1; pageIndex <= pageCount; pageIndex++) {
// Define the page size here, _before_ you start the page.
// You can easily switch from landscape to portrait to whatever
document.SetPageSize(new Rectangle(600, 800));
if (document.IsOpen()) {
document.NewPage();
} else {
document.Open();
}
}
关于c# - iTextSharp : table in landscape,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2019246/