Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Webpage convert to PDF button

Tags:

html

php

pdf

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.

like image 956
Hans de Vries Avatar asked Nov 08 '11 12:11

Hans de Vries


People also ask

How do I turn an entire web page into a PDF?

The fastest way to convert an open web page to PDF is to use the Adobe PDF toolbar. If you have the toolbar installed in your browser, simply select the Convert To PDF tool. Give your new PDF file a name, select Save, and voila — the conversion is done.

Where is the Convert to PDF button?

The Adobe PDF Maker toolbar is normally located in the upper left-hand corner, just under the Standard toolbar. If you don't see the button, click View -> Toolbars -> Acrobat PDFMaker. Note that there are two conversion buttons, the “Convert to Adobe PDF” button is on the left.


1 Answers

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');
like image 86
Manse Avatar answered Sep 16 '22 19:09

Manse