Untitled

mail@pastecode.io avatar
unknown
php
2 years ago
1.4 kB
5
Indexable
Never
 public function downloadBordro()
    {
        require_once __DIR__ . '../../third_party/mpdf/vendor/autoload.php';

        // Create an instance of the class:
        $mpdf = new \Mpdf\Mpdf(
            [
                'mode'              => 'utf-8',
                'format'            => 'A4',
                'orientation'       => 'P',
                'margin_left'       => 2,
                'margin_right'      => 2,
                'margin_top'        => 10,
                'default_font_size' => 7,
            ]
        );

        $bootstrapCss = file_get_contents(__DIR__ . '../../../assets/css/bootstrap.min.css');

        $customCss = '
            .row {
                margin-left: 0; 
                margin-right: 0; 
            }

            .row .col-xs-1, .row .col-xs-2, .row .col-xs-3, .row .col-xs-4, .row .col-xs-5, .row .col-xs-6, .row .col-xs-7, .row .col-xs-8, .row .col-xs-9, .row .col-xs-10, .row .col-xs-11, .row .col-xs-12 {
                padding-left: 0;
                padding-right: 0;
            }
            
        ';

        $combinedCss = $bootstrapCss . $customCss;

        $mpdf->WriteHTML($combinedCss, 1);
        $html = $this->load->view('bordro/bordro_pdf', '', true);
        $mpdf->WriteHTML($html,2);

        // Output a PDF file directly to the browser
        $mpdf->Output();

    }