0

Similar to this SO PDFBox - PDF to Image losing barcode

The PDF in question: https://drive.google.com/file/d/0B13zTPQR9uxscXRMWjhsZ0doa00/view?usp=sharing

There is minimal text, and a medium sized QR Code. I have tried many different solutions to convert this PDF page to an image using PDFBox/ImageIO, but so far the QR Code is always missing from the result.

When I use PDFBox's PDFImageWriter I get this log:

ColorSpace Pattern doesn't provide a non-stroking color, using white instead!

I'm thinking that pertains to the QR Code.

Is this expected behavior? Can someone else confirm PDFBox cannot copy the QR Code from this PDF? Is there any way to convert this to an image using Java or PDFBox?

Community
  • 1
  • 1
Don Cheadle
  • 5,224
  • 5
  • 39
  • 54
  • Your PDF has restricted access. What I can already tell you is that patterns aren't supported in 1.8.*, but they will be in the 2.0 version. – Tilman Hausherr Feb 18 '15 at 17:11
  • so the `ColorSpace Pattern doesn't provide a non-stroking color, using white instead!` signifies that PDFBox is finding a "pattern" on the source PDF? Is that different from an "image"? It's a print off from a webpage that had a QR Code and some text on it. I'll try to resolve the restricted access – Don Cheadle Feb 18 '15 at 17:12
  • I've updated the share-link. It should work now. – Don Cheadle Feb 18 '15 at 17:14
  • The QR-Code is an image that is part of a pattern. This is of course silly, because it could have been done directly as an image in the PDF, but that is how the creator of that PDF did it. – Tilman Hausherr Feb 18 '15 at 17:24
  • How could you tell it is `an image that is part of a pattern`? Also... what is the timeframe of `2.0` :) ? Six months off? One year off? Three? In the mean time I think I'll need to use Ghost4J to convert this PDF to an image, unless you have some other ideas. – Don Cheadle Feb 18 '15 at 18:02
  • I used PDFDebugger. The timeframe is a few months. (hopefully - we're all volunteers). Ghost4J sounds like an excellent idea. Ghostscript is a very good product. I've used their testfiles to uncover errors in PDFBox :-) – Tilman Hausherr Feb 18 '15 at 18:07
  • thanks to you and all the other PDFBox committers for your work and engagement in SO! – Don Cheadle Feb 18 '15 at 18:57
  • @TilmanHausherr hello, I just realized that Ghost4J is not friendly in threaded environments, which is how I would use it... now I'm getting desperate... do you know of any (preferably Java) open-souce/free libs that can convert a PDF to image such as the one in this question, excluding GhostScript? I trust your advice and I've been searching to no avail. If no free ones, any commercial suggestion? – Don Cheadle Feb 19 '15 at 00:12
  • Like I said, PDFBox can do it, but only the trunk version, i.e. it's more work (build from source, or get snapshot libraries, and read about the API from the source examples). Commercial products with free evaluations are ICEPdf and JPedal. ICEPdf has a free version but it isn't good with fonts. – Tilman Hausherr Feb 19 '15 at 07:12
  • Until PDFBox 2.x is more stable... I checked out the less discussed (for some reason?) PDF-Renderer and did [similar to this answer](http://stackoverflow.com/questions/21064270/how-to-increase-the-resolution-of-image-in-pdf-renderer#answer-21071630) to convert PDF to image. It seems to work – Don Cheadle Feb 19 '15 at 17:40

0 Answers0