Hi I’m working on a japanese pdf document with a font not embed.
I have not the font on my system but an ‘equivalent font’ (same code page ranges handled) : Meiryo.
I tried to convert the document to a png file. But I glyphs are not found.
Could you please help me to found a way to make it work?
We are considering bying a license for aspose pdf if this behavior is available.
My code :
public class AsposeRenderer {
public static void main(String[] args) throws Exception{
FontRepository.addLocalFontPath("/home/pierres/tmp/fontfolder");
boolean replaceNotFoundFonts = FontRepository.isReplaceNotFoundFonts();
FontRepository.setReplaceNotFoundFonts(true);
String filename = “/home/pierres/Downloads/payslip-20190920.pdf”;
Path path = Paths.get(filename);
Document doc = new Document(filename);
Page item = doc.getPages().get_Item(1);
FontCollection fonts = item.getResources().getFonts();
PngDevice renderer = new PngDevice();
BufferedImage bufferedImage = renderer.processToBufferedImage(item);
File output = new File(path.getParent().toFile(), String.format(“preview%s.png”,System.currentTimeMillis()));
ImageIO.write(bufferedImage,“png”, output);
System.out.println("Outputfile : "+output.getCanonicalPath());
}
}