如何从spring boot中获取资源的字体路径?

时间:2016-09-15 09:04:28

标签: java spring-boot resources

我有春季启动应用程序。在resources/static我有字体CyrilicOld.TTF

如何获取此字体的路径?

public static final String FONT = "resources/static/CyrilicOld.TTF";

public static final String FONT = "/static/CyrilicOld.TTF";
...
 BaseFont bf = BaseFont.createFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, false, null, null, false);

我收到错误

java.io.IOException:resources / static / CyrilicOld.TTF未找到文件或资源。

如果BaseFont.createFont(this.getClass().getResource("/static/CyrilicOld.TTF").getPath(), BaseFont.IDENTITY_H, BaseFont.EMBEDDED, false, null, null, false)

错误

com.itextpdf.text.DocumentException: Table 'name' does not exist in /C:/gitProjects/BillingInvoiceGenerator/target/classes/static/CyrilicOld.TTF

0 个答案:

没有答案