pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stahle, Patrick" <patrick.sta...@te.com>
Subject drawing images with rotation PDFBox 2.0
Date Fri, 04 Mar 2016 19:35:32 GMT

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(),
PDPageContentStream canvas = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND,
true, true);
                canvas.drawXObject(ximage, at);

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...

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?


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message