Webpage convert to PDF button

后端 未结 3 1547
刺人心
刺人心 2021-01-05 10:57

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.

So I w

相关标签:
3条回答
  • 2021-01-05 11:35

    Use FPDF. It's a well-respected PDF-generating library for PHP that is written in pure PHP (so installing it should be dead simple for you).

    0 讨论(0)
  • 2021-01-05 11:35

    Try this: http://www.macronimous.com/resources/Converting_HTML2PDF_using_PHP.asp

    It will convert HTML to a PDF using FPDF and HTML2PDF class.

    Also found this:

    http://www.phpclasses.org/package/3168-PHP-Generate-PDF-documents-from-HTML-pages.html

    0 讨论(0)
  • 2021-01-05 11:49

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

    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');
    
    0 讨论(0)
提交回复
热议问题