Hi Jon,

https://issues.apache.org/jira/browse/PDFBOX-2949
created. I'm somewhat undecided about what to do. Lets see what John Hewson thinks.

Tilman

Am 28.08.2015 um 19:30 schrieb Jon Wu:
Sorry about that, here's the files:
https://drive.google.com/folderview?id=0B0sKf6PlTlwgfjhxdDRTSVd1NFZiQXVzbzZ5bDBZc3hzZDNoeWhnTUp6ZS0zbElZMi1QUk0&usp=sharing

On Fri, Aug 28, 2015 at 12:25 AM, Tilman Hausherr <[email protected]>
wrote:

Am 28.08.2015 um 07:57 schrieb Jon Wu:

Thanks for the guidance on not creating a PageDrawer. It was already in
our codebase like that and I was adapting without checking examples until
now. Since it was wrong, nevermind what I had before except to say that I
was generating a transparent BufferedImage with it in 1.x and 2.0.0 from
Feb.

Are both of these correct way to use PDFBox? With either of these on the
latest SNAPSHOT, I'm getting a black background.

1. new PDFRenderer(document).renderPageToGraphics(0, graphics);
2. new PDFRenderer(document).renderImageWithDPI(0, resolution,
ImageType.ARGB);

With #1, I was able to make it work by writing a transparent background
before renderPageToGraphics, but that is ugly of course. There's nothing
special about the PDF and it works fine with the latest pdfbox-app.jar.

Every PDF is unique... upload your PDF somewhere, binary attachments don't
work on the mailing list.

Tilman


Tilman, yes setting a black transparent background doesn't really make
sense as a workaround, but given that I'm basically writing a couple lines
and I'm using ARGB, I don't know what else could be wrong.

For reference, I attached the PNG I get with my general code on 1.x and
2.0.0 from Feb (expected), and the black image converted to PNG that I'm
getting with 2.0.0 latest. The PDF to generate these is attached too.


On Wed, Aug 26, 2015 at 11:45 PM, Tilman Hausherr <[email protected]
<mailto:[email protected]>> wrote:

     Am 27.08.2015 um 02:56 schrieb Jon Wu:

         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
         <tel: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,
         BufferedImage.TYPE_INT_ARGB);
              Graphics2D graphics = result.createGraphics();
              new PageDrawer(new PDFRenderer(document),
         page).drawPage(graphics,
         mediaBox);


     That isn't the way you're supposed to use PDFBox.


         --- 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,
         ImageType.ARGB);

         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?


     The best would be that you upload your PDF somewhere so we can
     have a look at it.

     The current code starts with a default bufferedimage of the type
     you pass. Non ARGB images are assigned a white background, the
     other images are kept as is.


         --- 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.


     So you're setting a black transparent background.


         -- 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.


     Tilman


         Thanks,
         Jon



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




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




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

Reply via email to