I don't know if it exists for PDF's. But you could turn a PDF into an image with some tool and analyze the pixels of the image.
Just a quick google search:
- Turn PDF into Image: https://github.com/spatie/pdf-to-image
- Get the value of a pixel in PHP: https://stackoverflow.com/questions/15172115/how-can-i-get-the-pixel-value-of-image-in-php