getDrawingTransform(_:rect:rotate:preserveAspectRatio:)
Returns the affine transform that maps a box to a given rectangle on a PDF page.
Declaration
func getDrawingTransform(_ box: CGPDFBox, rect: CGRect, rotate: Int32, preserveAspectRatio: Bool) -> CGAffineTransformParameters
- box:
A constant that specifies the type of box. For possible values, see Cgpdfbox.
- rect:
A Quartz rectangle.
- rotate:
An integer, that must be a multiple of
90, that specifies the angle by which the specified rectangle is rotated clockwise. - preserveAspectRatio:
A Boolean value that specifies whether or not the aspect ratio should be preserved. A value of True 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.
Discussion
Quartz constructs the affine transform as follows:
Computes the effective rectangle by intersecting the rectangle associated with
boxand the/MediaBoxentry of the specified page.Rotates the effective rectangle according to the page’s
/Rotateentry.Centers the resulting rectangle on
rect.If the value of therotateparameter is non-zero, then the rectangle is rotated clockwise by rotate degrees. The value ofrotatemust be a multiple of 90.Scales the rectangle, if necessary, so that it coincides with the edges of
rect. If the value ofpreserveAspectRatioparameter is true, then the final rectangle coincides with the edges ofrectonly in the more restrictive dimension.