gpt4 book ai didi

java - Apache PDFBox : Can I set font other than those present in PDType1Font

转载 作者:行者123 更新时间:2023-12-02 00:49:13 30 4
gpt4 key购买 nike

我在 PDType1Font 中只能看到 4 种带有变体的字体。有什么方法可以使用其他/自定义字体吗?

PDFType1Font 字体

  public static final PDType1Font TIMES_ROMAN = new PDType1Font("Times-Roman");
public static final PDType1Font TIMES_BOLD = new PDType1Font("Times-Bold");
public static final PDType1Font TIMES_ITALIC = new PDType1Font("Times-Italic");
public static final PDType1Font TIMES_BOLD_ITALIC = new PDType1Font("Times-BoldItalic");
public static final PDType1Font HELVETICA = new PDType1Font("Helvetica");
public static final PDType1Font HELVETICA_BOLD = new PDType1Font("Helvetica-Bold");
public static final PDType1Font HELVETICA_OBLIQUE = new PDType1Font("Helvetica-Oblique");
public static final PDType1Font HELVETICA_BOLD_OBLIQUE = new PDType1Font("Helvetica-BoldOblique");
public static final PDType1Font COURIER = new PDType1Font("Courier");
public static final PDType1Font COURIER_BOLD = new PDType1Font("Courier-Bold");
public static final PDType1Font COURIER_OBLIQUE = new PDType1Font("Courier-Oblique");
public static final PDType1Font COURIER_BOLD_OBLIQUE = new PDType1Font("Courier-BoldOblique");
public static final PDType1Font SYMBOL = new PDType1Font("Symbol");
public static final PDType1Font ZAPF_DINGBATS = new PDType1Font("ZapfDingbats");

最佳答案

您可以在 Apache PDFBox 2.0.* 中像这样加载 truetype 字体:

PDType0Font font = PDType0Font.load(document, new File("c:/windows/fonts/simhei.ttf"));

另见 API documentationEmbeddedFonts.java example .

关于java - Apache PDFBox : Can I set font other than those present in PDType1Font,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41313554/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com