I’m looking for a way to get the PDF page color information using ITextSharp. I need to know if the page is Black and White or color
any help would be great.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To the best of my knowledge PDFs don’t have a “page color” or a “background color”. The fact that when you open a PDF in Acrobat and you see a white canvas is actually an implementation detail, albeit one that everyone does. (Actually this can be changed by turning on some accessibility options in preferences.)
Instead, any PDF that looks like it has a different background color probably has an image or a full color shape stretched across it. Using iTextSharp you could probably enumerate all of the images and shapes and look for any that are the same size or larger than the actual page, but I’m not sure how reliable that would be.
The only way that I could think that would actually work would be to convert the PDF to an image and sample one or more of the corners where (hopefully) no one has any content. Think link shows how to convert a PDF to JPG.