Returns the affine transform that maps a box to a given rectangle on a PDF page.


CGAffineTransform CGPDFPageGetDrawingTransform(CGPDFPageRef page, CGPDFBox box, CGRect rect, int rotate, bool preserveAspectRatio);



A PDF page.


A constant that specifies the type of box. For possible values, see CGPDFBox.


A Quartz rectangle.


An integer, that must be a multiple of 90, that specifies the angle by which the specified rectangle is rotated clockwise.


A Boolean value that specifies whether or not the aspect ratio should be preserved. A value of YES specifies that the aspect ratio should be preserved.

Return Value

An affine transform that maps the box specified by the box parameter to the rectangle specified by the rect parameter.


Quartz constructs the affine transform as follows:

  • Computes the effective rectangle by intersecting the rectangle associated with box and the /MediaBox entry of the specified page.

  • Rotates the effective rectangle according to the page’s /Rotate entry.

  • Centers the resulting rectangle on rect.If the value of the rotate parameter is non-zero, then the rectangle is rotated clockwise by rotate degrees. The value of rotate must be a multiple of 90.

  • Scales the rectangle, if necessary, so that it coincides with the edges of rect. If the value of preserveAspectRatio parameter is YES, then the final rectangle coincides with the edges of rect only in the more restrictive dimension.

See Also

Getting Page Information


Returns the rectangle that represents a type of box for a content region or page dimensions of a PDF page.


Returns the dictionary of a PDF page.


Returns the document for a page.


Returns the page number of the specified PDF page.


Returns the rotation angle of a PDF page.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software