iTextsharp landscape document

前端 未结 2 1975
粉色の甜心
粉色の甜心 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.

    0 讨论(0)
  • 2020-12-29 05:39

    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)

    0 讨论(0)
提交回复
热议问题