|
Posted by Ian Hobson on 11/16/07 22:14
Alan M Dunsmuir wrote:
> Is there a standard technique, in a PHP/MySQL Web Application, for users
> to be provided with printable-quality output - e.g. business invoices -
> created for them on the fly?
I don't know about "standard", but for one customer I am creating .pdf
files on the fly. He can then forward them by email or print them as he
wishes, using the integration of Adobe and Outlook Express (windows).
The library is public domain and can be found at http://www.ros.co.nz/pdf/
You will not like how page throws are handled! You can't know you need
to take a new page, until you over stepped the bottom of the page. The
work around is ugly - you detect that you are now on a new page, discard
back to the last check point, head the new page, and then output the
stuff you threw away again. Yeuk, but it works.
I ended up writing an adapter pattern so I could write lots of
do {
$text = "Please find below q.... ": // build a paragraph in $text
$text .= ".\n";
$pdf->ezText($text,$size,$opts); // add it
} while ($pdf->endsOnNewPage($this,'headpage'));
loops to send out the bits between possible break points.
It means I can forget all about driving printers, fax machines, or
emailing the results. I have included his (colour) letterhead, with its
image, so he prints on plain paper, with no line-up problems. The code
even get the addresses to appear in the window of the envelope every time.
Regards
Ian
[Back to original message]
|