DynaPDF Manual - Page 562

Previous Page 561   Index   Next Page 563

Function Reference
Page 562 of 787
activates it in the graphics state when the corresponding TEndPattern callback function is
executed. However, a pattern is applied when the next fill or stroke path operation occurs
and if the pattern was defined as fill or stroke color.
o If a pattern is used on a page, the pattern matrix maps pattern space to the default
(initial) coordinate space of the page. Changes to the page’s transformation matrix
that occur within the page’s content stream, such as rotation and scaling, have no
effect on the pattern; it maintains its original relationship to the page no matter where
on the page it is used. Similarly, if a pattern is used within a template, the pattern
matrix maps pattern space to the template's default user space (that is, the template
coordinate space at the time the template is painted). A pattern may be used within
another pattern; the inner pattern’s matrix defines its relationship to the pattern space
of the outer pattern.
Working with Transformation Matrices
Coordinate transformations in PDF are achieved with so called Affine Transformations. Affine
transformations can represent any linear mapping from one coordinate system to another.
Affine transformations work with transformation matrices which consist of 6 real numbers. A
transformation matrix describes the coordinate origin, scaling factors of the x- and y-axis, as well as
the rotation angle of the coordinate system. A transformation matrix represents essentially a
coordinate space in which graphical objects can be drawn. Two coordinate spaces can easily be
concatenated by multiplying the corresponding transformation matrices.
Coordinates of objects which use their own coordinate space, such a text, templates, or patterns,
must be transformed to user space before the coordinates can be used. How this must be done is
described later.
Transformation matrices in DynaPDF are stored in the structure TCTM that is defined as follows:
struct TCTM
double a;
double b;
double c;
double d;
double x;
double y;
The identity matrix is [1, 0, 0, 1, 0, 0] (a, b, c, d, x, y).
The following overview lists the most important matrix manipulations:
Translations are specified as [1, 0, 0, 1, tx, ty] where tx and ty represent the distances to
translate the origin of the coordinate system in horizontal and vertical dimensions,

Previous topic: Coordinate Spaces

Next topic: Helper Functions

Start Chat