Liebe Gemeinde,
ich möchte gerne mehrere PDF-Dateien per TCPDF erstellen. Leider erstellt er immer nur die erste und bricht dann ab. Hat jemand eine Idee?
Wird in einer WHILE-Schleife aufgerufen wenn ich die Daten zur Ausgabe beisammen habe.
ich möchte gerne mehrere PDF-Dateien per TCPDF erstellen. Leider erstellt er immer nur die erste und bricht dann ab. Hat jemand eine Idee?
PHP:
function pdf($pfad , $neuerDateiname, $output)
{
// Extend the TCPDF class to create custom Header and Footer
class MYPDF extends TCPDF
{
// Page footer
public function Footer()
{
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0, 10, '123'.$this->getAliasNumPage().'/'.$this->getAliasNbPages(), 0, false, 'C', 0, '', 0, false, 'T', 'M');
}
}
$obj_pdf = new MYPDF('L', PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false);
$obj_pdf->SetCreator(PDF_CREATOR);
$obj_pdf->SetTitle($neuerDateiname);
$obj_pdf->SetHeaderData('', '', PDF_HEADER_TITLE, PDF_HEADER_STRING);
$obj_pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$obj_pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
$obj_pdf->SetDefaultMonospacedFont('helvetica');
$obj_pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$obj_pdf->SetMargins(PDF_MARGIN_LEFT, '5', PDF_MARGIN_RIGHT);
$obj_pdf->setPrintHeader(false);
$obj_pdf->setPrintFooter(true);
$obj_pdf->SetAutoPageBreak(TRUE, 10);
$obj_pdf->SetFont('helvetica', '', 10);
$obj_pdf->AddPage();
$content = $output;
$obj_pdf->writeHTML($content);
//$obj_pdf->Output("C:\Apache24\htdocs\bildung-service.com_2022\data\user\SvenKasubek11\Gutschriften\/" . $monat .'_' . $jahr . '\/' .$dateiname , 'F');
//$pdf_string = $obj_pdf->Output('pdftmp.pdf', 'S');
//file_put_contents($pfad . '/' . $neuerDateiname, $pdf_string);
//unset($obj_pdf);
$obj_pdf->Output($pfad . '/' . $neuerDateiname , 'F');
unset($obj_pdf);
}
Wird in einer WHILE-Schleife aufgerufen wenn ich die Daten zur Ausgabe beisammen habe.
PHP:
while(...)
{
.. Daten sammeln
pdf($ordnerpfad , $neuerDateiname, $output);
}