iTextsharp landscape document

大憨熊 提交于 2019-11-30 04:50:36
Shoaib Shaikh

Try this

Document Doc = new Document(new Rectangle(288f, 144f), 10, 10, 10, 10);
Doc.SetPageSize(iTextSharp.text.PageSize.A4.Rotate());

you might also need this to expand a table to max width.

var _pdf_table = new PdfPTable(2); // table with two  columns
PdfPCell hc = new PdfPCell();
_pdf_table.WidthPercentage = 100; //table width to 100per
_pdf_table.SetTotalWidth(new float[] { 25, iTextSharp.text.PageSize.A4.Rotate().Width - 25 });// width of each column

You must make sure that when setting the page size you do it before a call to Doc.Open();

Regards.

No need to initialize the Document and reset the page size...

Document doc = new Document(iTextSharp.text.PageSize.A4.Rotate(), 10, 10, 10, 10);

...will do the trick.

(4.1.6.0)

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