Solved

create a print page and send it to printer

Posted on 2014-09-03
5
294 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
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.

696 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