Generate PDF report from php

后端 未结 4 1716
醉话见心
醉话见心 2020-11-28 14:50

I am using php code to query to a database and the results will be used to generate a report.

If I want the report to be generated in a pdf format how should I do it

相关标签:
4条回答
  • 2020-11-28 15:06

    Look into html2pdf

    Create your report as html and then run the code to transform into PDF. You don't need to know the language to generate the PDF blocks. Submitted forms work out cool too.

    0 讨论(0)
  • 2020-11-28 15:14

    I've used TCPDF (http://www.tcpdf.org/) for my last project. It worked pretty good but the next time im going for a html to pdf converter, simply because designing the report (converting to pdf draw statements) was such a time sink.

    So i would suggest http://sourceforge.net/projects/html2fpdf/

    0 讨论(0)
  • 2020-11-28 15:17

    If you need UTF support in your PDF file, consider tcpdf library.

    Download it from here: http://www.tecnick.com/public/code/cp_dpage.php?aiocp_dp=tcpdf

    And in your script:

    <?php
    //include files
    require_once($_SERVER['DOCUMENT_ROOT'].'/tcpdf/config/lang/eng.php');
    require_once($_SERVER['DOCUMENT_ROOT'].'/tcpdf/tcpdf.php');
    
    // create new PDF document
    $pdf = new TCPDF(PDF_PAGE_ORIENTATION, PDF_UNIT, PDF_PAGE_FORMAT, true, 'UTF-8', false); 
    
    //add some content using class methods
    
    //Close and output PDF document
    $pdf->Output('filename.pdf', 'I');
    ?>
    
    0 讨论(0)
  • 2020-11-28 15:19

    You can also use FPDF, I've used that for several projects. In the beginning you will be annoyed a lot, but when you get used to it, it will get easier to create pdf's :)

    0 讨论(0)
提交回复
热议问题