Kova_Llano Posted March 12, 2014 Share Posted March 12, 2014 as far i compare, mpdf is quite amazing, simple and easy. others conversion library is tcpdf, fpdf, dompdf, wkhtml2pdf.. so far, only fpdf and mpdf can convert the php to pdf. i try to convert a php form to pdf. for example when we want to book a flight ticket. after the booking process, we will get the booking details in pdf form. any idea how to implement the pdf in php form? Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 12, 2014 Share Posted March 12, 2014 (edited) ?? I think you are saying you want to create a pdf out the html on your screen. (There is NO php on your client screen, only HTML). Using fpdf you create the pdf from your data in a php script without using html. Fpdf has several functions that you use to output your data according to how you want the pdf to appear when done. Then you output the new pdf file to a separate screen (target) or else be sure you do not send any other output to the current window. Edited March 12, 2014 by ginerjm Quote Link to comment Share on other sites More sharing options...
Kova_Llano Posted March 13, 2014 Author Share Posted March 13, 2014 ok... fpdf is doing it manually and had done it line by line and takes time, so i was looking other alternative that convert whole html to pdf..... Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 13, 2014 Share Posted March 13, 2014 Good luck. I looked a couple years ago and could not find anything. Quote Link to comment Share on other sites More sharing options...
trq Posted March 13, 2014 Share Posted March 13, 2014 wkhtml2pdf does exactly what your asking. Easy to use too. Quote Link to comment Share on other sites More sharing options...
Kova_Llano Posted March 13, 2014 Author Share Posted March 13, 2014 Good luck. I looked a couple years ago and could not find anything. so, do you manage to do something? wkhtml2pdf does exactly what your asking. Easy to use too. not understand how use composer.jason Quote Link to comment Share on other sites More sharing options...
trq Posted March 13, 2014 Share Posted March 13, 2014 not understand how use composer.jason I don't see what that has to do with it, wkhtml2pdf is a command line program but anyway... Composer has a manual. https://getcomposer.org/doc/00-intro.md Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 13, 2014 Share Posted March 13, 2014 I picked up fpdf and figured it out. It's not that hard - reminds of the days when I used to program Cobol and had to lay out reports by hand and then program to fit the layout. Quote Link to comment Share on other sites More sharing options...
Kova_Llano Posted March 14, 2014 Author Share Posted March 14, 2014 I picked up fpdf and figured it out. It's not that hard - reminds of the days when I used to program Cobol and had to lay out reports by hand and then program to fit the layout. yea, not that hard. just quite hard to adjust table content. I don't see what that has to do with it, wkhtml2pdf is a command line program but anyway... Composer has a manual. https://getcomposer.org/doc/00-intro.md ok.. that wkhtml2pdf is some sort of software that convert the html page to pdf? yes, its simple. but its not what i want. because the user need to install wkhtml2pdf on the pc. else, cant print out pdf report Quote Link to comment Share on other sites More sharing options...
ginerjm Posted March 14, 2014 Share Posted March 14, 2014 Don't understand what you mean about adjusting table content. With fpdf you design the output the way you want it. If you want to do a table it's not much different than an html table. Just set up the widths of the columns to be on your pdf report and use them for each of the cells in each row of the pdf table. No different than the <col> tags of an html table Quote Link to comment Share on other sites More sharing options...
trq Posted March 14, 2014 Share Posted March 14, 2014 but its not what i want. because the user need to install wkhtml2pdf on the pc. else, cant print out pdf report No. You install wkhtml2pdf on the server. It's all done server side. Quote Link to comment Share on other sites More sharing options...
Kova_Llano Posted March 18, 2014 Author Share Posted March 18, 2014 No. You install wkhtml2pdf on the server. It's all done server side. oh i see. good tips.. tyvm... well, i almost finish my industrial attachment and had to present it next week. the only problems now is this pdf matter.. try see the attachment i put below. i did try wkhtml2pdf.. it works awesome. easily generate.. Don't understand what you mean about adjusting table content. With fpdf you design the output the way you want it. If you want to do a table it's not much different than an html table. Just set up the widths of the columns to be on your pdf report and use them for each of the cells in each row of the pdf table. No different than the <col> tags of an html table fpdf had to design the table. else, it bcme awful. lol... so, my last resolution is using html2pdf after many tries using mPDF, fpdf, dompdf and TCPDF. as you see in my file attachment below, i'm adjusting the font and the alignment of the pdf.. not yet put sql command as i want to make it look nice then i will put sql command. Quote Link to comment Share on other sites More sharing options...
Kova_Llano Posted March 18, 2014 Author Share Posted March 18, 2014 this too Quote Link to comment Share on other sites More sharing options...
Yohanne Posted March 18, 2014 Share Posted March 18, 2014 Hi kova, try this and hope it will help you. pdf_lib.php <?php function phptopdf_url($source_url,$save_directory,$save_filename) { $API_KEY = 'egtyuhes66r8rb3v5'; $url = 'http://phptopdf.com/urltopdf.php?key='.$API_KEY.'&url='.urlencode($source_url); $resultsXml = file_get_contents(($url)); file_put_contents($save_directory.$save_filename,$resultsXml); } function phptopdf_html($html,$save_directory,$save_filename) { $API_KEY = 'egtyuhes66r8rb3v5'; $postdata = http_build_query( array( 'html' => $html, 'key' => $API_KEY ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $resultsXml = file_get_contents('http://phptopdf.com/htmltopdf.php', false, $context); file_put_contents($save_directory.$save_filename,$resultsXml); } ?> index.php <?php include_once('pdf_lib.php') ; $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <body> <p>page page page page</p> </body> </html>'; phptopdf_html($html,'my_pdf_filename.pdf'); echo "<a href='filename.pdf'>Download PDF</a>"; ?> phptopdf_html($html,'pdf/', 'my_pdf_filename.pdf'); echo "<a href='pdf/my_pdf_filename.pdf'>Download PDF</a>"; Quote Link to comment Share on other sites More sharing options...
Kova_Llano Posted March 18, 2014 Author Share Posted March 18, 2014 Hi kova, try this and hope it will help you. pdf_lib.php <?php function phptopdf_url($source_url,$save_directory,$save_filename) { $API_KEY = 'egtyuhes66r8rb3v5'; $url = 'http://phptopdf.com/urltopdf.php?key='.$API_KEY.'&url='.urlencode($source_url); $resultsXml = file_get_contents(($url)); file_put_contents($save_directory.$save_filename,$resultsXml); } function phptopdf_html($html,$save_directory,$save_filename) { $API_KEY = 'egtyuhes66r8rb3v5'; $postdata = http_build_query( array( 'html' => $html, 'key' => $API_KEY ) ); $opts = array('http' => array( 'method' => 'POST', 'header' => 'Content-type: application/x-www-form-urlencoded', 'content' => $postdata ) ); $context = stream_context_create($opts); $resultsXml = file_get_contents('http://phptopdf.com/htmltopdf.php', false, $context); file_put_contents($save_directory.$save_filename,$resultsXml); } ?> index.php <?php include_once('pdf_lib.php') ; $html = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title></title> <body> <p>page page page page</p> </body> </html>'; phptopdf_html($html,'my_pdf_filename.pdf'); echo "<a href='filename.pdf'>Download PDF</a>"; ?> phptopdf_html($html,'pdf/', 'my_pdf_filename.pdf'); echo "<a href='pdf/my_pdf_filename.pdf'>Download PDF</a>"; thanks.. but no output shown Quote Link to comment Share on other sites More sharing options...
Yohanne Posted March 19, 2014 Share Posted March 19, 2014 what do you mean by no output? Quote Link to comment Share on other sites More sharing options...
Kova_Llano Posted March 19, 2014 Author Share Posted March 19, 2014 what do you mean by no output? it does not appear anything can show yours how it look like? have attachment file. try to implement it? borang_ot.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.