网页转换为PDF按钮 [英] Webpage convert to PDF button

查看:111
本文介绍了网页转换为PDF按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在有一个网站,我想在其上创建一个按钮以将该页面转换为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.

所以我想要一个按钮,当我按下它时,它将页面转换为.PDF文件.

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

我不想使用第三方网站来生成PDF.我想将其用于内部目的以使用PHP生成文件.因此,我需要可以为每页制作PDF的代码.

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.

推荐答案

我使用wkhtmltopdf-效果很好- http://code.google.com/p/wkhtmltopdf/有一个PHP包装器

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

根据以下有关用法的评论进行了更新:

Updated based on comments below on usage :

如何使用集成类:

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');

这篇关于网页转换为PDF按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆