Solved

How to print....

Posted on 2002-05-14
9
270 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:onestar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 4

Expert Comment

by:lokeshv
ID: 7010520
a easy way..

Use frames and print only the specific frame...

LK
0
 
LVL 32

Expert Comment

by:Batalf
ID: 7010522
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
 
LVL 1

Author Comment

by:onestar
ID: 7010852
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 32

Expert Comment

by:Batalf
ID: 7012585
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
 
LVL 1

Author Comment

by:onestar
ID: 7013549
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
 
LVL 8

Expert Comment

by:us111
ID: 7013594
http://www.easysw.com/htmldoc/

it works very well, it converts a HTML file to a PDF file.
and it's FREE!!
0
 
LVL 8

Expert Comment

by:us111
ID: 7013598
you have a php sample into the cgi-bin directory
0
 

Accepted Solution

by:
lovebolt earned 100 total points
ID: 7026466
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
 

Expert Comment

by:SpideyMod
ID: 8287226
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question