Free Support Forum - aspose.com

Pdf not recognized as color

Hi,

When using the below snipped to recognize whether or not a pdf is color, this sometimes returns false results. I attached 2 sample pdfs. 1 is recognized correctly as color and the other is recognized as B/W while it clearly contains color. Am I missing something?

private bool IsColorPdf(String inputFile)
{
Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(inputFile);
String pagecolor = "";

int iColor = 0;

for (int pageCount = 1; pageCount <= pdfDocument.Pages.Count; pageCount++)
{
Aspose.Pdf.ColorType pageColorType = pdfDocument.Pages[pageCount].ColorType;
switch (pageColorType)
{
case Aspose.Pdf.ColorType.BlackAndWhite:
pagecolor = "BlackAndWhite";
break;
case Aspose.Pdf.ColorType.Grayscale:
pagecolor = "Grayscale";
iColor++;
break;
case Aspose.Pdf.ColorType.Rgb:
pagecolor = "Rgb";
iColor++;
break;
case Aspose.Pdf.ColorType.Undefined:
pagecolor = "Undefined";
iColor++;
break;
}
}

return iColor > 0;
}

Best Regards

Hi Johan,

Thanks for your inquiry. I have tested your scenario with shared document using Aspose.Pdf for .NET 10.8.0 and managed to observe the reported issue. For further investigation, I have logged an issue in our issue tracking system as PDFNEWNET-39387 and also linked your request to it. We will keep you updated via this thread regarding the issue status.

We are sorry for the inconvenience caused.

Best Regards,