Q: I need to create Separation color space using PDFNet SDK. Normaly
the customer include a TIFF 1bpp into the PDF with ColorSpace /
Separation and CMYK tint value. For
example:
.. obj
/Separation
/Cyan
/DeviceCMYK
10 0 R
10 0 obj
<<
/FunctionType 0
/C0 [0 0 0 0]
/C1 [1 0 0 0]
/Range [0 1 0 1 0 1 0 1]
/Domain [0 1]
/N 1
It would be very helpful if you have any information or code on how to
create Separation color space using PDFTron toolkit. Thanks!
--------
A: The following C# pseudocode can be used to create a separation
color space based on a PostScript function:
static ColorSpace CreateSpotColorSpace(PDFDoc doc)
{
Obj sep_cs = doc.CreateIndirectArray();
sep_cs.PushBackName("Separation");
sep_cs.PushBackName("LogoGreen"); // The name of the colorant
sep_cs.PushBackName("DeviceCMYK"); // Alternate color space
// Create tint function (using PostScript calculator function).
// Tint function is used to transform a tint value into color
// component values in the alternate color space.
string ps_funct = "{ dup 0.84 mul exch 0.00 exch dup 0.44 mul exch
0.21 mul }";
Obj tint_funct = doc.CreateIndirectStream(new
System.Text.UTF8Encoding().GetBytes(ps_funct));
tint_funct.PutNumber("FunctionType", 4);
Obj tint_domain = tint_funct.PutArray("Domain");
tint_domain.PushBackNumber(0); // Gray
tint_domain.PushBackNumber(1);
Obj tint_range = tint_funct.PutArray("Range");
tint_range.PushBackNumber(0); // C
tint_range.PushBackNumber(1);
tint_range.PushBackNumber(0); // M
tint_range.PushBackNumber(1);
tint_range.PushBackNumber(0); // Y
tint_range.PushBackNumber(1);
tint_range.PushBackNumber(0); // K
tint_range.PushBackNumber(1);
sep_cs.PushBack(tint_funct);
return new ColorSpace(sep_cs);
}
The sample code in C++ or JAVA should be almost identical.
The resulting color space can be reused throughout the PDF document.
For example:
.. create ElementBuilder/ElementWriter (see ElementBuilder sample
project )
...
ColorSpace cs = CreateSpotColorSpace(doc);
...
Element rect = builder.CreateRect(0, 0, 100, 100);
rect.SetPathStroke(true);
rect.GetGState().SetStrokeColorSpace(cs);
rect.GetGState().SetStrokeColor(new ColorPt(1));
writer.WriteElement(rect)
...