略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: PDF_info_textline

2024-11-15

PDF_info_textline

(PECL pdflib >= 2.1.0)

PDF_info_textlinePerform textline formatting and query metrics

说明

PDF_info_textline ( resource $pdfdoc , string $text , string $keyword , string $optlist ) : float

Performs textline formatting and queries the resulting metrics.

add a note add a note

User Contributed Notes 1 note

up
-3
nico
9 years ago
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, '');
}
?>

官方地址:https://www.php.net/manual/en/function.pdf-info-textline.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3