Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

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");

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum