Hello Matt,

Your attachments don't go through. But what I can tell you is that 1.8 had many errors in rendering, so the many differences are usually not a bug, but an improvement.

The case you describe ("but it looks nothing like Courier") could be because of missing fonts on your system so the "Liberation Sans" fallback is used. Try to have Courier, Arial/Helvetica, Times, Symbol and Zapf Dingats in your font directory. Another possibility is that fonts are not found. Please post the .pdfbox.cache from the user directory. Does this file have all the fonts on your system? If not, please tell what directories to search.

To find out more, have a look at
\fontbox\src\main\java\org\apache\fontbox\util\autodetect\UnixFontDirFinder.java and the other "finders" in the package.

It has

        return new String[] { System.getProperty("user.home") + "/.fonts", // user
                "/usr/local/fonts", // local
                "/usr/local/share/fonts", // local shared
                "/usr/share/fonts", // system
                "/usr/X11R6/lib/X11/fonts" // X
        };

If that one isn't enough, please tell where the fonts are, and tell also what System.getProperty("os.name") returns.

Tilman

Am 22.03.2018 um 20:24 schrieb Matt Pryor:
Hello

I'm resending this from the address I'm subscribed with, so hope it doesn't appear twice.

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:[email protected] <mailto:[email protected]>

URL:www.International-presence.com <http://www.international-presence.com/>


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]


Reply via email to