create a print page and send it to printer

Dear experts,

I wish to create a printable page that can be printed with printer. I wish to know if there are easier solutions that can accomplish my tasks.

Currently I am using php to setup the codes that can fill in the content of the page. The template of the page is being coded by html.

Basic layout is like this:
1. there is a top section on the page which the left portion contains the company's address and left portion contains the other parties address.
2. the body section contains a table that can fit max of 30 rows per page and table has 4 columns as in part number, qty, short description of the product and price. There will be a row that has total cost
3. the bottom of the page contains some contents at as the footer
4. fonts and size of table can be adjusted to user's need simply through css

Method:
1. I am using div to divide the sections and the contents are placed inside these divs.
2. when user has complete the order, can press the print button on the page. This print button links with the print function from the browser that allows the user to use the print interface from the browser to print.

Is there  a better way for me to design the template besides the html?
Is there a way for me to create a print interface with php instead of using the browser's print interface?

Thanks.
Kinderly WadeprogrammerAsked:
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.

Kim WalkerWeb Programmer/TechnicianCommented:
This is just my opinion, but I believe in simplicity and lean programming. Why waste bandwidth and time downloading a different page for printing when you can control the way the current page prints separately from the way it displays on the screen using @media. Simply create a whole different set of css rules for printing and place them inside a media selector. For example:
@media print {
	body {
		color: black; background-color: white;
		background-image: none;
		font: normal normal normal 12pt/1.5em Arial, Helvetica, sans-serif;
	}
}

Open in new window

This will override the setting you have for the body element on your screen.
0
Dave BaldwinFixer of ProblemsCommented:
You can't use PHP or any web page to force a page to print.  It must be at least accepted by the user if not actually requested.  This is considered a security barrier to prevent malicious pages from wasting people's resources.
0
Ray PaseurCommented:
HTML is a semantic markup language.  PDF is a print layout language.  These different language types are not quite as different as fish and bicycles, but almost!  If you need precise document positioning, PDF is the only way to go.  There are two main PDF libraries for PHP - FPDF and TCPDF (Google 'em).  Both are free, open-source and object-oriented extensible classes.  Designing a PDF layout is a meticulous task, but once you've got the layout right, either library is lightning fast.

If you don't really need precision, have a separate style sheet for print (obvious things to hide - navigation - you can't click on a piece of paper) and make do with that.

There is a window.print() method in JavaScript.  It will not start the printer, but it will ask the client to permit the document to print and fill in the printer-appropriate information about page orientation, print quality, etc.
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
Kinderly WadeprogrammerAuthor Commented:
Hi Ray,

Nice to hear from you again. Thanks again for your expertise.
0
Ray PaseurCommented:
Thanks for the points - it's a great question! ~Ray
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.