zoukankan      html  css  js  c++  java
  • 设置PdfPTable与标题间的距离

    使用itextsharp生成PDF时,需要改变标题与文档中添加的PdfPTable间距离,改变SpacingBefore值不起作用,查了下这方面的知识较少,自己跟踪代码,找到了设置位置是在使用iTextSharp.text.Document时,如:

    using iTextSharp.text.pdf;
    using iTextSharp.text;

    //创建Pdf文档
    m_Doc = new Document(DefaultPageSize, 40f, 40f, 100f, 20f);  

    其中100f就是内容距上边距的距离 ,若设置200f 则标题与文档中生成的PdfPTable间距离变大。

    上面方法适合于改变 模板。

    当然也可以改变单个PDF文档,不过还有一个间接的方法改变单个PDF文档中标题与文档中添加的PdfPTable间距离:

    在添加的PdfPTable最上方添加不显示边框的字符串为空的行(一排单元格)。如下:

    PdfPCell cell;

    String gcInfo = string.Empty;
    font = ITextPdfHelper.GetFont(12);
    cell = new PdfPCell(new Paragraph(gcInfo, font));
    cell.HorizontalAlignment = Element.ALIGN_LEFT;
    cell.VerticalAlignment = Element.ALIGN_BOTTOM;
    cell.Border = Rectangle.NO_BORDER;
    cell.Colspan = 9; // 标段名称 占一行
    pdfTable.AddCell(cell);


    String bdInfo = string.Empty;
    font = ITextPdfHelper.GetFont(12);
    cell = new PdfPCell(new Paragraph(bdInfo, font));
    cell.HorizontalAlignment = Element.ALIGN_LEFT;
    cell.VerticalAlignment = Element.ALIGN_BOTTOM;
    cell.Border = Rectangle.NO_BORDER;
    cell.Colspan = 9; //2014-10-13 标段名称 占一行
    pdfTable.AddCell(cell);

  • 相关阅读:
    Codeforces 1255B Fridge Lockers
    Codeforces 1255A Changing Volume
    Codeforces 1255A Changing Volume
    leetcode 112. 路径总和
    leetcode 129. 求根到叶子节点数字之和
    leetcode 404. 左叶子之和
    leetcode 104. 二叉树的最大深度
    leetcode 235. 二叉搜索树的最近公共祖先
    450. Delete Node in a BST
    树的c++实现--建立一棵树
  • 原文地址:https://www.cnblogs.com/shenchao/p/4037079.html
Copyright © 2011-2022 走看看