How to print....

Hi,

I am writing a web application that at the end prints out an invoice.  I am using a web browser for
my interface web forms to get the information from the user.  The program is all written using php and
mysql.  I am wondering what is the best way to print out my invoices at the end?  If I print the web
page directly from the web brower then i get the http://address and page number printed on the page and I don't want
that printed out on the invoice.  I tried making it create a rtf file which worked ok but I was thinking
of creating a pdf.  What is the easiest way to do this.  I was thinking of creating a template and maybe
do a search and replace.  Can someone please let me know the best way to create a pdf or if someone
has a better idea let me know that.
I really don't want to use pdflib because it cost $500.00 I am not making much from the program.

Has any ever used http://ros.co.nz/pdf/ I just found it now?

Thanks
LVL 1
onestarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lokeshvCommented:
a easy way..

Use frames and print only the specific frame...

LK
0
BatalfCommented:
I have created our own invoices using pdf-lib(downloadable from www.pdflib.com). To create pdf's is much better than plain HTML-files. RTF-files is also an option but pdf is after my opinion better because:

* Easier to put text and boxes at an accurate position
* The content of the pdf-document is not that easy to change as the content of an pdf.

I have never used http://ros.co.nz/pdf/ before, but it doesn't seem to be be any better than the original pdf-commands.

So my recommendation is that you use pdf-lib for this task(all pdf-lib commands are described at php.net, and they all start with pdf_ .......)

Batalf

 
0
onestarAuthor Commented:
The biggest issue I have with pdflib is the price $500.00 is a lot of money.  I wouldn't mind paying some money but not that much. It seems kind of weird that it costs so much when php is free.

http://ros.co.nz/pdf/ is free.  So if you don't think its better do you think it close to being equal.  I would rather learn that simply because its free.

I can't believe that these are my only 2 options.  I think creating pdf's are the best option for the invoices.
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

BatalfCommented:
I didn't know the price of pdflib. I was so sure that it was free. I think it was free not long ago.

I have checked out the link you gave, and it seems to be a good alternative. One thing I liked about it was that you was able to print html and get the formatting on the pdf. That's not possible with pdf-lib as far as I know.

Why don't you download both pdflib and the code from ros.co.nz and test them out. They don't take any charge for pdflib if you don't use it for a commercial product.

PDF is no matter what a better choice than rtf. A tip if you want to use rtf is to create the rtf-file in for instance wordpad(DON'T USE WORD - It creates a lot of messy code). Then put in your own tags in the document and let php replace the tags with the data of this invoice. For instance:

<firstname> <lastname>

would be replaced with the first and lastname of the person this invoice should be sent to.

The point is to create a rtf-template with some static text and some own tags(a lot like xml-tags). Then use this template in all your invoices, perform search&replace and store a new copy of the modified rtf as the new invoice.

Batalf
0
onestarAuthor Commented:
Actually I tried the rtf thing first and it worked okay but then it screwed up my ms word program.  I kept saying some about the dot template has been changed or something like that.  I did what you said with the search and replace.  I don't really like how word intergrates with the web browser compared to pdfs.

What I have done know is created a template in corel and then created a pdf with my tags <<invoice#>> etc... and then did a search and replace on the pdf.  The problem I had is you must be able to create a pdf with it uncompressed so you can find your tags.  I have tried about 15 different ways to create the pdf and only one worked after I did the search and replace most of the time it says the pdf is corrupt.  But the one program I have that worked has a bug with corel and it took out all the spacing in the pdf.  So that's where I am at manually fix all the spacing or find another way. I also have a new job coming up for a company to redesign how there whole company runs using a database, it has a lot of different excel and word documents that will have to be created.  They won't care if I switch them to pdf's so I like to come up with a good way to create dynamic documents that need to be printed correctly.



Thanks
Onestar
0
us111Commented:
http://www.easysw.com/htmldoc/

it works very well, it converts a HTML file to a PDF file.
and it's FREE!!
0
us111Commented:
you have a php sample into the cgi-bin directory
0
loveboltCommented:
the easiest way I have found is to use a thingy called HTMLDOC which you will have to check is installed.
Even if this doesn't answer your question it will certainly help a few others!
The url for HTMLDOC is http://www.easysw.com/htmldoc/htmldoc.html

The easiest way to use it is as follows.

Convert an existing HTML document
=================================
Existing document on server called existing.htm
PHP file called PDF.php which contains:

<?
passthru("htmldoc -t pdf14 --quiet --jpeg size A4 --webpage 'existing.htm'");
?>

Now put a link to PDF.php using the following syntax:

<a href="PDF.php?/random.pdf">Create PDF</a>

This SHOULD generate your page as a PDF. random.pdf is required as the file name even though it is displaying in the browser.

Convert a Dynamic HTML Document
===============================
The above solution wont work for database generated content etc. Therefore the solution I use is to create the dynamic content in PHP and then create a static HTML document. Then redirect to the PDF creation link as above so the code would look like this

<?
$content='
dynamically generated HTML
';

$random=time();

$fp=fopen("pdf.htm","w");
fputs($fp,$content);
fclose($fp);
header("Location: PDF.php?/$random.pdf");
exit;
?>

I hope Ive covered everything.
ZL
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SpideyModCommented:
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.