DLE Rendering Support Enhancement: Separation Channels

Datalogics has been bringing new engineers into working with DLE over the past several months, and we’re excited about enhancements that they have made to DLE in that time. One in particular is the ability to generate color separations as raster images for PDF pages. DLE has had the ability to generate PDF page separations as EPS files for some time. These changes enhance DLE to allow for rendering of PDF page separations to raster images. This allows saving these as any of the file formats that the Image object can be saved as (JPEG, PNG, TIFF) and for all other functionality of DLE Image objects.
Acquiring PDF page raster separations is easy and is demonstrated in the DrawSeparations samples for C# and Java included with DLE, but a couple extra steps over rendering a PDF page are required. To illustrate in Java:
1) Make the list of colorants to draw: this should include the process colors (Cyan, Magenta, Yellow and Black) as the first four list elements, followed by the names of separation (spot) color channels to draw. A shortcut is to get all colorants used on the page, and make separation color channels for each of these:

List<Ink> inks = pg.listInks();
List<SeparationColorSpace> colorants = new ArrayList<SeparationColorSpace>();
for (Ink ink : inks) {
  colorants.add(new SeparationColorSpace(pg, ink));

2) Set up the transform desired for the page and the other page drawing parameters. Here we transform the media box of the PDF page from PDF orientation to Java image orientation, and request that the image being drawn be placed on a white background (DO_LAZY_ERASE) and for annotations that have appearance streams to be drawn (USE_ANNOT_FACES):

 double width = pg.getMediaBox().getRight() - pg.getMediaBox().getLeft();
 double height = pg.getMediaBox().getTop() - pg.getMediaBox().getBottom();
 Matrix matrix = new Matrix().scale(1, -1).translate(0, -height);
 DrawParams params = new DrawParams();
 params.setDestRect(new Rect(0, 0, width, height));
 params.setFlags(EnumSet.of(DrawFlags.DO_LAZY_ERASE, DrawFlags.USE_ANNOT_FACES));

3) Executing the PDF page rendering can be done to a list of DLE Image objects, or to a list of Java BufferedImage objects; the list contains one image per channel in the order they were added to list of colors to draw:

 List<BufferedImage> separatedImages = pg.drawContents(params, colorants);

And that’s it! We hope you enjoy this new DLE feature.

Share this post with your friends

Share on facebook
Share on twitter
Share on linkedin

2 thoughts on “DLE Rendering Support Enhancement: Separation Channels”

    1. One could render to the C, M, Y and K channels and see if the C, M and Y channels are all blank (0 – valued) as a check on whether a PDF page contains color. However, this is not foolproof – some calibrated RGB spaces, for example, render with some colorant in the C, M and Y channels . This is due to the nature of ICC color profile conversions.
      You may be better off going through the Element objects in the page and checking the colorspace of each element. This will tell you if an element is in a grayscale color space, or a different color space. However, if you want to determine if an Element in a non-gray colorspace only uses gray colorants (i.e. just the ‘K’ channel in CMYK, or only uses R=G=B colors in RGB) then you need to inspect the contents of the Element objects.

Leave a Comment

Your email address will not be published. Required fields are marked *

Get instant access to the latest PDF news, tips and tricks!

Do you want monthly updates on the latest document technology trends?

By submitting the form, you agree to receive marketing emails from Datalogics. You may unsubscribe at any time. 

Like what you're reading?

Get Datalogics blogs sent right to your inbox!

By submitting the form, you agree to receive marketing emails from Datalogics. You may unsubscribe at any time.