You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by Ján Kaššovic <ja...@gmail.com> on 2017/01/12 12:38:13 UTC

Drawing rotated image in a content stream

Hi,

I consider the following more as a bug/feature request, but since I am not
sure I start here. I have ended up with a need to use deprecated
PDPageContentStream.drawXObject since I need to rotate the PDImageXObject
which I am drawing. The nondeprecated methods just hide the transformation
inside, which I find unfortunate.
If there is a better way to do so, please let me know.

Jan

Re: Drawing rotated image in a content stream

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 12.01.2017 um 18:17 schrieb Tilman Hausherr:
> Am 12.01.2017 um 13:38 schrieb J�n Ka\u0161\u0161ovic:
>> Hi,
>>
>> I consider the following more as a bug/feature request, but since I 
>> am not
>> sure I start here. I have ended up with a need to use deprecated
>> PDPageContentStream.drawXObject since I need to rotate the 
>> PDImageXObject
>> which I am drawing. The nondeprecated methods just hide the 
>> transformation
>> inside, which I find unfortunate.
>> If there is a better way to do so, please let me know.
>
> This is more a documentation problem.... I've improved the javadoc for 
> next version.
>
> call
>
> cs.drawImage(img, Matrix.getRotateInstance(Math.toRadians(45), ..., 
> ....));
>
>
> note that rotation is done around (0,0) so you need to do a 
> translation too 

Oops it's more complex, you need to scale for the image size too. So you 
need to pass a matrix that has both the rotation, the translation and 
the scale.

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


Re: Drawing rotated image in a content stream

Posted by Tilman Hausherr <TH...@t-online.de>.
Am 12.01.2017 um 13:38 schrieb J�n Ka\u0161\u0161ovic:
> Hi,
>
> I consider the following more as a bug/feature request, but since I am not
> sure I start here. I have ended up with a need to use deprecated
> PDPageContentStream.drawXObject since I need to rotate the PDImageXObject
> which I am drawing. The nondeprecated methods just hide the transformation
> inside, which I find unfortunate.
> If there is a better way to do so, please let me know.

This is more a documentation problem.... I've improved the javadoc for 
next version.

call

cs.drawImage(img, Matrix.getRotateInstance(Math.toRadians(45), ..., ....));


note that rotation is done around (0,0) so you need to do a translation too

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