iTextSharp table width 100% of page

前端 未结 5 1644
小蘑菇
小蘑菇 2021-02-12 12:14

I\'m trying to add a table to a document using iTextSharp. Here is an example:

Document document = new Document(PageSize.LETTER,72, 72, 72, 72);
PdfWriter writer         


        
相关标签:
5条回答
  • 2021-02-12 12:50

    The WidthPercentage property is no longer available in iText7. Use the following instead

    table.SetWidth(new UnitValue(UnitValue.PERCENT, 100));
    
    0 讨论(0)
  • 2021-02-12 12:53

    In Java table.setWidthPercentage(100); Works in 5.5.8 version

    0 讨论(0)
  • 2021-02-12 12:54

    In iTextSharp latest version (5.0.4) the PdfPTable has a WidthPercentage property.

    To set a static value the property is TotalWidth.

    0 讨论(0)
  • 2021-02-12 13:02

    Users can also set table width by Percentage.

    t.WidthPercentage = 100f;
    
    0 讨论(0)
  • 2021-02-12 13:09

    Figured it out. Apparently table.Width is a percent and not the width in pixels. So using:

    table.Width = 100;
    

    Worked like a charm.

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