SECTION 4.6
303
Patterns
By setting a shading pattern as the current color in the graphics state, a PDF con-
tent stream can use it with painting operators such as
f
(fill),
S
(stroke),
Tj
(show
text), or
Do
(paint external object) with an image mask to paint a path, character
glyph, or mask with a smooth color transition. When a shading is used in this
way, the geometry of the gradient fill is independent of that of the object being
painted.
Shading Operator
When the area to be painted is a relatively simple shape whose geometry is the
same as that of the gradient fill itself, the
sh
operator can be used instead of the
usual painting operators.
sh
accepts a shading dictionary as an operand and
applies the corresponding gradient fill directly to current user space. This opera-
tor does not require the creation of a pattern dictionary or a path and works with-
out reference to the current color in the graphics state. Table 4.27 describes the
sh
operator.
Note:
Patterns defined by type 2 pattern dictionaries do not tile. To create a tiling
pattern containing a gradient fill, invoke the
sh
operator from within the content
stream of a type 1 (tiling) pattern.
TABLE 4.27 Shading operator
OPERANDS
OPERATOR
DESCRIPTION
name
sh
(PDF 1.3)
Paint the shape and color shading described by a shading dictionary, sub-
ject to the current clipping path. The current color in the graphics state is neither
used nor altered. The effect is different from that of painting a path using a shading
pattern as the current color.
name
is the name of a shading dictionary resource in the
Shading
subdictionary of
the current resource dictionary (see Section 3.7.2, “Resource Dictionaries”). All co-
ordinates in the shading dictionary are interpreted relative to the current user
space. (By contrast, when a shading dictionary is used in a type 2 pattern, the
coordinates are expressed in pattern space.) All colors are interpreted in the color
space identified by the shading dictionary’s
ColorSpace
entry (see Table 4.28). The
Background
entry, if present, is ignored.
This operator should be applied only to bounded or geometrically defined shad-
ings. If applied to an unbounded shading, it paints the shading’s gradient fill across
the entire clipping region, which may be time-consuming.