Solved

create a print page and send it to printer

Posted on 2014-09-03
5
291 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
[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
5 Comments
 
LVL 22

Assisted Solution

by:Kim Walker
Kim Walker earned 100 total points
ID: 40301938
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 83

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 40302047
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 110

Accepted Solution

by:
Ray Paseur earned 300 total points
ID: 40302354
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
ID: 40302923
Hi Ray,

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

Expert Comment

by:Ray Paseur
ID: 40303171
Thanks for the points - it's a great question! ~Ray
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JQuery conflicts/syntax issue 4 24
Html using "Or" in condition 3 26
Table style position to the left 8 25
Read text on Table 7 27
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

749 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