简体   繁体   中英

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. How can i solve this. Thanx for your interest.

Try TCPDF. It is simple and powerful enough.

Two options, one is paid and another open source. Both are good, and well documented.

  1. PDFLib
  2. FPDF

I would suggest starting with FPDF, and then learning/moving to PDFLib

Using 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");
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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