CakePdf icon indicating copy to clipboard operation
CakePdf copied to clipboard

parameters not passed to mPDF engenie

Open nilsonpena opened this issue 4 years ago • 3 comments

Metadata parameters not passed to mPDF engine. Am I doing something wrong? Cakephp 3.9 mPDF 8.0.4

Configure::write('CakePdf', [
            'engine' => [
                'className' => 'CakePdf.Mpdf',
                'options' => [
                    'SetTitle' => $this->titulo,
                    'SetAuthor' => $this->autor,
                    'SetCreator' => $this->criador,
                    'SetSubject' => $this->assunto,
                    'ShowWatermarkText' => true,
                    'SetWatermarkText' => 'RASCUNHO'
                ]
            ],

            'orientation' => 'portrait',
            'download' => true,
            'filename' => $local_file,
        ]);

nilsonpena avatar Apr 04 '21 13:04 nilsonpena

Well the options set through engine config are merged with other options and passed to Mpdf class constructor. https://github.com/FriendsOfCake/CakePdf/blob/f8b945187877f59030e307c1ab51a3457f7c6b67/src/Pdf/Engine/MpdfEngine.php#L34-L36

ADmad avatar Apr 06 '21 12:04 ADmad

Ok.... SetTitle, SetAuthor, SetSubject and SetCreator are methods of MPDF Class. It wont work this way!!!

But setWatermarkText and showWatermarkText are config variables.... Shuld works....

So, is there another way to set metadata (title, subject, creator, author) of PDF files?

nilsonpena avatar Apr 06 '21 17:04 nilsonpena

No, currently you can only pass options to the vendor class' constructor. There's no way to access the internal vendor class instance of the engine classes, so that you can call the methods you need.

ADmad avatar Apr 26 '21 18:04 ADmad