PDF Box embed Fonts into existing PDF
So I have a pdf that I know needs the fonts embeded.
Here is the sample code to get this list.
PDDocument doc = PDDocument.load(new File(SRC)); List<PDFont> nonEmbeddedFonts = IntStream.range(0, doc.getNumberOfPages()).mapToObj(doc::getPage).flatMap(page -> { PDResources resources = page.getResources(); return StreamSupport.stream(resources.getFontNames().spliterator(), false).map(name -> { try { return resources.getFont(name); } catch (IOException e) { throw new RuntimeException(e); } }); }).filter(font -> !font.isEmbedded()).distinct().collect(Collectors.toList());
Does any one know of a simple way to embed these fonts? I know I can skip Times and Helvetica.
I have searched, but cannot find how to add these required fonts to an existing documnet.