iTextSharp: table in landscape

微笑、不失礼 提交于 2019-11-30 23:25:09

You can set the document size and it will affect the next pages. Some snippets:

Set up your document somewhere (you know that already):

  var document = new Document();
  PdfWriter pdfWriter = PdfWriter.GetInstance(
    document, new FileStream(destinationFile, FileMode.Create)
  );
  pdfWriter.SetFullCompression();
  pdfWriter.StrictImageSequence = true;
  pdfWriter.SetLinearPageMode();           

Now loop over your pages (you probably do that as well already) and decide what page size you want per page:

 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();
    }
  }
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!