Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to design a webpage to be print friendly?

What are the right sizes for a webpage to be printed on A4 size paper? What other stuff should be considered?

*inline CSS is preferred in this case

Clarification: This web-page's only propose is to be printed, since it is a receipt.

Clarification # 2: This web-page is for the internal use of the company I'm working for. They would like it to look professionally designed receipt.

Clarification # 3: This web-page must be printed on one page -of A4 size- only.

like image 987
M. A. Kishawy Avatar asked Jan 05 '10 10:01

M. A. Kishawy


People also ask

How do I make a web page PrintFriendly?

Use high contrast between your background and text. For maximum readability, using black text on a white background works best. Adjust font sizing improve readability. Text that might be easy to read on a computer screen is sometimes too small or too large when you're reading it from a printed page.

What is a PrintFriendly website?

PrintFriendly cleans and formats web pages so you save paper and ink when you print. The software improves the readability of printed material by removing visual distractions such as ads, navigation and web page junk and increasing font sizes up to 130%.

What is printer friendly format?

An optional layout on a Web page that enables only the essential text to print properly. The icons, navigation buttons, ads and graphics on a Web page might cause the text to be truncated or print in a garbled manner.


4 Answers

Answer

I'd recommend using two different style sheets.

For viewing in the browser you could set the table width to the width of an A4 paper: 21cm. (Minus margins 18cm.)

For printing the size of the table should be "100%", which means the printer fills the whole width of the page, using the margins given by the browser's settings. (Those page margins are what makes it impossible for you to make a printout look exactly the same.)

Possibly working

Make the table narrow enough to be safe it's in the page margins. Then center that table vertically.

Solution for perfect layout

There's no way you're going to achieve that with HTML & CSS, it's just not designed to allow exact layouts!

Create PDFs online and let the users download them. Most browsers are able to render PDFs anyway.

like image 52
Georg Schölly Avatar answered Oct 13 '22 01:10

Georg Schölly


the best way is use from @Media command in stylesheet

for example

@media print{}

use for print layout of all control and

@media screen{}

used for screen layout of control, just think you have a

<div class="wrapper">content</div>

and then in your media you should have

@media print{ .wrapper{width: 100%;background-color:Transparent;color:Black;}}

and

@media screen{ .wrapper{width: 100%;background-color:#cdebcd;color:Red;}}

with this @media you can style your layout totaly different for print and screen. you can also use

.SomeDivOrContent{visibility:hidden;display:none;}

to hide ites in print.

let me know was it helpfull or not

like image 29
Nasser Hadjloo Avatar answered Oct 13 '22 00:10

Nasser Hadjloo


Like the other guys said you need to use a print CSS, but remember one thing:

display:none; //is your friend!

You can use this to make sure elements such as your navigation etc are not printed out.

By the way A List Apart has this great article on print stylesheets, check it out.

like image 37
Ben Everard Avatar answered Oct 12 '22 23:10

Ben Everard


Make your printable version as simple and free from page furniture as possible.

You should create a print-specific stylesheet that as a minimum removes any width restrictions on the page so the print page can flow the text to fit the output paper.

You should also be aware that most browser don't print CSS background images by default so don't rely on them being present on the printed page.


EDIT: In answer to your comment, I would make the receipt as simple as possible. The main issue is you don't have control over the end-user's printer so you can't know for sure exactly how wide the printable area is.

Design the page using a liquid/flowable layout and try and keep it simple. Amazon's receipt style that you get in the delivery box is probably worth using for inspiration.

like image 43
Paolo Avatar answered Oct 13 '22 01:10

Paolo