Skip to content

Instantly share code, notes, and snippets.

@aur1mas
Created December 8, 2010 10:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aur1mas/733109 to your computer and use it in GitHub Desktop.
Save aur1mas/733109 to your computer and use it in GitHub Desktop.
<?php
try {
$wkhtmltopdf = new Wkhtmltopdf(array('path' => APPLICATION_PATH . '/../public/uploads/'));
$wkhtmltopdf->setTitle("Title");
$wkhtmltopdf->setHtml("Content");
$wkhtmltopdf->output(Wkhtmltopdf::MODE_DOWNLOAD, "file.pdf");
} catch (Exception $e) {
echo $e->getMessage();
}
@clemherreman
Copy link

Maybe you meant new Wkhtmltopdf instead of new Core_Wkhtmltopdf ?

@aur1mas
Copy link
Author

aur1mas commented Oct 21, 2011

clemherreman, yep :) mistype from copy & pasting the code.

@rom117
Copy link

rom117 commented Oct 25, 2011

Hello,
I'm currently trying to use Wkhtmltopdf but it's not working... not yet at least.
I do have a pdf file at the end but it is not readable.

My code to run the class:

'/var/www/test/')); //$wkhtmltopdf = new Wkhtmltopdf(array('path' => APPLICATION_PATH . '/../public/uploads/')); $wkhtmltopdf->setTitle("Title"); $wkhtmltopdf->setHtml("http://www.google.com"); $wkhtmltopdf->output(Wkhtmltopdf::MODE_DOWNLOAD, "myfile.pdf"); } catch (Exception $e) { echo $e->getMessage(); } ``` ?>

Any idea of the problem?

Thanks in advance,

Romain

PS: I am working with Linux

@clemherreman
Copy link

My guess is that your wkhtomtopdf must have some problem.
Display the full exception, and not only the message, and also display the return of Wkhtmltopdf::_render, you'll have plenty of information to debug this =).

@rom117
Copy link

rom117 commented Oct 29, 2011

Hello,

Thank you for your reply.
I've added the line $wkhtmltopdf->Wkhtmltopdf::_render; at the end.
I've got this error: "The website encountered an error while retrieving http://localhost/test/. It may be down for maintenance or configured incorrectly".
So it's not working anymore.

How can I display the full exception?

Many thanks,

Romain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment