Pdfbox Can't read the embedded font

Was trying to print pdf’s files using Lucee.
But encouraged some problems: printing with strange font.
So I tried to copy PDFBox libs to test.java file and to print same file:
This message appeared: “INFO org.apache.pdfbox.pdmodel.font.PDCIDFontType2Font - Can’t read the embedded font TimesNewRomanPS-BoldMT_PDF_Subset
INFO org.apache.pdfbox.pdmodel.font.PDType0Font - Using font SansSerif.plain instead of TimesNewRomanPS-BoldMT_PDF_Subset
INFO org.apache.pdfbox.util.PDFStreamEngine - unsupported/disabled operation: BDC”
And other same messages.

Lucee (Gelert) Os 5.3.7.43 (CFML Version 2016,0,03,300357)
Windows Server 2012

Looks like you haven’t got the fonts installed. I’m not sure, but I came across this post on so, that mentions there is a library called fontbox that should come as an additional package. Can you check if you have those installed?

This is a hard requirement even on AFC boxes.

either install the fonts and corresponding graphics libraries as needed (*NIX) or install the font(s) windows.

You can optionally, if you like pain try just providing font paths, but this usually leads to problems later down the line.

1 Like

Sorry, I didn’t mentioned that those are embedded fonts, so I think they should not be searched between system fonts,
Also I tried same library but downloaded from “apache” and it worked correctly.

test.pdf (144.8 KB)

Script that I used:

PDDocument document = PDDocument.load(new File("E:\\test.pdf"));
        PrintService myPrintService = findPrintService("WHSE_DEV");
        PrinterJob job = PrinterJob.getPrinterJob();
        job.setPrintService(myPrintService);
        document.silentPrint(job);
        /*For Apache lib*/  
        /*job.print();*/  
        document.close();
private static PrintService findPrintService(String printerName) {
        PrintService[] printServices = PrintServiceLookup.lookupPrintServices(null, null);
        for (PrintService printService : printServices) {
            if (printService.getName().trim().equals(printerName)) {
                return printService;
            }
        }
        return null;
    }

So, temporary resolved by adding apache as an OSGi Bundle and createObject("java","org.apache.pdfbox.pdmodel.PDDocument", "org.apache.pdfbox.app")

1 Like