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: Move rotated text to center of page
Date Tue, 24 Jan 2017 22:30:35 GMT
Am 24.01.2017 um 23:20 schrieb Gilad Denneboom:
> Thanks, but surely PDFont.getStringWidth() will return the width of the
> text string on its own, not of the rect that surrounds it when it is
> rotated, right?

No. You'll need to so some math (cosine).

https://en.wikipedia.org/wiki/Trigonometric_functions

Tilman


>
> On Tue, Jan 24, 2017 at 11:02 PM, Tilman Hausherr <THausherr@t-online.de>
> wrote:
>
>> Am 24.01.2017 um 22:53 schrieb Gilad Denneboom:
>>
>>> I can't figure out
>>> how the moveTextPositionByAmount works...
>>>
>> It is relative to the previous position since the start of the text mode.
>> It starts at 0,0.
>>
>> Basically what I would like is to be able to calculate the height and width
>>> of the text, so I could figure out where on the page to place it so that
>>> the center of both objects are aligned.
>>>
>>
>> See the DrawPrintTextLocations example on how to calculate the height.
>> It's quite tricky. The width you can get by PDFont.getStringWidth().
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@pdfbox.apache.org
>> For additional commands, e-mail: users-help@pdfbox.apache.org
>>
>>


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


Mime
View raw message