PHP: PDF_fit_textline - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

PDF_get_apiname PDF_fit_textflow

Last updated: Fri, 26 Jan 2007

view this page in

# PDF_fit_textline

(PECL)

PDF_fit_textline -- Place single line of text

## Описание

bool PDF_fit_textline ( resource pdfdoc, string text, float x, float y, string optlist )

Places a single line of text on the page, subject to various options. Возвращает `TRUE` в случае успешного завершения или `FALSE` в случае возникновения ошибки.

add a note User Contributed Notes
PDF_fit_textline
Chris at postal-code dot com
27-Nov-2006 01:47
`A patch to the code below to handle an array bounds error that arises:
<?php
$nextText = "";
if ( ( count( $tmpTxt ) - 1 ) >= ( $i + 1 ) )
{ $nextText = $tmpTxt[ $i+1 ]; }
if ( ( strlen( $str ) + strlen( $nextText ) ) > $cols )
?>`
rcable at workforceconnections dot biz
11-Jul-2006 05:49
`Here is a function I created in order to allow me to do textblocks on pdflib lite. Hope this helps someone else, cause all the stuff I've found on php.net has helped me.
$p is your pdf resource
$text is the string to put in the box
$cols is the number col characters before a carriage return
$xcrd,$ycrd is lower left of first line.
This will accept \n as a newline/carriage return and use it to skip to next line. It is not setup to hyphenate words, but someday I'll build one, or buy the full pdf package. ;)
function text_block($p,$text,$cols,$xcrd,$ycrd)
{
$font_size=12; //font size, used to space lines on y axis
$tmplines = explode("\n",$text);
for($j=0;$j<count($tmplines);$j++)
{
$tmptxt = explode(" ",$tmplines[$j]);
$str="";
for($i=0;$i<count($tmptxt);$i++)
{
if($str=="") $str=sprintf("%s",$tmptxt[$i]);
else $str=sprintf("%s %s",$str,$tmptxt[$i]);
if((strlen($str) + strlen($tmptxt[$i+1])) > $cols)
{
pdf_fit_textline($p,$str,$xcrd,$ycrd,"");
$str="";
$ycrd-=$font_size;
}
}
pdf_fit_textline($p,$str,$xcrd,$ycrd,"");
$ycrd-=$font_size;
}
return $ycrd;
}`
add a note
PDF_get_apiname PDF_fit_textflow

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 10:36:09 2007 PST