Solved

How to print....

Posted on 2002-05-14
9
234 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
  • 2
  • 2
  • 2
  • +3
9 Comments
 
LVL 4

Expert Comment

by:lokeshv
Comment Utility
a easy way..

Use frames and print only the specific frame...

LK
0
 
LVL 32

Expert Comment

by:Batalf
Comment Utility
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
Comment Utility
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
 
LVL 32

Expert Comment

by:Batalf
Comment Utility
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 1

Author Comment

by:onestar
Comment Utility
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
Comment Utility
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
Comment Utility
you have a php sample into the cgi-bin directory
0
 

Accepted Solution

by:
lovebolt earned 100 total points
Comment Utility
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
Comment Utility
Force Accepted

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now