how to print only the contents inside the div in A4 size from web pages.
someone please help me. I've almost completed my project.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit ChoudharyRank #145 · 15.8K reputationPosted May 3, 2011, 7:39 AM EDT
Try something like this:
Andrew FensterRank #983 · 2K reputationPosted May 3, 2011, 8:00 AM EDT
The media="print" part tells the browser that this CSS only applies when printing.
If you only want to print the contents of one div, then you must use the CSS to hide everything else. You set everything else to display: none. For example:
#header, #footer, #navigation, #sidebar, button {display:none;}
If your html included sections with IDs of header, footer, navigation and sidebar, this would hide them during printing. It would also hide every section with a CSS class of button. You could modify this to hide everything you don't want to print.
While you're at it, you can set fonts, colors, or any other styles you want. These will only apply during printing.
Andrew FensterRank #983 · 2K reputationPosted May 3, 2011, 8:02 AM EDT
Andrew FensterRank #983 · 2K reputationPosted May 3, 2011, 8:09 AM EDT
http://www.princexml.com/doc/6.0/page-size/