Creation of the "Legal Size" for MPDF conversion, for long length page in php

To convert the multiple A4 size MPDF document into a single legal sized page


The following is a PHP code snippet :


Example code:

<?php

 include(FCPATH . 'assets/mpdf_core/mpdf.php'); // (This is local project mpdf library path)

    $mpdf = new mPDF(array('mode' => 'utf-8', 'format' => array(216, 356)));

    $mpdf->SetHeader($title);

    $mpdf->showWatermarkImage = true;


    $mpdf->AddPageByArray(array(

      'orientation' => 'P',

      // 'sheet-size' => 'Legal',

      'sheet-size' => array(230, 406), // (Declaration for the size of the sheet (230 is width and 406 is the length) )

    ));

    $mpdf->WriteHTML($html);

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

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

    $mpdf->SetAuthor("Dolphin"); // (hear dolphin is the water mark )

    $mpdf->SetWatermarkText("Dolphin");

    $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'));

    ob_clean();

    $mpdf->Output();

      $file_name = FCPATH . "assets/salary_reports/salary_month34.pdf"; // ( the path saved locally)

      

      $file_name = "performance_report" . $enquiry_id . ".pdf";

      $mpdf->Output($file_name , 'I'); // (This is the browser view)

      // $mpdf->Output($file_name , 'D'); // (This is for the purpose of download)

    }

?>


Images for your reference (BEFORE):


Legal page MPDF, now :


Sign In or Register to comment.