开发者

how to create PDF of dynamic contain using PHP script?

开发者 https://www.devze.com 2023-03-26 22:03 出处:网络
Data is generated dynamically by using php, and displayed on browser in specified Design format; we need to generate PDF of that design format with dynamic data?

Data is generated dynamically by using php, and displayed on browser in specified Design format; we need to generate PDF of that design format with dynamic data?

we have data in php Sting, want to convert data string in PDF.

$str="<html><body>
    <table width='100%'  cellspacing='0' cellpadding='0'>
    <tr>
    <td width='3%'>&nbsp;</td>
    <td width='98%' align='left'><br><img src='abs-path' border='0' alt='logo'>
    <br>
    <span class='style3'>Dear ".$name.",<br />
    <p>Many thanks for your Interest  
    <br />
    <br>
    Thanking You,<br />
    Secretariat <br>
    ".$addr."<br>

    </span></td>
    </tr>
    </table>

    </body>
 开发者_开发问答   </html>";

we have tried pdf function but its not working, when we call image dynamically using php. Also we have checked previously asked question regarding php-pdf, but still not able to solve the problem. please help us to generate PDF using php.


You can you pdf file generator like tcpdf or fpdf ..

you just need to use readymade functions .. from tcpdf


To generate a PDF-File using PHP is a task which is often done using a PHP-Library like:

  • FPDF
  • TCPDF

These two projects are the most common and both are up to date (support UTF-8 for example) and free. If you already use one of the above, please be more specific about what problem you're facing and what error-messages come up.

Both those library's use pure PHP to generate the PDF so you don't need to have "PDFlib" installed, which is used by the standard PDF-functions offered by PHP.


At work we use html2ps, which has one big advantage over all the other solutions: You don't need to write PDF specific code but can re-use the HTML you generated anyway. Also, this is easier to debug and automatically spreads the contents on several pages.


Hiii, I feel its better to use the FPDF.It's available at www.fpdf.org


I just started using the mpdf library, and it's quite nice (and free), you can use (a bit limited) html+css, ttf fonts, headers/footers, table of contents, index, and more.

Examples.


PHP has functions for PDF generation. You can't simply convert HTML to PDF though.


Try using the mpdf it is best.. below is the url for the same http://www.mpdf1.com/mpdf/index.php

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号