Print Page | Close Window

How do you center text on a page?

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=1816
Printed Date: 29 Apr 25 at 10:27AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: How do you center text on a page?
Posted By: Carneno
Subject: How do you center text on a page?
Date Posted: 26 Apr 11 at 12:37AM

Hello,

I'm developing a VB 6.0 printing program using QuickPDF Library 7.24.
 
Something is not making sense about DrawText on a page.
 
If QuickPDF allows you to set the alignment of the text(SetTextAlign) then what does the Xpos do in DrawText?
 
Does anybody know how to do center alignment of text on a page?
 
Any help would be gratefully appreciated.
 
Thanks,
Tony


-------------
Stop The World, I want To Get Off.



Replies:
Posted By: Ingo
Date Posted: 26 Apr 11 at 1:33PM
Why you don't read the online-reference:
"...
XPos The horizontal position of where to draw the text. The reference point is usually to the left of the first character, unless the http://www.quickpdflibrary.com/help/quickpdf/SetTextAlign.php - SetTextAlign function has been used to change the alignment.
..."

Yyou can set the page dimensions.
You can set if you want inch, mm or pixels (psunits).
You can set the font dimensions.
You should know what you wanna write.
Where's the problem? Calculate a bit ... ;-)
Another advice: Use/try the html-functions...

Cheers, Ingo



Posted By: Carneno
Date Posted: 26 Apr 11 at 2:25PM

Hello Ingo.

Thanks again for your continued help with my issues.
 
I'm not sure of what your point is.  I have spent numerous hours reading the refernce manual as well as all the forums and other information on QuickPDF.org.
 
Everything i read simply says to use the SetTextAlign with a "1" for the TextAlign option.
 
If I use this code:
   
    QuickPDFResult = QuickPDFObject.SetTextAlign(1)
    ExceptionLineString = "* * * * * * * * * * C of A  EXCEPTION REPORT * * * * * * * * * *"
    Call QuickPDFObject.DrawText(0, 36, ExceptionLineString)
 
It prints "PTION REPORT * * * * * * * * * *" on the left side of the page.
 
I'm not sure of what I should calculate or what else I should do to center the text.
 
Thanks,
Tony


-------------
Stop The World, I want To Get Off.


Posted By: Ingo
Date Posted: 26 Apr 11 at 2:44PM
First set the measurements.
Then: How wide is your document?
Then: How long (how many characters) has your text?
Then: What's the font height? Height 10 should be round about 8 points wide (depends on the used font).
Then: Check if there's a non printable frame.
Then: Divide width of document, divide width of your text, ...
And try and try and try ... and if you've got your own solution you've learned a lot ;-)
BTW: Again... try the html-functions...

Cheers, Ingo 


Posted By: Carneno
Date Posted: 26 Apr 11 at 3:25PM
OK.  I think i see what you are telling me.  I used this code to center the line of text:
 
    QuickPDFCofAExceptDocumentID = QuickPDFObject.NewDocument
    QuickPDFCofAExceptDocumentID = QuickPDFObject.SelectedDocument
    QuickPDFPageHeight = QuickPDFObject.PageHeight
    QuickPDFPageWidth = QuickPDFObject.PageWidth
    QuickPDFResult = QuickPDFObject.SetOrigin(1)
    QuickPDFCourierBoldFontID = QuickPDFObject.AddStandardFont(1)
    QuickPDFResult = QuickPDFObject.SelectFont(QuickPDFCourierBoldFontID)
    QuickPDFResult = QuickPDFObject.SetTextSize(12)
    QuickPDFResult = QuickPDFObject.SetTextAlign(0)
   
    ExceptionLineString = "* * * * * * * * * * C of A  EXCEPTION REPORT * * * * * * * * * *"
    Call QuickPDFObject.DrawText((QuickPDFPageWidth / 2) - (Len(ExceptionLineString) / 2 * 7.2), QuickPDFStartYPosition, ExceptionLineString)
 
That centered the text.
 
I will look at the non printable frame information you suggested and the html functions.
 
So, does this mean that the SetTextAlign option "1" does not work?
 
Thanks,
Tony


-------------
Stop The World, I want To Get Off.


Posted By: Ingo
Date Posted: 26 Apr 11 at 4:26PM
Hi!

A last time:
Read the description about DrawText (specially xpos and regarding TextAlign).
Read the description about SetTextAlign.

Cheers, Ingo



Posted By: Carneno
Date Posted: 26 Apr 11 at 6:26PM

OK Ingo.  There is obviously something there that I can't see.  I'll try to figure it out.

Thanks again,
Tony


-------------
Stop The World, I want To Get Off.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk