Hans de Vries
Hans de Vries

Reputation: 119

Webpage convert to PDF button

I have a website now and I want to create a button on it to convert this page to PDF. Is there any code to make this happen? I cannot find it on the internet.

So I want to have a button and when I press on it it converts the page to a .PDF file.

I do not want to use a third party website to generate the PDF's. I want to use it for internal purposes to generate files with PHP. So I need the code what can make a PDF for each page.

Upvotes: 6

Views: 18719

Answers (3)

Manse
Manse

Reputation: 38147

I use wkhtmltopdf - works very well - http://code.google.com/p/wkhtmltopdf/ there is a PHP wrapper

Updated based on comments below on usage :

How to use the integration class:

require_once('wkhtmltopdf/wkhtmltopdf.php');     // Ensure this path is correct !
$html = file_get_contents("http://www.google.com");
$pdf = new WKPDF();
$pdf->set_html($html);
$pdf->render();
$pdf->output(WKPDF::$PDF_EMBEDDED,'sample.pdf');

Upvotes: 5

Mike Thomsen
Mike Thomsen

Reputation: 37506

Use FPDF. It's a well-respected PDF-generating library for PHP that is written in pure PHP (so installing it should be dead simple for you).

Upvotes: 0

Related Questions