Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Unable to identify correct Black and white PDF pages

$
0
0
Hi,

I want to determine if the current PDF is colored, B&W or Gray-scale. The following code snippet works fine for color PDF and Gray scale PDFs. When i test it with B&W PDF files it display that current PDF is gray scale.

Document pdfDocument = new Document(file);
                // itterate through all the page of PDF file
                string filename = Path.GetFileName(file);
                for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
                {

                    // get the color type information for particular PDF page
                    Aspose.Pdf.ColorType pageColorType = pdfDocument.Pages[pageCount].ColorType;
                    switch (pageColorType)
                    {
                        case ColorType.BlackAndWhite:
                            Console.WriteLine("File " + filename + " Page # - " + pageCount + " is Black and white..");
                            break;
                        case ColorType.Grayscale:
                            Console.WriteLine("File " + filename + " Page # - " + pageCount + " is Gray Scale...");
                            break;
                        case ColorType.Rgb:
                            Console.WriteLine("File " + filename + " Page # - " + pageCount + " is RGB..");
                            break;
                        case ColorType.Undefined:
                            Console.WriteLine("File " + filename + " Page # - " + pageCount + " Color is undefined..");
                            break;
                    }
                }

Need your help in this regard. I am also attaching the B&W PDF "200dpi.pdf" .  

Viewing all articles
Browse latest Browse all 3131

Trending Articles