Q:
I'm working on a module that will apply a transform (scaling,
rotation, translation, skew) to an image file exported from the PDF.
The transform is intended to ensure that the extracted image has the
same appearance as the displayed PDF.
According to the spec, PDF matrix transformations specify the
conversion from the transformed coordinate system to the original
(untransformed) coordinate system.
Therefore, I'm assuming that the CTM returned by:
pdftron::Common::Matrix2D ctm = m_pElement->GetCTM();
returns a transformation matrix to map an element from a transformed
coordinate system to an untransformed system.
We want to export an image from the PDF and apply a transform to the
original image in order to match the display appearance of the PDF. Do
we need to apply the inverse transform (from the CTM of the image)? If
so, does PDFNet provide any support for finding the inverse matrix or
will we need to provide this function? Or is there another approach?
-----
A:
Does PDFNet provide any support for finding the inverse matrix or will we need to provide this function?
To compute the matrix inverse you could use:
pdftron::Common::Matrix2D ctm = m_pElement->GetCTM();
pdftron::Common::Matrix2D inv = ctm.Inverse();
Btw, the CTM maps the 1x1 unit square to the image parallelogram (i.e.
as the image appears on page). So the original PDF image is always 1x1
point and is 'stretched' and positioned using the CTM.