pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tilman Hausherr <THaush...@t-online.de>
Subject Re: drawing images with rotation PDFBox 2.0
Date Fri, 04 Mar 2016 19:43:49 GMT
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(),
> 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?

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

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


To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
For additional commands, e-mail: users-help@pdfbox.apache.org

View raw message