HTML to PDF how can i convert into PDF?

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

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

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.

This is my Controller function …

public function exportpdf()
            $invoice = $this->Countries->find();
                '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.

I have got an error failed to load Failed to load PDF document. i have check git error posting same issue. but my app have no errors. but getting this error.

I have always ran into permission issues when I get PDF generation errors. Try pushing the file to a very public location (/app/tmp/ or /tmp) and ensure permissions are 777 for the directory, just as a test. Sometimes www-data is trying to write the pdf, but it doesn’t have write permissions for /usr/bin/…

Open the file in a text editor (Like VSCode), often that error means the there is a PHP error/warning in the PDF file.

1 Like

This Problem solved by myself. same solution used for find issue. Thank You for great time.

i didnt have “WkHtmlToPdf”…then what i have to do please tell for me

Is installing WkHtmlToPdf an option for you?

yah… i got it through tcpdf engine

You need to install friendsofcake/cakepdf package. well your problem is solved by the way

1 Like