Solved

create a print page and send it to printer

Posted on 2014-09-03
5
287 Views
Last Modified: 2014-09-04
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.
0
Comment
Question by:Kinderly Wade
5 Comments
 
LVL 21

Assisted Solution

by:Kim Walker
Kim Walker earned 100 total points
Comment Utility
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
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
Comment Utility
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
 
LVL 108

Accepted Solution

by:
Ray Paseur earned 300 total points
Comment Utility
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
 

Author Comment

by:Kinderly Wade
Comment Utility
Hi Ray,

Nice to hear from you again. Thanks again for your expertise.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Thanks for the points - it's a great question! ~Ray
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

Suggested Solutions

A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
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

6 Experts available now in Live!

Get 1:1 Help Now