vikas rane
vikas rane

Reputation: 13

how to create PDF of dynamic contain using PHP script?

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.

Upvotes: 0

Views: 22392

Answers (7)

Bhavik
Bhavik

Reputation: 9

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

Upvotes: 0

sim642
sim642

Reputation: 769

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

Upvotes: 0

biziclop
biziclop

Reputation: 14616

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.

Upvotes: 0

Rukmi Patel
Rukmi Patel

Reputation: 2561

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

you just need to use readymade functions .. from tcpdf

Upvotes: 4

kiran tej
kiran tej

Reputation: 11

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

Upvotes: 1

cweiske
cweiske

Reputation: 31107

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.

Upvotes: 1

Lukas Knuth
Lukas Knuth

Reputation: 25755

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

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.

Upvotes: 1

Related Questions