Why does transforming PDF pages drop embedded fonts?

36 Views Asked by At

I maintain a program which resizes PDF pages which are larger than DIN A4.

This program uses PDFBox v3 (3.0.0 when I discovered the bug, an update to 3.0.2 did not help).

When resizing a page, PDFs with embedded fonts become unreadable. It seems that the transformation via the following code results in embedded fonts being dropped.

public void scale(PDDocument pdf, PDPage page) throws IOException {
    PDPageContentStream contentStream = new PDPageContentStream(pdf, page, PDPageContentStream.AppendMode.PREPEND, false);
    contentStream.transform(Matrix.getScaleInstance(factor, factor));
    contentStream.close();
    page.setMediaBox(targetMediaBox);
}

The input PDF has 3 Windows-related fonts, embedded as subsets.

When I replace this method with an empty implementation, then the output PDF still holds the original, embedded fonts.

Why does the transformation drop the fonts?

0

There are 0 best solutions below