Print Page | Close Window

Detecting Colour in a PDF

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2350
Printed Date: 29 Sep 24 at 1:20AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: Detecting Colour in a PDF
Posted By: Doc-ItMan
Subject: Detecting Colour in a PDF
Date Posted: 24 Jul 12 at 3:09PM
Is there a function for detecting if a PDF has colour on any of the pages other than black and white?



Replies:
Posted By: Ingo
Date Posted: 24 Jul 12 at 9:22PM
Hi Doc!

There's no implemented function for this.
You can do it by your own. I've posted some code little time ago.
Use RenderPageToStream and put the content into a small (64 x 64 or so) bmp-image.
Now you can check the pixels if there's any other colour than black or white.
Here's the link:
http://www.quickpdf.org/forum/forum_posts.asp?TID=2194&KW=Round%28pix%29&PID=9362&title=this-tif-cant-be-converto-pdf#9362

Cheers, Ingo



Posted By: Doc-ItMan
Date Posted: 24 Jul 12 at 9:30PM
Thanks for the help. It is interesting that there is no such function for this. I do not believe that the PDF Spec includes it either.


Posted By: AndrewC
Date Posted: 27 Jul 12 at 5:07AM
The closest and quickest function we have is GetPageColorSpaces.

This will return a CSV based string showing all the colorspaces used in the document for images.  If the string contains anything other than DeviceGray then there is a very good chance that colours are used in the document.

This may not pick up coloured objects in the content stream but most PDF's have some type of image or logo.

Andrew.


Posted By: Doc-ItMan
Date Posted: 27 Jul 12 at 7:01AM
I could not find that method in the QuickPDF Library v8.12.
 
Cheers Howard.


Posted By: AndrewC
Date Posted: 27 Jul 12 at 8:09AM
This is a relatively new function and is available in 8.15 / 8.16.  QPL  8.16 is a free upgrade to all registered 8.xx users and contains many fixes and improvements over 8.11 and 8.12.

It can be downloaded from  http://www.quickpdflibrary.com/products/quickpdf/updates.php - http://www.quickpdflibrary.com/products/quickpdf/updates.php

Andrew.




Posted By: Ingo
Date Posted: 27 Jul 12 at 1:47PM
Hi!

There's no need to use ColourSpaces if you want to create coloured pdf-documents.
There could be DeviceRGB but the content is absolutely b/w... and there could be no ColourSpaces and the content are coloured images.
It's not a save method.
There are many printing services out there and the customers have to pay more for coloured printouts than for b/w. I've few customers using my solution i've described above.

Cheers, Ingo



Posted By: AndrewC
Date Posted: 02 Aug 12 at 11:40AM
Currently, the only 99.9% correct way of detecting colour in a PDF would be to render the page to a BMP file and then checking each and every pixel - basically following Ingo's method.

Some commercial design and printing customers need to know about the various plates and colorspaces used by a PDF and that is where GetPageColorSpaces comes in handy and is why I mentioned it as the answer hopefully may be useful for some people reading this.

Andrew.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk