HTML to PDF how can i convert into PDF?

#1

Well, i have used friendsofcake/cakepdf .This plugin used but i have design one certificate which is in html and css format when i call the function to convert pdf it will show the separate parts of certificate. css will not apply after the pdf conversion. how can resolve this type problem …Please suggest some solution

0 Likes

#2

Which engine are you using? Can you post some example code of what you’ve tried?

0 Likes

#3

Thanks for reply post.I have solved this problem, & i have used wkhtmltopdf engine.i have not to set default layout in pdf folder so the css will not to set to my acutal pdf.

0 Likes

#4

This is my Controller function …

public function exportpdf()
        {
            $invoice = $this->Countries->find();
            $this->viewBuilder()->setClassName('CakePdf.Pdf');
            $this->viewBuilder()->options([
                'pdfConfig' => [
                    'orientation' => 'portrait',
                    'filename' => 'certificate_'
                ],
                
            ]);
            $this->set('invoice', $invoice);
        }
///////////////////////////////////    this is bootstrap.php setup ////

Configure::write('CakePdf', [
    'engine' => [
        'className' => 'CakePdf.WkHtmlToPdf',
        'binary' => '/usr/bin/wkhtmltopdf', //LINUX
        //'binary' => 'C:\PROGRA~1\wkhtmltopdf\bin\wkhtmltopdf.exe', //WINDOWS
        'options' => [
            'print-media-type' => true,
            'outline' => true,
            'dpi' => 96
        ]
    ],
    'pageSize' => 'Letter',
]); 

But when i call the function it’s was long run but not any output.

0 Likes