pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matt Pryor <pr...@international-presence.com>
Subject Difference in fonts between PDFBox 1.8 and 2.0
Date Thu, 22 Mar 2018 19:20:19 GMT
Hello

We use PDFBox in our software which runs on IBM system i / AS400s to
convert PDF files to TIFFs. We have many users who are on older JVMs, such
as 1.5, so have to maintain code for them as well as people on newer JVMs.

We recently swapped over to PDFBox 2.0.8 for users who are on JRE 1.6 or
above and have had complaints from customers about the fonts changing. The
issue does not occur when I test in a Windows environment but does on the
iSeries JVM.

I have attached two sample TIFF files, the first is generated with PDFBox
1.8 and the second with PDFBox 2.0.8 (named accordingly)

I put logging output in the SetFontAndSize class and confirm that it's
using "Courier-Bold" in 2.0.8, but it looks nothing like Courier.

This is the code to create a BufferedImage from the PDF pages, which then
gets inserted into the TIFF file

PDFBox 1.8 code:
==============

    int imageType = BufferedImage.TYPE_INT_RGB;

    int resolution = (int) PRINTER_RESOLUTION;

    PDDocument document = PDDocument.load( pdf );

    List<PDPage> pages =

        (List <PDPage>) document.getDocumentCatalog().getAllPages();

    int pagesSize = pages.size();

    for (int i = 1 - 1; i < pagesSize; i++) {

        PDPage page = pages.get(i);

        BufferedImage image = page.convertToImage(imageType, resolution);

….

    }


PDFBox 2.0.8 code:
================

    PDDocument document = PDDocument.load( pdf );
    PDPageTree pagetree = document.getDocumentCatalog().getPages();
    int pagesSize = pagetree.getCount();
    PDFRenderer pdfRenderer = new PDFRenderer(document);
    for (int i = 1 - 1; i < pagesSize; i++) {
        PDPage page = pagetree.get(i);
        BufferedImage image = pdfRenderer.renderImageWithDPI(i, 200,
ImageType.RGB);
        ...
    }

I'm hoping someone might be able to point me in the direction of what's
going wrong or perhaps give me a better idea about how PDFBox generates or
gets fonts. I realise the platform that I'm running on is rather obscure!

Many thanks in advance
-- 
Matt Pryor

The International Presence Group of Companies

EMAIL: pryor@presencebpm.com

URL: www.International-presence.com

Mime
View raw message