我想加载一些字体并将它们与 Itext 一起使用。
我将字体保存在 /resources/font/
文件夹中。我尝试加载它们,这是
BaseFont verdana_bf = BaseFont.createFont("../resources/font/Calibri.ttf", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
但它不起作用,我收到以下错误:
java.io.IOException: ../resources/font/Calibri.ttf not found as file or resource.
如何从我的 beans 中的资源文件夹加载字体、图像?我还需要加载一些图像。
最佳答案
试试这个
Myclass.class.getResource("/font/calibri.ttf");
为此,需要将资源文件夹添加到构建路径中。
关于java - 从资源 bean 加载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18375842/