Repository navigation
PDF Spec 08 General
Part of: PDF-Spec-08-Graphics
Navigation: ← Previous | PDF-Spec-Index | PDF-Spec-08-Graphics-State
The graphics operators used in PDF content streams describe the appearance of pages that are to be reproduced on a raster output device. The facilities described in this clause are intended for both printer and display applications.
The graphics operators form six main groups:
- Graphics state operators manipulate the data structure called the graphics state , the global framework within which the other graphics operators execute. The graphics state includes the current transformation matrix (CTM), which maps user space coordinates used within a PDF content stream into output device coordinates. It also includes the current colour , the current clipping path , and many other parameters that are implicit operands of the painting operators.
- Path construction operators specify paths , which define shapes, line trajectories, and regions of various sorts. They include operators for beginning a new path, adding line segments and curves to it, and closing it.
- Path-painting operators fill a path with a colour, paint a stroke along it, or use it as a clipping boundary.
- Other painting operators paint certain self-describing graphics objects. These include sampled images, geometrically defined shadings, and entire content streams that in turn contain sequences of graphics operators.
- Text operators select and show character glyphs from fonts (descriptions of typefaces for representing text characters). Because PDF treats glyphs as general graphical shapes, many of the text operators could be grouped with the graphics state or painting operators. However, the data structures and mechanisms for dealing with glyph and font descriptions are sufficiently specialized that clause 9, "Text" focuses on them.
- Marked-content operators associate higher-level logical information with objects in the content stream. This information does not affect the rendered appearance of the content (although it may determine if the content should be presented at all; see 8.11, "Optional Content"); it is useful to applications that use PDF for document interchange. Marked content is described in 14.6, "Marked Content".
This clause presents general information about device-independent graphics in PDF: how a PDF content stream describes the abstract appearance of a page. Rendering -the device-dependent part of graphics-is covered in clause 10, "Rendering". The Bibliography lists a number of books that give details of these computer graphics concepts and their implementation.
As discussed in 7.8.2, "Content Streams", the data in a content stream shall be interpreted as a sequence of operators and their operands , expressed as basic data objects according to standard PDF syntax. A content stream can describe the appearance of a page, or it can be treated as a graphical element in certain other contexts.
The operands and operators shall be written sequentially using postfix notation. Although this notation resembles the sequential execution model of the PostScript language, a PDF content stream is not a program to be interpreted; rather, it is a static description of a sequence of graphics objects . There are specific rules, described below, for writing the operands and operators that describe a graphics object.
PDF provides five types of graphics objects:
- A path object is an arbitrary shape made up of straight lines, rectangles, and cubic Bézier curves. A path may intersect itself and may have disconnected sections and holes. A path object ends with one or more
painting operators that specify whether the path shall be stroked, filled, used as a clipping boundary, or some combination of these operations.
- A text object consists of one or more character strings that identify sequences of glyphs to be painted. Like a path, text can be stroked, filled, or used as a clipping boundary.
- An external object (XObject) is an object defined outside the content stream and referenced as a named resource (see 7.8.3, "Resource Dictionaries"). The interpretation of an XObject depends on its type. An image XObject defines a rectangular array of colour samples to be painted; a form XObject is an entire content stream to be treated as a single graphics object. Specialized types of form XObjects shall be used to import content from one PDF file into another (reference XObjects) and to group graphical elements together as a unit for various purposes (group XObjects) . In particular, the latter are used to define transparency groups for use in the transparent imaging model ( transparency group XObjects , discussed in detail in clause 11, "Transparency"). There is also a PostScript XObject that may appear in some existing PDF files, but it should not be used by a PDF 1.7 conforming writer.
- An inline image object uses a special syntax to express the data for a small image directly within the content stream.
- A shading object describes a geometric shape whose colour is an arbitrary function of position within the shape. (A shading can also be treated as a colour when painting other graphics objects; it is not considered to be a separate graphics object in that case.)
PDF 1.3 and earlier versions use an opaque imaging model in which each graphics object is painted in sequence, completely obscuring any previous marks it may overlay on the page. PDF 1.4 introduced a transparent imaging model in which objects can be less than fully opaque, allowing previously painted marks to show through. Each object is painted on the page with a specified opacity , which may be constant at every point within the object's shape or may vary from point to point. The previously existing contents of the page form a backdrop with which the new object is composited , producing results that combine the colours of the object and backdrop according to their respective opacity characteristics. The objects at any given point on the page forms a transparency stack , where the stacking order is defined to be the order in which the objects shall be specified, bottommost object first. All objects in the stack can potentially contribute to the result, depending on their colours, shapes, and opacities.
PDF's graphics parameters are so arranged that objects shall be painted by default with full opacity, reducing the behaviour of the transparent imaging model to that of the opaque model. Accordingly, the material in this clause applies to both the opaque and transparent models except where explicitly stated otherwise; the transparent model is described in its full generality in clause 11, "Transparency".
Although the painting behaviour described above is often attributed to individual operators making up an object, it is always the object as a whole that is painted. Figure 9 in Annex L shows the ordering rules for the operations that define graphics objects. Some operations shall be permitted only in certain types of graphics objects or in the intervals between graphics objects (called the page description level in the figure). Every content stream begins at the page description level, where changes may be made to the graphics state, such as colours and text attributes, as discussed in the following sub-clauses.
In the Figure 9 in Annex L, arrows indicate the operators that mark the beginning or end of each type of graphics object. Some operators are identified individually, others by general category. Table 51 summarizes these categories for all PDF operators.
Table 51 - Operator Categories
| Category | Operators | Table |
|---|---|---|
| General graphics state | w , J , j , M , d , ri , i , gs | 57 |
| Special graphics state | q , Q , cm | 57 |
| Path construction | m , l , c , v , y , h , re | 59 |
Table 51 - Operator Categories (continued)
| Category | Operators | Table |
|---|---|---|
| Path painting | S , s , f , F , f* , B , B* , b , b* , n | 60 |
| Clipping paths | W , W* | 61 |
| Text objects | BT , ET | 107 |
| Text state | Tc , Tw , Tz , TL , Tf, Tr, Ts | |
| Text positioning | Td , TD , Tm , T* | 108 |
| Text showing | Tj , TJ , ' , " | 109 |
| Type 3 fonts | d0 , d1 | 113 |
| Color | CS , cs , SC , SCN , sc , scn , G , g , RG , rg , K , k | 74 |
| Shading patterns | sh | 77 |
| Inline images | BI , ID , EI | 92 |
| XObjects | Do | 87 |
| Marked content | MP , DP , BMC , BDC , EMC | 320 |
| Compatibility | BX , EX | 32 |
Figure 9 - Graphics Objects
- EXAMPLE The path construction operators m and re signal the beginning of a path object. Inside the path object, additional path construction operators are permitted, as are the clipping path operators W and W* , but not general graphics state operators such as w or J . A path-painting operator, such as S or f , ends the path object and returns to the page description level.
- NOTE A conforming reader may process a content stream whose operations violate these rules for describing graphics objects and can produce unpredictable behaviour, even though it may display and print the stream correctly. Applications that attempt to extract graphics objects for editing or other purposes depend on the objects' being well formed. The rules for graphics objects are also important for the proper interpretation of marked content (see 14.6, "Marked Content").
A graphics object also implicitly includes all graphics state parameters that affect its behaviour. For instance, a path object depends on the value of the current colour parameter at the moment the path object is defined. The effect shall be as if this parameter were specified as part of the definition of the path object. However, the operators that are invoked at the page description level to set graphics state parameters shall not be
considered to belong to any particular graphics object. Graphics state parameters should be specified only when they change. A graphics object can depend on parameters that were defined much earlier.
Similarly, the individual character strings within a text object implicitly include the graphics state parameters on which they depend. Most of these parameters may be set inside or outside the text object. The effect is as if they were separately specified for each text string.
The important point is that there is no semantic significance to the exact arrangement of graphics state operators. A conforming reader or writer of a PDF content stream may change an arrangement of graphics state operators to any other arrangement that achieves the same values of the relevant graphics state parameters for each graphics object. A conforming reader or writer shall not infer any higher-level logical semantics from the arrangement of tokens constituting a graphics object. A separate mechanism, marked content (see 14.6, "Marked Content"), allows such higher-level information to be explicitly associated with the graphics objects.
Coordinate systems define the canvas on which all painting occurs. They determine the position, orientation, and size of the text, graphics, and images that appear on a page. This sub-clause describes each of the coordinate systems used in PDF, how they are related, and how transformations among them are specified.
- NOTE The coordinate systems discussed in this sub-clause apply to two-dimensional graphics. PDF 1.6 introduced the ability to display 3D artwork, in which objects are described in a three-dimensional coordinate system, as described in 13.6.5, "Coordinate Systems for 3D".
Navigation: ← Previous | PDF-Spec-Index | PDF-Spec-08-Graphics-State