note 68065 added to function.pdf-fit-textline

From: Date: Wed, 12 Jul 2006 00:49:40 +0000
Subject: note 68065 added to function.pdf-fit-textline
Groups: php.notes 
Request: Send a blank email to php-notes+get-114684@lists.php.net to get a copy of this message
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; } ---- Server IP: 216.194.113.175 Probable Submitter: 65.168.37.75 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.pdf-fit-textline.php Edit -- http://master.php.net/note/edit/68065 Del: integrated -- http://master.php.net/note/delete/68065/integrated Del: useless -- http://master.php.net/note/delete/68065/useless Del: bad code -- http://master.php.net/note/delete/68065/bad+code Del: spam -- http://master.php.net/note/delete/68065/spam Del: non-english -- http://master.php.net/note/delete/68065/non-english Del: in docs -- http://master.php.net/note/delete/68065/in+docs Del: other reasons-- http://master.php.net/note/delete/68065 Reject -- http://master.php.net/note/reject/68065 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114684) next »