©
本文档使用
php.cn手册 发布
(PECL pdflib >= 2.1.0)
PDF_info_textline — Perform textline formatting and query metrics
$pdfdoc
, string $text
, string $keyword
, string $optlist
)Performs textline formatting and queries the resulting metrics.
[#1] nico [2009-07-16 16:18:00]
You can use PDF_info_textline to center some text in the page.
Here's a little function
<?php
// Parameters:
// $p -> the PDF handle
// $text -> the text to center
// $posy -> the vertical position of the text
// $pageWidth -> the width of the page, defaults to 595 (A4)
function center_text($p, $text, $posy, $pageWidth=595)
{
$width = PDF_info_textline($p, $text, 'width', '');
PDF_fit_textline($p, $text, ($pageWidth-$width)/2, $posy, '');
}
?>