【问题标题】:How to use CSS proprieties in iTextSharp如何在 iTextSharp 中使用 CSS 属性
【发布时间】:2015-01-04 14:20:40
【问题描述】:

如何在 iTextSharp 中使用 CSS 属性,例如填充、单元格间距、背景颜色等...?

【问题讨论】:

    标签: asp.net .net itextsharp


    【解决方案1】:

    您可以使用PdfPTable

    PdfPTable headerTbl = new PdfPTable(2);   //Create table with 2 Cols
    headerTbl.SetWidths(new float[] { 4, 1 });    //1st having size of 4 and other 1
    headerTbl.TotalWidth = doc.PageSize.Width;   //Total Width of the table
    headerTbl.SpacingBefore = 20f;
    headerTbl.SpacingAfter = 30f;
    

    您可以在PdfPTable 中创建单元格 使用这个

    PdfPCell cell = new PdfPCell
    cell.Colspan = 3;                  //Colspan
    cell.HorizontalAlignment = 1; //0=Left, 1=Centre, 2=Right  Horizontal alignment 
    

    参考文献

    1. http://jwcooney.com/2013/08/23/itextsharp-pdfptable-basic-example/
    2. http://www.mikesdotnetting.com/article/86/itextsharp-introducing-tables
    3. http://www.mikesdotnetting.com/article/89/itextsharp-page-layout-with-columns

    【讨论】:

      【解决方案2】:

      有很多可用的 Java 示例来解释如何使用 XML Worker 和 CSS:http://itextpdf.com/sandbox/xmlworker

      其中一些示例是为回答有关 iTextSharp 的 StackOverflow 问题而编写的:

      在某种程度上,您的问题不符合 StackOverflow 的条件,因为它太宽泛(您没有展示您尝试过的内容)并且与其他问题重复。

      在创建新问题之前,请确保您查阅官方文档以及过去已回答(并接受)的 StackOverflow 问题。

      【讨论】:

      • 我想使用 Margin , padding , position of a text
      猜你喜欢
      • 1970-01-01
      • 2013-01-13
      • 1970-01-01
      • 1970-01-01
      • 2019-05-08
      • 2013-02-18
      • 2021-06-05
      • 1970-01-01
      • 2022-12-11
      相关资源
      最近更新 更多