Frequently Asked Question:
Draw text in the center of the page?
Question
Is there an easy way to draw text using DrawText function in the top/bottom center of the page without knowing the width of the text? I use SetOrigin to position the text vertically, but there doesn't seem to be an option do it horizontally.
Answer
This should work:
QP.SetOrigin(1);
// 10 point
QP.SetTextSize(10);
// Centre aligned
QP.SetTextAlign(1);
// Horizontal page centre
QP.DrawText(QP.PageWidth() / 2, QP.PageHeight / 2 + (QP.GetTextSize() / 2),
"This it my centred text");