PdfFontFactory.createFont can read otf font files from the assets directory by using the following code:

AssetManager assetManager = getAssets();
InputStream inputStream = assetManager.open("font.otf");
PdfFont font = PdfFontFactory.createFont(inputStream, PdfEncodings.IDENTITY_H, true);

In this code, we first get an instance of the AssetManager to access the assets directory. We then open the font.otf file as an InputStream. Finally, we use PdfFontFactory.createFont to create a PdfFont object from the InputStream, specifying the encoding as IDENTITY_H and the embedded flag as true

PdfFontFactorycreateFont 读取assets目录下的otf字体文件

原文地址: https://www.cveoy.top/t/topic/gtI6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录