Search code examples
phppdfcolorsfpdf

Getting PDF color in PHP


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.


Solution

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