Hi there, we wanted to retrieve the color-type of every single page (Rgb, Grey, BlackAndWhite) of the attached PDF : ThesisUniBasel.pdf, but it didn’t seems to work correctly.
The page 3 to 9, 12 to 15, 18 to 24, 26 to 32, 35 and 36 are displayed as Rgb, when i expected to get BlackAndWhite.
Here is the code used to get the color :
com.aspose.pdf.Document document = new com.aspose.pdf.Document(“C:\temp\ThesisUniBasel.pdf”);
for (int i = 1; i <= document.getPages().size(); i++) {
System.out.println(“COLOR, page: " + i + " Color :” +
document.getPages().get_Item(i).getColorType());
}
We am using the version 25.9 of aspose-pdf ThesisUniBasel.pdf (493.7 KB)
It looks like the Page.getColorType() method is returning RGB for pages that you expect to be BlackAndWhite.
In Aspose PDF the color type is determined from the resources that are present on the page (images, graphics, color spaces, etc.). If a page contains even a single object that is defined in an RGB color space, the method will report RGB, even when the visual appearance of the page looks monochrome.
What to check / try
Inspect the page resources
Open the PDF in a viewer that can show the page’s object list (e.g., Adobe Acrobat → Print Production → Output Preview or any PDF‑inspection tool). Look for:
Images that are stored as RGB (even if they are visually gray).
Vector graphics or text that use an RGB color space.
Confirm the PDF version you are using
You are on Aspose.PDF 25.9. This version had a known limitation where getColorType() could return RGB for pages that only contain gray‑scale images encoded in an RGB stream. The issue was addressed in later releases.
Upgrade to the latest Aspose.PDF version (e.g., 25.12 or newer) and re‑run the same code.
Document doc = new Document("C:\\temp\\ThesisUniBasel.pdf");
for (int i = 1; i <= doc.getPages().size(); i++) {
System.out.println("Page " + i + " : " + doc.getPages().get_Item(i).getColorType());
}
If the result changes to BlackAndWhite for the expected pages, the bug has been fixed.
Create a minimal reproducible sample Copy only a few pages (e.g., page 3 and page 4) into a new PDF and run the same snippet. If the problem persists, attach that small PDF when you open a support ticket – it helps the Aspose team to reproduce the issue quickly.
When the above does not help
Open a support request on the Aspose forum (or via the Aspose support portal) and include:
The exact Aspose.PDF version you are using.
The small PDF that reproduces the wrong color type.
The code snippet you run (as shown above).
The support team can then verify whether the behavior is a regression and, if needed, provide a hot‑fix or a workaround.