kartik-v / yii2-mpdf

A Yii2 wrapper component for the mPDF library which generates PDF files from UTF-8 encoded HTML.
http://demos.krajee.com/mpdf
Other
161 stars 150 forks source link

Add mpdf watermark text attribute #88

Closed thiago-you closed 5 years ago

thiago-you commented 5 years ago

Scope

This pull request includes a

Changes

The following changes were made:

thiago-you commented 5 years ago

Mpdf have a lot of extra attributes. So its better to create an adapter that extends the yii2-mpdf and implement the required new features/properties.

kartik-v commented 5 years ago

You can achieve this without adding new properties for every mpdf setup this way as shown below (for your water marker):

use kartik\mpdf\Pdf;

$pdf = new Pdf([
    'methods' => [
        'SetWatermarkText' => '<your watermark text>',
    ],
    'options' => [
        'showWatermarkText' => true,
    ]
]);
// then wherever you need to render
echo $pdf->render();
thiago-you commented 5 years ago

Thanks Kartik. I had not seen the "methods" in the documents.