Search code examples
phpmacosubuntuwkhtmltopdf

Can not print pdf using wkhtmltopdf on mac


I'm using wkhtmltopdf library in my code-igniter application for printing. I'm using vagrant ubuntu on mac.

Url is like

> http://localhost:8084/{sitename}/{controller_name}/{function}

Code snippet is

> $pdf = new WKPDF();
>     // Set PDF's HTML
>     $html_in_string = "<html><body>Content goes here</body></html>";
>     $pdf->set_html($html_in_string);
>     // Convert HTML to PDF
>     $pdf->render();
>     // Output PDF. The file name is suggested to the browser.
>     $pdf->output(WKPDF::$PDF_EMBEDDED, 'print_file_name.pdf');

But it shows "Failed to load PDF document."

PDF document is not created in cache/temp.

Any help will be highly appreciated.


Solution

  • Please remove port from the url;

    http://localhost/{sitename}/{controller_name}/{function}
    

    i hope that will fix the issue;