使用Pdfbox将PDF(可填充)转换为Jpeg时,复选框中的对勾会转换为方框字符
WARN [org.apache.pdfbox.rendering.Type1Glyph2D]代码52没有字形 ZapfDingbats字体中显示(a20)
公共静态void main(String [] args)引发异常{
try (final PDDocument document = PDDocument.load(new File("C:\\Users\\priyadarshini.s\\Downloads\\ADWE3244_Merge(1).pdf"))){
ClassLoader classloader = Thread.currentThread().getContextClassLoader();
InputStream is = classloader.getResourceAsStream("zapfdingbats.ttf");
PDFRenderer pdfRenderer = new PDFRenderer(document);
PDFont font = PDType0Font.load(document,is); //PDTrueTypeFont.loadTTF(document, new File( "c:/arial.ttf" ));
//font.s sesetWidths(PDType1Font.HELVETICA.getWidths());
for (int page = 0; page < document.getNumberOfPages(); ++page)
{
BufferedImage bim = pdfRenderer.renderImageWithDPI(page, 300, ImageType.RGB);
String fileName = OUTPUT_DIR + "image-" + page + ".jpg";
ImageIOUtil.writeImage(bim, fileName, 300);
}
document.close();
} catch (IOException e){
System.err.println("Exception while trying to create pdf document - " + e);
}
}
如何将字体设置为图像代码的PDF?
答案 0 :(得分:1)
该问题可能与字体有关。 (Zapf Dingbats和/或MS Gothic可能会丢失)
您是否可以尝试在Linux的目录“ ./fonts”或“ / usr / share / fonts”中安装缺少的字体,
“ / Windows /字体”(适用于Windows)