-2

I want to convert the content of a php file (this file is generated using some query from mysql database along with some image)to html file in order to create a pdf format. I tried converting php file to pdf but could not be succeeded. Kindly help with very short example as I am very new to the area.Thanks in advance.

sdk
  • 1
  • 3
  • 1
    have you tried anything? and you can generate `pdf` with php also. – Sougata Bose Nov 07 '14 at 11:14
  • I do not understand this question at all. Have you got code examples? And can you explain your problem a little better? – Peter Nov 07 '14 at 11:16
  • Users fill up a form and submit. When a user want to get a print out of it, he supplies the application number and accordingly a php file is generated by querying from mysql database. Now I want to convert this php file to pdf to the user. I have tried but failed to do so. – sdk Nov 07 '14 at 11:21
  • possible duplicate of [Convert HTML + CSS to PDF with PHP?](http://stackoverflow.com/questions/391005/convert-html-css-to-pdf-with-php) – xmojmr Nov 07 '14 at 12:09

1 Answers1

0

you can generate a static html file from a url (to the php page) like so:

file_put_contents('static.html', file_get_contents('http://example.com/dynamic.php'));

Though writing the file to disk is probably unnecessary.

Probably your pdf function takes an html sting, in which case include and output buffering might be a suitable solution:

ob_start();
include 'dynamic.php';
$html = ob_get_clean();

create_pdf('mypdf.php', $html);

For a more specific example you would need to show your current code

Steve
  • 20,703
  • 5
  • 41
  • 67
  • I am explaining my problem once again----- I have a html file where i am inputting my application number. the action of this html page is act.php, in which his/her detail application gets print. Now I want to print this generated file to pdf. Kindly suggest me the way. Thanks in advance. – sdk Nov 20 '14 at 10:40