/    Sign up×
Community /Pin to ProfileBookmark

FPDF Center Align Rotated Text

I am rotating text like this
$pdf->RotatedText(17,145,$lefttext,90);

But this $lefttext is entered by the user and needs to be centered between the top and bottom of the page, so the 145 needs to be changed to a variable, based on the length of the text.

I can center horizonal text with something like this
$pdf->Cell(0,$height,$toptext,0,1,’C’);

I have been trying to use GetStringWidth for the rotated text, but am about to pull the only hair I have left out!
Any examples of this code would be appreciated.
Thanks

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ginerjmMay 12.2014 — Some perhaps silly questions:

1 - why not just print landscape and avoid the rotation? Or is there more on this page?

2 - You're talking about getting an exact position which may currently be only off by the normal height of this text. Why is it so important to be more exact than that?

btw - been using fpdf for a couple years and apparently there have been some new improvements. Never had RotateText available before.
Copy linkTweet thisAlerts:
@lexiferrauthorMay 12.2014 — The users are creating a bar graph, and this text will be over on the left side of the graph. So if someone types 3 letters vs someone typing 20 letters. the text would need adjusted accordingly. The font will always be the same size.
×

Success!

Help @lexiferr spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...