note 92268 modified in function.pdf-info-textline by danbrown
| From: | danbrown@php.net | Date: | Thu, 16 Jul 2009 23:21:58 +0000 |
| Subject: | note 92268 modified in function.pdf-info-textline by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158389@lists.php.net to get a copy of this message | ||
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, '');
}
?>
--was--
You can use PDF_info_textline to center some text in the page.
Here's a little function
// 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, '');
}
http://php.net/manual/en/function.pdf-info-textline.php