iTextsharp landscape document

前端 未结 2 2006
粉色の甜心
粉色の甜心 2020-12-29 05:00

I am trying to create Landscape PDF using iTextSharp but It is still showing portrait. I am using following code with rotate:

Document document = new Documen         


        
2条回答
  •  醉酒成梦
    2020-12-29 05:29

    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.

提交回复
热议问题