PHP Doku:: Erzeugt ein Textflussobjekt oder fügt Text zu einem Textflussobjekt hinzu - function.pdf-add-textflow.html

Verlauf / Chronik / History: (1) anzeigen

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

Ein Service von Reinhard Neidl - Webprogrammierung.

PDF Funktionen

<<PDF_add_table_cell

PDF_add_thumbnail>>

PDF_add_textflow

(PECL pdflib >= 2.1.0)

PDF_add_textflowErzeugt ein Textflussobjekt oder fügt Text zu einem Textflussobjekt hinzu

Beschreibung

int PDF_add_textflow ( resource $pdfdoc , int $textflow , string $text , string $optlist )

Erzeugt ein Textflussobjekt oder fügt Text und spezielle Optionen zu einem vorhandenen Textfluss hinzu.


Ein BenutzerBeitrag:
- Beiträge aktualisieren...
david
1.10.2008 18:19
If you get an error like this:

PHP Fatal error:  Allowed memory size of 16777216 bytes exhausted (tried to allocate 3072 bytes) in /var/www/html/pdf/starter_textflow.php on line 70

It is because you are sending too much data to the "add_textflow" function.  Increasing the memory in the php.ini file won't fix the problem.  The solution is to try buffering the data you send to the function.

For example, if this fails:

<?php
$text
=
"Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";

//send lots of data all at once
$max=100;
for(
$i=0;$i<$max;$i++)
  
$text .= $text;

$tf = $p->add_textflow($tf, $text, $optlist1);
?>


Try something like this instead:

<?php
$text
=
"Lorem ipsum dolor sit amet, consectetur adi­pi­sicing elit, sed do eius­mod tempor incidi­dunt ut labore et dolore magna ali­qua. Ut enim ad minim ve­niam, quis nostrud exer­citation ull­amco la­bo­ris nisi ut ali­quip ex ea commodo con­sequat. Duis aute irure dolor in repre­henderit in voluptate velit esse cillum dolore eu fugiat nulla pari­atur. Excep­teur sint occae­cat cupi­datat non proident, sunt in culpa qui officia dese­runt mollit anim id est laborum. ";

//send chunks of data
$max=100;
for(
$i=0;$i<$max;$i++)
  
$tf = $p->add_textflow($tf, $text, $optlist1);
?>


In the second example we send less data, but we call the function more often.  With the first example, I could only generate 3 or 4 pages of a PDF; with the latter example I could generate 200+ page PDF's.

This took me a while to debug; hope it saves someone else some time. :)



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",...)