pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jon Wu <...@wuservices.com>
Subject Black background rendering an ARGB BufferedImage after upgrading to recent 2.0.0
Date Thu, 27 Aug 2015 00:56:38 GMT
I'm getting a solid black background trying to convert a PDF to an ARGB
BufferedImage after updating from 2.0.0-20150209.214830-1071 to
2.0.0-20150826.181706-1650. Is there any recent change that could be
causing that?

--- Working OK on 20150209 ---

On 20150209, I had this and it worked fine - producing a transparent image
once I converted to PNG using code like this:

    BufferedImage result = new BufferedImage(width, height,
    Graphics2D graphics = result.createGraphics();
    new PageDrawer(new PDFRenderer(document), page).drawPage(graphics,

--- Updating to latest broke things ---

When updating to the current snapshot, I simply changed the last line to
use the new API:

    new PDFRenderer(document).renderPageToGraphics(0, graphics);

Unfortunately, with this change + the newer version, I get a black
background on my BufferedImage instead of a transparent one.

I get the same issue when I do the following:

    new PDFRenderer(document).renderImageWithDPI(0, resolution,

I'd normally think there's something wrong with my code, but this is the
only change I've made. Is there something wrong with the rendering in the
latest PDFBox?

--- Workaround ---

With renderPageToGraphics, if I call graphics.setBackground(new Color(0, 0,
0, 0)); before rendering the page, I avoid this issue. However, it seems
like this shouldn't be necessary.

-- Cropping when rendering? ---

As a side note, I sort of miss being able to conveniently crop the PDF
before rendering with a rectangle, but maybe I should just be doing that in
Graphics2D land.


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message