8

I am working on a project in which I need to analyze images; the primary source of these images is the webcam, but recently we've been ask to add support for uploaded files and scanners. This is fine, for the most part, except they'd like us to be able to use documents in PDF format.

I need a raw pixel bitmap for the processing; on Mac, I can use CoreGraphics to load the PDF into an image buffer, but I'm not sure how to pull this off on Windows.

To summarize: I need a C++ library (preferably with a license like BSD since this is closed-source, but potentially LGPL could work) that I can use to open a PDF file and export each page as a rendered image buffer bitmap.

taxilian
  • 14,229
  • 4
  • 34
  • 73
  • @taxillian did you come up with a solution for this? What did you end up using? – Jesse Pepper Oct 09 '15 at 03:53
  • 1
    I never did find a good solution, I'm afraid. I was actually using it in a plugin, and I now use pdf.js to render it in the browser and then send the image data to the plugin – taxilian Oct 12 '15 at 16:22

2 Answers2

6

ImageMagick. Far and away the best library for reading and writing as many formats as possible http://www.imagemagick.org/script/index.php

totowtwo
  • 2,101
  • 1
  • 14
  • 21
  • Hmm. I didn't realize ImageMagick could read PDF files. That's a definite possibility, though ImageMagick is a huge dependency to add to a project; I'll consider this one. thanks. – taxilian Jul 06 '11 at 22:51
  • 3
    I believe that ImageMagick uses Ghostscript for the conversion. I see you've considered Ghostscript, have you also considered MuPDF ? It only handles PDF, unlike GS, but has a much smaller footprint. It is used in SumatraPDF and in library form in other places. – KenS Jul 08 '11 at 07:15
  • if I end up having to start a process I'll take a look at MuPDF as an option. thanks! – taxilian Jul 08 '11 at 21:42
3

Example:

pdf2swf --pages 1 -T9 PDF_FILE.pdf -o temp.swf
swfrender temp.swf --output 1.png
  • With poppler

Example using Qt http://bit.ly/8UksK6

Rodrigo
  • 135
  • 4
  • 45
  • 107
  • Hmm; I guess I could call this from C++, but I'd really prefer to use a library that I can use directly in the app; it's actually a FireBreath browser plugin, which means starting other processes can be... problematic. I have also considered using Ghostscript in a way similar to what you suggest. – taxilian Jul 06 '11 at 22:51