DOUBLE PDFPAGE_GetUnicodeTextWidth ( BSTR text ) |
This method returns the width (in pixels) of the specified Unicode text string in pixels for the current font and page properties. Use PDFPAGE_SetActiveFont to set a desired font before calling this method.
Equivalent in new interface: IPDFDocument4::GetUnicodeTextWidth.
{ PDF object is supposed to be created } PDF.BeginDoc; PDF.PDFPAGE_SetActiveFont('Verdana', false, false, false, false, 16.0, 0); txt := 'Centered text.'; h := PDF.PDFPAGE_GetUnicodeTextHeight(txt); w := PDF.PDFPAGE_GetUnicodeTextWidth(txt); l := (PDF.PageWidth - w) / 2; t := (PDF.PageHeight - h) / 2; PDF.PDFPAGE_TextOut(l, t, 0.0, txt); PDF.EndDoc;
// PDF object is supposed to be created PDF->BeginDoc(); PDF->PDFPAGE_SetActiveFont("Verdana", FALSE, FALSE, FALSE, FALSE, 16.0, 0); wstring txt = L"Centered text."; DOUBLE h = PDF->PDFPAGE_GetUnicodeTextHeight(txt); DOUBLE w = PDF->PDFPAGE_GetUnicodeTextWidth(txt); DOUBLE l = (PDF->PageWidth - w) / 2.0; DOUBLE t = (PDF->PageHeight - h) / 2.0; PDF->PDFPAGE_TextOut(l, t, 0.0, txt); PDF->EndDoc();
// PDF object is supposed to be created PDF.BeginDoc(); PDF.PDFPAGE_SetActiveFont("Verdana", false, false, false, false, 16.0, 0); string txt = "Centered text."; double h = PDF.PDFPAGE_GetUnicodeTextHeight(txt); double w = PDF.PDFPAGE_GetUnicodeTextWidth(txt); double l = (PDF.PageWidth - w) / 2.0; double t = (PDF.PageHeight - h) / 2.0; PDF.PDFPAGE_TextOut(l, t, 0.0, txt); PDF.EndDoc();
' PDF object is supposed to be created PDF.BeginDoc PDF.PDFPAGE_SetActiveFont "Verdana", False, False, False, False, 16.0, 0 txt = "Centered text." h = PDF.PDFPAGE_GetUnicodeTextHeight(txt) w = PDF.PDFPAGE_GetUnicodeTextWidth(txt) l = (PDF.PageWidth - w) / 2 t = (PDF.PageHeight - h) /2 PDF.PDFPAGE_TextOut l, t, 0.0, txt PDF.EndDoc