PHP Doku:: Platziert einzelne Textzeile - function.pdf-fit-textline.html

Verlauf / Chronik / History: (2) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzNon-Text MIME-AusgabenPDFPDF FunktionenPDF_fit_textline

Ein Service von Reinhard Neidl - Webprogrammierung.

PDF Funktionen

<<PDF_fit_textflow

PDF_get_apiname>>

PDF_fit_textline

(PECL pdflib >= 2.0.0)

PDF_fit_textlinePlatziert einzelne Textzeile

Beschreibung

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

Platziert eine einzelne Textzeile unter Berücksichtigung verschiedener Optionen am Referenzpunkt (x, y). Gibt bei Erfolg TRUE zurück. Im Fehlerfall wird FALSE zurückgegeben.


4 BenutzerBeiträge:
- Beiträge aktualisieren...
scott at dont want spam dot com
13.07.2009 0:49
One point about using the PDF_show_boxed function.

It does not support Unicode. So if you need that support you will need to use this function or the text flow functions.
eslindsey at gmail dot com
25.03.2009 3:17
For right now, if you are using PDFlib Lite, you can still use the legacy (depreciated) PDF_show_boxed or $p->show_boxed functions to create a text area. This seems to be a good (if not as full-featured) alternative to the textflow functions, and definitely a whole lot easier than trying to write your own text wrapping/hyphenation solution.
Chris at postal-code dot com
27.11.2006 22: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
12.07.2006 2: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;
}



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)