I can not see the content of my pdf help ! :, c


(Jorge+) #1

I’ve been trying to generate a pdf for several days, and the truth is that I do not know what else to do, I’ve already gone through several errors to create a pdf and now my biggest achievement is a blank sheet.
And although I have a view that should be shown, it is not seen.
I leave the code that I use in my controller:
$ model = $ this-> loadModel ($ id);
$ mPDF1 = Yii :: app () -> ePdf-> mpdf (‘utf-8’, ‘A4’, ‘’, ‘’, 15,15,35,25,9,9, ‘P’);
// $ mPDF1-> useOnlyCoreFonts = true;
$ mPDF1-> SetTitle (“Family Credential”);
$ mPDF1-> SetAuthor ("");
// $ mPDF1-> SetDisplayMode (‘fullpage’);
$ mPDF1-> WriteHTML ($ this-> renderPartial (‘pdf’, array (‘model’ => $ this-> loadModel ($ id)), true));
ob_end_clean ();
$ mPDF1-> Output ();
exit;
I hope and can receive your support, I have already received a lot from this community and the truth I thank you.


(libedux) #2

why don’t you use Kartik’s PDF package.Here is a working example;

         // setup kartik\mpdf\Pdf component
    $pdf = new Pdf([
        'filename' => $filename,
        // set to use core fonts only
        'mode' => Pdf::MODE_UTF8,
        // A4 paper format
        'format' => Pdf::FORMAT_A4,
        // portrait orientation
        'orientation' => Pdf::ORIENT_LANDSCAPE,
        // stream to browser inline
        'destination' => Pdf::DEST_STRING,
        // your html content input
        'content' => $content,

        'cssInline' => '<style>
     * {
        font-family: DejaVu Sans, sans-serif;
    }

    table {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
    }

    td, th {
        text-align: left;
        font-size: 8px;
        padding: 2px;
    }
</style>',
        // set mPDF properties on the fly
        'options' => ['title' => ' Report'],
        // call mPDF methods on the fly
        'methods' => [
            'SetFooter' => ['{PAGENO}'],
        ]
    ]);

    // return the pdf output as per the destination setting
    return $pdf->render();

(Jorge+) #3

It looks interesting and good.
But I do not use another package because I’m working for someone, and that someone asked me to use mpdf.
Unless I misunderstood and that package can be used in conjunction with mpdf.