Printing support by all browsers is very poorly supported with horrendous bugs in many popular browsers that have gone unfixed for years.
The short answer is to avoid HTML/CSS printing if you need to ensure a specific layout. Use PDF, possibly dynamically generated on-demand. There's various PDF generator APIs such as iTextSharp. It's possible to print from Flash, but only if Flash is installed and working (i.e. no Flashblock, iOS).
HTML/CSS printing should be restricted to simple layouts. Form printing is a nightmare with fieldset
& legend
support being especially problematic (particularly on Firefox). Interestingly printing support is best on the internet explorers.
The CSS3 printing support specification hasn't been completed and is some time off.
General principles:
No backgrounds or background CSS images are supported (by default - users can change their browser settings for an intranet application). Only foreground images print.
Widths need to be fluid as page sizes vary around the planet. US Letter format is shorter and wider than A4 layout
All browsers support printing in different ways. Bugs are legion.
Test using print preview.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…