Am 04.03.2016 um 20:35 schrieb Stahle, Patrick:
Hi,

I am struggling with rotating an image. For instance I have the following code:
AffineTransform at = new AffineTransform(rect.getWidth(), 0, 0, 
rect.getHeight(), rect.getLowerLeftX(), rect.getLowerLeftY());
PDPageContentStream canvas = new PDPageContentStream(document, page, 
PDPageContentStream.AppendMode.APPEND, true, true);
                 at.rotate(Math.toRadians(90));
                 canvas.drawXObject(ximage, at);
                 canvas.close();

It seems to work, but not the way I would've expected it to. It rotates the 
image but keeps the original boxed rectangle size which in this case squishing 
the image. Is this expected behavior, and if so is there way for an image to 
rotate and keep the sizing? I kind of hoped it work the same way as rotating 
text...

Sorry I don't understand you... why should it not keep the size?


Also on a PDFBox 2.0 note, the "PDPageContentStream  -> drawXObject' is 
deprecated and the source says to use drawImage instead. However I was not able to find 
a drawImage method that takes AffineTransform. What is the recommended way to do this 
in 2.0 going forward?

        saveGraphicsState();
        transform(new Matrix(transform));  <== do the rotation only

         drawImage()     <=== here just set the position

        restoreGraphicsState();



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to