$preg_begin = "\\[(.+)"; $preg_end = "\\[\\/(.+)"; $count_tag = 0; $stand = ""; foreach ($out as $inhalt) { $count_tag++; $endtag = 0; if (preg_match_all("/" . $preg_begin . "/Us", $inhalt, $match)) { if (preg_match_all("/\\[\\/" . $match[1][0] . ".*\\]/Us", $inhalt, $match_end)) { $endtag = -1; } $item = $match[1][0] . $count_tag; ${$item} = $pdf->begin_item($match[1][0], ""); $inhalt = preg_replace("/\\[[\\/A-Za-z0-9=]*\\]/", "", $inhalt); #$inhalt = preg_replace("/\[.*\]/","",$inhalt); $textflow = $pdf->create_textflow($inhalt, "fontname=" . $fontname . " fontsize=10 textformat=utf8 encoding=unicode "); if ($stand == "") { $pdf->fit_textflow($textflow, 50, 120, 550, 820, ""); } else { $pdf->fit_textflow($textflow, 50, 120, 550, $stand, ""); } $stand = $pdf->info_textflow($textflow, "textendy") - 20; } if ($endtag == -1) { $pdf->end_item(${$match}[1][0] . $count_tag); } } $pdf->end_item($doc); $pdf->end_page_ext(""); $pdf->end_document(""); $buf = $pdf->get_buffer();
/* open new PDF file; insert a file name to create the PDF on disk */ if ($p->begin_document('', '') == 0) { die("Error: " . $p->get_errmsg()); } $p->begin_page_ext(1100, 600, ''); $tfcreate_options = array('fontname=Helvetica', 'fontsize=' . $_REQUEST['fontsize'], 'encoding=winansi'); $tfcreate_options[] = 'alignment=' . $_REQUEST['alignment']; $tfcreate_options[] = 'adjustmethod=' . $_REQUEST['adjustmethod']; $tfcreate_options[] = 'maxspacing=' . $_REQUEST['maxspacing']; $tfcreate_options[] = 'minspacing=' . $_REQUEST['minspacing']; $tfcreate_options[] = 'nofitlimit=' . $_REQUEST['nofitlimit']; $tfcreate_options[] = 'shrinklimit=' . $_REQUEST['shrinklimit']; $tfcreate_options[] = 'spreadlimit=' . $_REQUEST['spreadlimit']; $tfcreate_options[] = 'charspacing=' . $_REQUEST['charspacing']; $tffit_options = array('showborder=true'); $tf1 = $p->create_textflow($_REQUEST['text'], implode(' ', $tfcreate_options)); $tf2 = $p->create_textflow($_REQUEST['text'], implode(' ', $tfcreate_options)); $tf3 = $p->create_textflow($_REQUEST['text'], implode(' ', $tfcreate_options)); $tf4 = $p->create_textflow($_REQUEST['text'], implode(' ', $tfcreate_options)); $p->fit_textflow($tf1, 20, 20, 400, 580, implode(' ', $tffit_options)); $p->fit_textflow($tf2, 420, 20, 720, 580, implode(' ', $tffit_options)); $p->fit_textflow($tf3, 740, 20, 960, 580, implode(' ', $tffit_options)); $p->fit_textflow($tf4, 980, 20, 1080, 580, implode(' ', $tffit_options)); $p->delete_textflow($tf1); $p->delete_textflow($tf2); $p->delete_textflow($tf3); $p->delete_textflow($tf4); $tf = $p->create_textflow(implode(' ', $tfcreate_options), 'fontname=Helvetica fontsize=9 encoding=winansi'); $p->fit_textflow($tf, 5, 5, 1095, 18, implode(' ', $tffit_options)); $p->delete_textflow($tf); $p->end_page_ext('');