Jump to content

WirePDF download File


Frank Schneider
 Share

Recommended Posts

i create a pdf file with WirePdf on PW andand want it download to browser downloads folder.

$header = '';
$footer = $pages->get("/einstellungen/")->company_name;
$filename = 'Ausgabe.pdf';
 
error_reporting(0); // E_ALL=Melde alle PHP-Fehler 0=deaktiviert
ob_start();
ob_clean();
$pdf = $modules->get('WirePDF');
$pdf->pageFormat = 'A4';
$pdf->leftMargin = 20;
$pdf->rightMargin = 20;
$pdf->topMargin = 20;
$pdf->bottomMargin = 20;
 
$mpdf = $pdf->mpdf;
$mpdf->SetHTMLHeader($header);
$mpdf->SetHTMLFooter($footer);
$mpdf->WriteHTML($content);
ob_end_clean();
$mpdf->Output($filename, 'F');

 $mpdf->Output($filename, 'F'); works and create in template folder.

 $mpdf->Output(); not working and the browser shows, annot load file.

Know anyone the reason.

Ist it a parameter in PW?

 

Link to comment
Share on other sites

Looks like you’re using @Wanze’s module Pages2Pdf. Unfortunately that module is pretty outdated and not compatible with PHP 8. I recommend switching to @bernhard’s RockPdf:

$pdf = $modules->get('RockPdf');
$pdf->settings([
    'mode' => 'utf-8',
    'format' => [210, 297],
    'margin_top' => 20,
    'margin_bottom' => 20,
    'margin_left' => 20,
    'margin_right' => 20,
]);
$pdf->write("<h1>{$page->title}</h1>");
$pdf->write($page->body);
$pdf->download($page->name . '.pdf');

It comes with handy output methods:

Quote

You can use these methods to output your pdf files:

save() to save your file to the file system
show() to directly show your file in the browser
download() to force the browser to download the pdf

 

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...