Hi!

I encountered a strange problem. I used PrintImageLocations.java as source for 
my image extraction function,
which is supposed to extract the image and it's position as well as it's width 
and height in the PDF source document.

Everything works fine except the calculation of width and height.

I use the following code:

                    PDXObjectImage image = (PDXObjectImage) xobject;
                    PDPage page = getCurrentPage();
                    Matrix ctm = getGraphicsState()
                            .getCurrentTransformationMatrix();
                    double rotationInRadians = (page.findRotation() * Math.PI) 
/ 180;

                    AffineTransform rotation = new AffineTransform();
                    rotation.setToRotation(rotationInRadians);
                    AffineTransform rotationInverse = rotation.createInverse();
                    Matrix rotationInverseMatrix = new Matrix();
                    rotationInverseMatrix
                            .setFromAffineTransform(rotationInverse);
                    Matrix rotationMatrix = new Matrix();
                    rotationMatrix.setFromAffineTransform(rotation);

                    Matrix unrotatedCTM = ctm.multiply(rotationInverseMatrix);
                    float xScale = unrotatedCTM.getXScale();
                    float yScale = unrotatedCTM.getYScale();

                    float img_width = xScale / 100f * image.getWidth(); 
                    float img_height = yScale / 100f * image.getHeight();


But for some reason, the calculated Width and height are not correct, the 
scaling factor is somehow strange and
xScale and yScale differ, even when the image is scale proportional.

Does anybody know what I've to do?

Thanks a lot in advance!
Chris


Reply via email to