Print Page | Close Window

On-the-fly color conversion (RGB -> Separation)

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=3145
Printed Date: 04 Jun 25 at 11:26PM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: On-the-fly color conversion (RGB -> Separation)
Posted By: Rob
Subject: On-the-fly color conversion (RGB -> Separation)
Date Posted: 09 Jul 15 at 6:47PM
I need to find a way to get separation colors into my output PDF.
Fortunately QuickPDF supports separation colors. It's pretty straightforward:

PdfLib.AddSeparationColor('RDG_WHITE', 25, 25, 25, 25, 0); // add a separation color
PdfLib.SetFillColorSep('RDG_WHITE', 1); // set fill color to use the separation color
PdfLib.DrawBox(Left, Top, Width, Height, 1); // draw something with the separation color

On to the second part of the problem.
My PDF is generated using this code:

aCanvas := TCanvas.Create;
aCanvas.Handle := PdfLib.GetCanvasDC(Width, Height);
TemplateDoc.SVG.Draw(aCanvas, Rect(0, 0, Width, Height));
aCanvas.Free;
PdfLib.LoadFromCanvasDC(DPI, 0);

This also works fine.

Now for the actual problem:

Using Draw on a Canvas to generate output on a PDF page rules out the possibility of using separation colors (as far as I can tell), because internally the Canvas is first converted into a MetaFile object (which doesn't support named colors). Inside LoadFromCanvasDC the MetaFile is then drawn onto the PDF page using a Painter object (Painter.DrawImage).

The only solution I can think of is to somehow "hook" into the loop that paints the MetaFile onto the PDF page. Inside this loop I could look for a specific RGB color, $98918F for example, and each time an object is about to be painted with this color, I would call SetFillColorSep or SetLineColorSep, just before the object is drawn to the PDF, so that the object would then be drawn using the separation color instead of its RGB color.

But how to accomplish this? Is there a standardized way of hooking into this loop, like maybe an OnChanging event of some sort? If not, where exactly in the code is this "loop" that draws the MetaFile onto the PDF page?

I hope someone can point me in the right direction!
Many thanks in advance!



Replies:
Posted By: Rob
Date Posted: 12 Jul 15 at 1:52PM
Never mind, I got it working. I can now do on-the-fly conversion of any rgb color into any separation color I need.



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