How to set a failed download MPDF file in PHP

edited April 2023 in PHP

MPDG error:

So that it will clear all buffered output before processing mPDF.

<?php

ob_start(); // In order to enable the output buffering one must use the ob_start() function before any HTML content in a script.

include(FCPATH . 'assets/mpdf_core/mpdf.php'); // local project saved file path

  $mpdf = new mPDF('', '', 0, '', 15, 15, 8, 8, 9, 9, 'L');

        $mpdf->useOnlyCoreFonts = false; // false is default

        $mpdf->SetProtection(array('print'));

        $mpdf->SetAuthor("Dolphin"); // your required name

        $mpdf->SetWatermarkText("Dolphin"); // your required name

        $mpdf->showWatermarkText = true;

        $mpdf->watermark_font = 'DejaVuSansCondensed';

        $mpdf->watermarkTextAlpha = 0.06;

        $mpdf->SetDisplayMode('fullpage');

        $mpdf->list_indent_first_level = 0;

        $mpdf->WriteHTML(mb_convert_encoding($html, 'UTF-8')); // $html is mpdf HTML page content

ob_clean();

        $mpdf->Output();

$quotefilename = $html;

       $mpdf->Output($quotefilename, 'I'); // view the file from browser

 $mpdf->Output($quotefilename, 'D'); // download the file

Sign In or Register to comment.