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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Centering text not working.. why??
  FAQ FAQ  Forum Search   Register Register  Login Login

Centering text not working.. why??

 Post Reply Post Reply
Author
Message
peterlen View Drop Down
Beginner
Beginner


Joined: 13 Sep 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote peterlen Quote  Post ReplyReply Direct Link To This Post 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 
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3530
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 14 Sep 11 at 11:10PM
Could it be that the pdf was rotated internally?

Cheers, Ingo
Back to Top
peterlen View Drop Down
Beginner
Beginner


Joined: 13 Sep 11
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote peterlen Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Dan View Drop Down
Team Player
Team Player
Avatar

Joined: 21 Oct 11
Location: US
Status: Offline
Points: 23
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dan Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
AndrewC View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 08 Dec 10
Location: Geelong, Aust
Status: Offline
Points: 841
Post Options Post Options   Thanks (0) Thanks(0)   Quote AndrewC Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store