Q: What is the purpose of the Page.GetDefaultMatrix() method? In the
documents I have tested this with, the Default Matrix just appears to
have some wacky h and v values in it, which would be imposing a
translation to everything on the page. We currently are not even using
this matrix, and our output is still valid. What is the purpose of
A: PDF pages are cropped using page.GetCropBox(). This box defines an
area in the PDF user coordinate system that represents a visible page.
In most cases the origin of the crop box will coincide with the origin
on PDF user coordinate system (0, 0), however it is also possible that
to define a different crop box (for example, [-1000, 459, 560,
In case you are only rendering a PDF page using PDFDraw class, you
don't need to worry about these details. However, if you are
implementing PDF conversion, you may (or may not) need to translate
coordinates of PDF elements to compensate for this shift in the
coordinate system origin.
A PDF page case also be rotated using /Rotate attribute in the PDF
page dictionary (page.GetRotation()). To account for this you would
also need to rotate and shift coordinates for all elements on the
To address these issues, GetDefaultMatrix() method can be used to
transforms user space coordinates to rotated and cropped coordinates.
There are also optional parameters to flip the Y axis, to rotate
elements by an additional amount, etc.
A sample use case for this method would be as follows:
Matrix2D device_mtx = ....;
device_mtx *= page.GetDefaultMatrix();
while ((element = element_reader.Next()) != null) // Read page
// Get the final bounding box for an element as it appears on
Similarly you can use device_mtx to transform points of a path,
text, image, CTM etc.