I'm using PDFBox for converting pdf to image. Here I'm facing an issue with font. while converting pdf to image I could see the below warnings in my log
Using fallback font LiberationSans for Helvetica-Bold
Using fallback font LiberationSans for Helvetica
Using fallback font LiberationSans for base font Courier-Bold
Using fallback font LiberationSans for base font Courier
because of this issue the font styles are not working properly. In PDF I have set the Bold font but after converting it into image its not showing as Bold font.
But the same code is working in my local machine which is Windows and not working server environments (application is running in Docker container, which is centos rhel fedora).
Please find the below code which I'm using
boolean isDoubleSide =false; //this is method parameter
try (PDDocument pdDocument = Loader.loadPDF(new File("path/to/pdffile"))) {
PDFRenderer pdfRenderer = new PDFRenderer(pdDocument);
for (int page = 0; page < pdDocument.getNumberOfPages(); ++page) {
//Setting DPI as 203 for the image
BufferedImage bufferedImage = pdfRenderer.renderImageWithDPI(page, 203);
String imageFileName = (isDoubleSide ? Paths.get("path/to/imagefile", random_str + "_" + (page + 1) + ".jpeg").toString() :
Paths.get("path/to/imagefile", sOutFileNameBase + ".jpeg").toString());
ImageIO.write(bufferedImage, "jpeg", new File(imageFileName));
}
}
I'm using latest pdfbox version - 3.0.1
Attaching the PDF and Image for the reference
you can see the font is not properly displaying in Image. Please suggest some solution for this. Thanks.
Update
I have installed the fonts in the Container and tried that conversion, but still I could see the warnings in logs. In the below location that fonts are installed
/usr/share/fonts/msttcorefonts/
Attaching the screen shot


