Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Centering text not working.. why?? |
Post Reply
|
| Author | |
peterlen
Beginner
Joined: 13 Sep 11 Status: Offline Points: 4 |
Post Options
Thanks(0)
Quote Reply
Topic: Centering text not working.. why??Posted: 14 Sep 11 at 7:24PM |
|
Hello,
I am using QuickPDF Lite 7.25. I wanted to center my title so I tried:
library.SetTextAlign(1); // 1 = center align
library.Drawtext(10,20, "My Title");
This would draw my title all the way to the left edge and halfway off the page. When I do SetTextAlign(0) for the default left alignment, all works well, but even if I try the right alignment (3), the text is displayed halfway off of the left side of the page.
Not sure what I amy be missing here. Must be something stupid I am not doing. Any clues?
Thanks - Peter
|
|
![]() |
|
Ingo
Moderator Group
Joined: 29 Oct 05 Status: Offline Points: 3530 |
Post Options
Thanks(0)
Quote Reply
Posted: 14 Sep 11 at 11:10PM |
|
Could it be that the pdf was rotated internally?
Cheers, Ingo |
|
![]() |
|
peterlen
Beginner
Joined: 13 Sep 11 Status: Offline Points: 4 |
Post Options
Thanks(0)
Quote Reply
Posted: 14 Sep 11 at 11:59PM |
|
Ingo - Thanks for the reply. I know the code didn't change any rotation. The left align is correct and the X, Y coords are good as well, so I am unsure how the page rotation would be off. The Lite version does has one method that deals with rotation I believe so I will test some things there to see.
|
|
![]() |
|
AndrewC
Moderator Group
Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
Quote Reply
Posted: 20 Sep 11 at 4:46PM |
|
This code works as expected
QP.SetOrigin(1); QP.SetTextAlign(0); // 0= left align QP.DrawText(100, 20, "My Title"); QP.SetTextAlign(1); // 1 = center align QP.DrawText(100, 40, "My Title"); QP.SetTextAlign(2); // 2 = right align QP.DrawText(100, 60, "My Title"); If you are drawing text onto an existing page then it is possible that the coodinate system and scaling on the page is not what you expect. Some pages can render the text upside down and right to left. We have a function called QP.NormalizePage() in the full QPL version that resets a page to a standard coordinate system. If you still cannot get it to work then you could send your code and PDF fiels to Andrew |
|
![]() |
|
Dan
Team Player
Joined: 21 Oct 11 Location: US Status: Offline Points: 23 |
Post Options
Thanks(0)
Quote Reply
Posted: 05 Nov 11 at 6:10PM |
|
I was thrown off by centering as well and I think I know your problem. For the XPos, use PageWidth / 2 so your code would look like:
library.SetTextAlign(1); // 1 = center align library.Drawtext( (library.PageWidth / 2) , 20, "My Title"); Centering is done around the coordinates, not on the vertical line you specify. Dan Edited by Dan - 05 Nov 11 at 6:11PM |
|
![]() |
|
AndrewC
Moderator Group
Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
Post Options
Thanks(0)
Quote Reply
Posted: 08 Nov 11 at 2:53AM |
|
Dan is right. The DrawText uses the x,y coordinate as the point to align to. So if the alignment is set to RightAlign and you DrawText(50, 20, "Hello") then the right most past of the text will be a the horizontal position of x = 50.
|
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store