Re: HTML->PDF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux