Introduction to PDF color: Experiments with Patterns

Introduction to PDF color: Experiments with Patterns

It’s a bit ironic, but I used the Pattern Colorspace all over my Introduction to PDF Color presentation before rushing through Patterns as the last topic in its own right.

You might recall the following slides; all of which use an Axial Shading pattern:

Different ways of specifying a white to black shading pattern.0OpticalIllusions3DrawSeparationImages-out1

 

but one of the following Radial Shading Patterns were used for as backgrounds for all slides with text on them:

TestPatterns22TestPatterns21TestPatterns23

 

Now, it’s relatively straightforward to create Axial Shading patterns with the DotNet Interface, but creating Radial Shading Patterns and even tiling Patterns isn’t supported with that API (Could be worse, the fruit company‘s fondleslabs don’t support displaying PDF shading patterns at all). So for the above and the slides below, I explored creating them using APDFL’s C interface, starting from the standard createPatterns sample app (which I’ve also translated to PDFJT code) and extending it in a manner that’s more random-walk than depth-first or breadth-first search.

TestPatterns8 TestPatterns14TestPatterns13

Let’s start by looking at the code for the tiling patterns.

Here we are basically setting up the Graphic State, used to set up the content, which is done in this routine which essentially draws an octagon:

and this routine takes PDEContent and creates a Pattern from it:

The next Pattern is much like the first, using the same PDEContent in fact, except we are going to fill the tiling pattern with a CalGray-based Axial Shading pattern.

The last pattern uses an octagram shape rather than an octagon, and also uses an axial shading pattern (deviceRGB-based) as a fill, but the tile itself is rotated 30º.

Now, for the backgrounds, I created a radial shading pattern.

Note that the color values were initially pulled from Example 4.25 from the PDF v1.7 Reference, page 313. They were nice cool greens that I color shifted to red by having the cyan, magenta, and yellow values do a circular shift. And again for blue.

Also note that a Radial Shading Pattern uses a stitched function, which is two -or more- functions appended together:

Learn more about Adobe PDF Library here.

Leave a Reply

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