Class PDFUtils

java.lang.Object
com.sankcrm.erp.contract.infrastructure.PDFUtils

public class PDFUtils extends Object
PDF工具
Since:
1.0.0
Author:
zhsxin
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.itextpdf.kernel.geom.Rectangle
    addText(com.itextpdf.kernel.pdf.canvas.PdfCanvas page, com.itextpdf.kernel.geom.Rectangle rect, com.itextpdf.layout.element.Paragraph paragraph)
     
    static com.itextpdf.kernel.geom.Rectangle
    addText(com.itextpdf.kernel.pdf.canvas.PdfCanvas page, com.itextpdf.kernel.geom.Rectangle rect, String text, com.itextpdf.kernel.font.PdfFont font, float fontSize)
     
    static int
    calculateLines(String text, float width, float fontSize, com.itextpdf.kernel.font.PdfFont font)
    计算文本需要多少行才能显示完全
    static com.itextpdf.kernel.font.PdfFont
     
    static com.itextpdf.kernel.font.PdfFont
    matchingFont(com.itextpdf.kernel.font.PdfFont templateFont)
    Load a complete local font matching a font already used by the template.
    static void
    resetRectangle(com.itextpdf.forms.fields.PdfTextFormField textField, String text)
    配置文本字段的字体和溢出策略。PDF 是固定版式,运行时不能根据值长度改变模板字段的位置或尺寸, 否则字段会覆盖相邻行。短文本沿用模板字号,只有内容无法放进原字段时才交给 iText 自动缩放。

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PDFUtils

      public PDFUtils()
  • Method Details

    • defFont

      public static com.itextpdf.kernel.font.PdfFont defFont()
    • matchingFont

      public static com.itextpdf.kernel.font.PdfFont matchingFont(com.itextpdf.kernel.font.PdfFont templateFont)
      Load a complete local font matching a font already used by the template. Template fonts are commonly embedded as subsets and cannot safely render arbitrary replacement text, so reuse their family rather than the subset itself. Fall back to the established default font when the family is unknown.
    • addText

      public static com.itextpdf.kernel.geom.Rectangle addText(com.itextpdf.kernel.pdf.canvas.PdfCanvas page, com.itextpdf.kernel.geom.Rectangle rect, String text, com.itextpdf.kernel.font.PdfFont font, float fontSize)
    • addText

      public static com.itextpdf.kernel.geom.Rectangle addText(com.itextpdf.kernel.pdf.canvas.PdfCanvas page, com.itextpdf.kernel.geom.Rectangle rect, com.itextpdf.layout.element.Paragraph paragraph)
    • resetRectangle

      public static void resetRectangle(com.itextpdf.forms.fields.PdfTextFormField textField, String text)
      配置文本字段的字体和溢出策略。PDF 是固定版式,运行时不能根据值长度改变模板字段的位置或尺寸, 否则字段会覆盖相邻行。短文本沿用模板字号,只有内容无法放进原字段时才交给 iText 自动缩放。
      Parameters:
      textField - 文本字段
      text - 文本内容
    • calculateLines

      public static int calculateLines(String text, float width, float fontSize, com.itextpdf.kernel.font.PdfFont font)
      计算文本需要多少行才能显示完全
      Parameters:
      text - 文本内容
      width - 可用宽度
      fontSize - 字体大小
      Returns:
      行数