When PDF(fillable) is converted to Jpeg using Pdfbox.The tick in checkbox is converted to a box character
WARN [org.apache.pdfbox.rendering.Type1Glyph2D] No glyph for code 52 (a20) in font ZapfDingbats
public static void main(String[] args) throws Exception{
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);
}
}
How do i set the font to the PDF to image code ?
The problem may related with fonts. (Zapf Dingbats and/or MS Gothic may be missing)
Can you try to install missing fonts in a directory "./fonts" or "/usr/share/fonts" for Linux,
"/Windows/Fonts" for Windows