Convert Webpage to PDF

Now I have a website, and I want to create a button on it to convert this page to PDF. Is there any code to make this happen? I can not find it on the Internet.

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

I do not want to use a third-party website to create PDF files. I want to use it for internal purposes to create files with PHP. So I need code that can do a PDF for every page.

+5
source share
3 answers

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

Updated based on comments below for use:

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'); 
+5
source

Use FPDF . This is a well-established library for creating PDF files for PHP, written in pure PHP (so installing it should be easy for you).

0
source
0
source

Source: https://habr.com/ru/post/951272/


All Articles