Print Page | Close Window

How to get color Info from 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=212
Printed Date: 24 Apr 24 at 10:59PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How to get color Info from PDF
Posted By: Harier
Subject: How to get color Info from PDF
Date Posted: 16 Dec 05 at 2:27AM

Hi

I'm can't find any color info function in library?

May be there some other tricks?

I'm need the info about additional colors (Pantone or other nonstandart) found in PDF file.

(same as displayed in Print_production->Output_preview command in Acro7)

Thanks

 

 




Replies:
Posted By: Ingo
Date Posted: 16 Dec 05 at 3:19AM
Hi!
I had the same problems i think...
I wanna know if rgb, cmyk or grey was used.
I do LoadFromFile, Encrypt and read all into a string. In this string i search for "RGB", "CMYK" and "GREY".
If you wanna make some experiences have a look in these string content... you'll see many interesting things for your own functions ;-)


-------------
Cheers,
Ingo



Posted By: Harier
Date Posted: 16 Dec 05 at 4:32AM

I can't understand how do you read all into a string??



Posted By: Ingo
Date Posted: 16 Dec 05 at 5:30AM
Hi!
I haven't access to my sources now. I'll post some code here this evening.


-------------
Cheers,
Ingo



Posted By: chicks
Date Posted: 16 Dec 05 at 12:33PM
Harier,

I wrote a color extraction library that extracts all CMYK
spot and process colors from a PDF.

It doesn't use QuickPDF, just opens the PDF and parses all objects looking for colorspaces and separations. It uses the open-source zlib.dll to uncompress any streams it comes across (only handles Flate encoding, so I use pdftk to decompress any PDFs that use other encodings first). It then parses the decompressed streams using regex for color definition patterns, such as:

0 0 0 0 K
0.3 0 0.4 1 k

etc.

It really isn't too difficult to do it yourself if you download the PDF spec and have a bit of regex knowledge.

My lib is for a prepress color separation tool I'm building for a printing company, so it only deals with CMYK values, not RGB. Also, it has a built-in Pantone to CMYK table, which you can download from Pantone.com.

I can't share my code, but (hint, hint) you can get a REALLY good introduction to PDF parsing with this code:

http://www.codeproject.com/useritems/pdfview.asp


Posted By: Michel_K17
Date Posted: 16 Dec 05 at 2:40PM
Hi Chicks!

   Thanks for the "hint"

   Personnally, I had been using a PDF Editor called "NitroPDF Pro" to be able to look at a picture and get info about the colorspace. That program is not bad, but has a quirky user interface and for being a little bit slow. I give it a 3.5 stars out of 5. It costs $99 and is available at www.nitropdf.com



Posted By: chicks
Date Posted: 16 Dec 05 at 3:16PM
Yep, I'm very familiar with NitroPDF. They use the Zeon PDF lib. I installed their beta the day it came out, but their forms interface was VERY slow at that time. Probably better now.

BTW, they don't publish an API, but it's very simple to get the interface and write to it


Posted By: Ingo
Date Posted: 16 Dec 05 at 5:55PM
Harier,

here's my code for extracting the complete file into a string (Delphi) ...

. . .
   textkomplett := '';
   fs := TFileStream.Create(Edit1.Text,fmOpenRead+fmShareDenyWrite);
   try
     SetLength(textkomplett,fs.Size);
     fs.Read(PChar(textkomplett)^,fs.Size);
   finally
     fs.Free;
   end;
. . .
Later you can use things like this:
. . .
       If Pos('/Device', textkomplett) > 0 Then
          begin
             fschema.Text := System.Copy(textkomplett, Pos('/Device', textkomplett) + 7, 4);
             fschema.Text := Trim(fschema.text);
          end
        else
          fschema.Text := 'Nothing';
. . .
Behind "Device" there's the colour model...

Good luck!
Ingo



-------------
Cheers,
Ingo



Posted By: chicks
Date Posted: 16 Dec 05 at 11:26PM
Harier,

I put together a commandline .exe using my lib. It only does DeviceCMYK process and spot separation colors, but if it extracts what you want, maybe I can create a DLL for you. It will ignore any RGB or any colors in images. Sorry, can't provide source code.

http://www.geocities.com/sea_sbs/files/pdfcolors.zip


Posted By: Harier
Date Posted: 20 Dec 05 at 3:49AM

Thank You Chicks

I'm trying the pdfcolors it works. But I'm need in for some more simple task. To do the list of nonstandart additional or "spot" colors for information only. So I'm no need in percent or objects info with some colors.

After looking on PDF file content (through text viewer) I'm discover that my info is after word "Separation". But in some files this info is omit(or encrypted) So some research is needed. 

Your program is very interesting because it can determine what real colors are in file. But sometime it describe color as (unknown) what it mean?

Thank's 



Posted By: chicks
Date Posted: 20 Dec 05 at 12:37PM
Harier,

The program is meant primarily to discover a set of predefined colors and Pantone colors, so has internal tables with cmyk values for about 800 process colors, and all 1089 Pantone colors.

Any cymk values not matching the internal tables return as (unknown), which simply means no "friendly" name for the cmyk values is known to the program.

I have thought about moving the color tables to an xml file or SQLite database so that they can be maintained without coding and recompiling. Do you have any interest in such an app?



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