Re: HTML->PDF
| From: | Robert Sossomon | Date: | Fri, 12 Nov 2004 21:25:23 +0000 |
| Subject: | Re: HTML->PDF | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201877@lists.php.net to get a copy of this message | ||
Amanda Hemmerich is quoted as saying on 11/12/2004 4:01 PM:
Is there a fairly straightforward way to generate a PDF out of a .php file that's made up of includes and the includes are contructed dynamically using data from mysql? This page normally displays the info based on parameters passed through the url or through a form. I've been looking <SNIP>Here's what I used to use, and i know that there are better ways to do it now, but it works for me: a form to pass the data from, and then some includes <?php //HTML2PDF by Clément Lavoillotte include_once('/home/fpdf/fpdf/html2pdf.php'); //connect to database include 'db.php'; include 'salesinfo.php'; $order_id = $_POST[order_id]; $faxnumber = $_POST[faxnum]; $html = ""; $time = "-"; $time .= date("mdY-His"); $outtie = "/saved_quotes/$user"; $title = "Quote for $acct $uFname $uLname on $today"; $subject = "Quote for $acct $uFname $uLname on $today"; $author = "$uFname $uLname"; $outtie .= "-"; $html .= "<html>\n<head>\n<title>"; $html .= $title; $html .= "</title>\n</head>\n<body bgcolor=\"white\">\n"; include 'order_header.php'; $html .= $header_block; include 'views_order_head.php'; $html .= $view_head_block; include 'views_order_body.php'; $html .= $display_block; $html .= "\n</body>\n</html>"; $outtie .= $num; $outtie .= $time; $tempfilename = $outtie; $outps = $outtie; $outps .= ".ps"; $tempfilename .= ".html"; $outtie .= ".pdf"; $out_url = "/saved_quotes/$user-$num$time.pdf"; $tempfile = fopen($tempfilename,'w'); fwrite($tempfile, $html); fclose($tempfile); $last_line = system("/usr/local/bin/html2ps $tempfilename > $outps", $retval); $last_line = system("/usr/bin/ps2pdf $outps $outtie", $retval); $last_line = system("/usr/bin/sendfax -n -d $faxnumber $outtie", $retval); $ps_line = system("/bin/rm -f $outps", $retval); //header("Location: $out_url"); //exit; HTH, Robert -- Robert Sossomon, Business and Technology Application Technician 4-H Youth Development Department 200 Ricks Hall, Campus Box 7606 N.C. State University Raleigh NC 27695-7606 Phone: 919/515-8474 Fax: 919/515-7812 robert_sossomon@ncsu.edu