[英]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. 我现在有一个网站,我想在其上创建一个按钮以将该页面转换为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. 所以我想有一个按钮,当我按下它时,它将页面转换为.PDF文件。
I do not want to use a third party website to generate the PDF's. 我不想使用第三方网站来生成PDF。 I want to use it for internal purposes to generate files with PHP.
我想将其用于内部目的以通过PHP生成文件。 So I need the code what can make a PDF for each page.
因此,我需要可以为每页制作PDF的代码。
I use wkhtmltopdf - works very well - http://code.google.com/p/wkhtmltopdf/ there is a PHP wrapper 我使用wkhtmltopdf-效果很好-http: //code.google.com/p/wkhtmltopdf/有一个PHP包装器
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');
Try this: http://www.macronimous.com/resources/Converting_HTML2PDF_using_PHP.asp 试试这个: http : //www.macronimous.com/resources/Converting_HTML2PDF_using_PHP.asp
It will convert HTML to a PDF using FPDF and HTML2PDF class. 它将使用FPDF和HTML2PDF类将HTML转换为PDF。
Also found this: 还发现了这一点:
http://www.phpclasses.org/package/3168-PHP-Generate-PDF-documents-from-HTML-pages.html http://www.phpclasses.org/package/3168-PHP-Generate-PDF-documents-from-HTML-pages.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.