2

I am trying to make project of a web app that will check the colour of the PDF document. My preferred language is PHP.

At the begining I've been thinking about GD, but this only refer to images (jpg, png, gif). Nothing for PDF. For images I am going to use some method similar to this: Get image color.

So does anyone know some method, library (opensource), or something else to make such app? I can't find any examples on the web.

Community
  • 1
  • 1
sebap123
  • 2,541
  • 6
  • 45
  • 81
  • 1
    What exactly do you mean by the colour of a PDF document? The average of the entire thing? The average of only the images? Either way, you'll probably be best off converting the PDF into an image, and then using the GD method. For that, "PDF to image" should yield good hits here on SO – Pekka Jul 08 '12 at 16:28
  • Thank you very much. You should give it as an answer. I was thinking about getting the number of each colour, but converting PDF to image will be the best option. – sebap123 Jul 08 '12 at 16:33
  • No problem. I added it as an answer. – Pekka Jul 08 '12 at 16:35

1 Answers1

2

You'll probably be best off converting the PDF into an image, and then using the same method you're using for images. In addition to being easy to do, that will also guarantee consistent results.

However, converting a PDF file to an image is not something that PHP alone is well-equipped to do. The best way to go is the ImageMagick based approach as described in this question. It gives a number of alternatives, too.

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088