简体   繁体   English

将html网页转换为pdf页面(用户将下载的pdf文件)

[英]Converting html webpage into a pdf page(pdf file which user will download)

I am developing a website in Cakephp framework, what i want to do, is to give the user option of downloading the page he is viewing in pdf format.I am using html2pdf plugin but its giving problem integrating with Cakephp. 我要在Cakephp框架中开发一个网站,我想做的是让用户选择以pdf格式下载他正在查看的页面。我使用的是html2pdf插件,但与Cakephp集成存在问题。 How can i solve this. 我该如何解决。 Thanx for your interest. 感谢您的关注。

Try TCPDF. 尝试TCPDF。 It is simple and powerful enough. 它既简单又强大。

Two options, one is paid and another open source. 有两种选择,一种是付费的,另一种是开源的。 Both are good, and well documented. 两者都很好,并且有据可查。

  1. PDFLib PDFLib来
  2. FPDF FPDF

I would suggest starting with FPDF, and then learning/moving to PDFLib 我建议从FPDF开始,然后学习/移至PDFLib

Using DOMPDF . 使用DOMPDF

Example Code : 示例代码:

<?php
    require_once("dompdf/dompdf_config.inc.php");

    $html = "<h1>some document</h1>";

    $dompdf = new DOMPDF();
    $dompdf->load_html($html);  
    $dompdf->set_paper('A4');
    $dompdf->render();
    $dompdf->stream("pdfReport.pdf");
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM