Class PDFUtils
java.lang.Object
com.sankcrm.erp.contract.infrastructure.PDFUtils
PDF工具
- Since:
- 1.0.0
- Author:
- zhsxin
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.itextpdf.kernel.geom.RectangleaddText(com.itextpdf.kernel.pdf.canvas.PdfCanvas page, com.itextpdf.kernel.geom.Rectangle rect, com.itextpdf.layout.element.Paragraph paragraph) static com.itextpdf.kernel.geom.RectangleaddText(com.itextpdf.kernel.pdf.canvas.PdfCanvas page, com.itextpdf.kernel.geom.Rectangle rect, String text, com.itextpdf.kernel.font.PdfFont font, float fontSize) static intcalculateLines(String text, float width, float fontSize, com.itextpdf.kernel.font.PdfFont font) 计算文本需要多少行才能显示完全static com.itextpdf.kernel.font.PdfFontdefFont()static com.itextpdf.kernel.font.PdfFontmatchingFont(com.itextpdf.kernel.font.PdfFont templateFont) Load a complete local font matching a font already used by the template.static voidresetRectangle(com.itextpdf.forms.fields.PdfTextFormField textField, String text) 配置文本字段的字体和溢出策略。PDF 是固定版式,运行时不能根据值长度改变模板字段的位置或尺寸, 否则字段会覆盖相邻行。短文本沿用模板字号,只有内容无法放进原字段时才交给 iText 自动缩放。
-
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:
- 行数
-