473,408 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Print a whole page and print div content

47
Hi, all

I am new, I am using rails to write the application... and now I want to make a function for print the specific div in the page.

What can I do with this?

Please give me some advice.

I did try to use
Expand|Select|Wrap|Line Numbers
  1.   <a href="#" onclick="window.print();return false;"><img src ="http://png.findicons.com/files/icons/61/dragon_soft/512/printer.png" width="20" height="20" /> Print all</a>|
  2.  
This works pretty good to print the whole page.
Nut i have no idea how to make the function to print specify div... and I don't want to have a pop up window as well.

Please help


thanks a lot

wiinie
Jun 7 '11 #1
5 10370
Frinavale
9,735 Expert Mod 8TB
You can create a CSS style that is used for printing purposes.

(Check out CSS Media Types)

So, if I were you, I would create a print style sheet that hides everything on the page except for the DIV that you want to print (eg: set everything on the page to "display:none" and set the div you want to print to "display:block" in the style sheet).

-Frinny
Jun 7 '11 #2
Wiinie
47
Ya, I am trying your idea as well. beside that,, i have a print function that can print whole page.. then i dont know how to add the print that can only print div..

Please help

This my css file

Expand|Select|Wrap|Line Numbers
  1.  /**print.css **/
  2. @media screen 
  3. {
  4. div.print {    display:block;
  5.     height: 100%;
  6.     width: 100%;
  7.     font-family:verdana,sans-serif;font-size:14px;
  8.     }
  9.     @media print
  10.   {
  11.   div.print {font-family:times,serif;font-size:10px;}
  12.   }
  13. @media screen,print
  14.   {
  15.   div.print {font-weight:bold;}
  16.   }
  17. }
  18.  
and my html file
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <link rel="stylesheet" href="../../print.css" type="text/css" media="print" />
  5. </head>
  6. <body>
  7. <a href="#" onclick="window.print();return false;"><img src ="http://png.findicons.com/files/icons/61/dragon_soft/512/printer.png" width="20" height="20" /> Print all</a>|
  8. <hr/>
  9. <div id="print">
  10. <table width = "100%", style ="overflow:scroll;">
  11.   <tr width = "50%" >
  12.     <td>(name)<hr/></td>
  13.     <td>Reason<hr/></td>
  14.     <td>phone<hr/></td>
  15.     <td>add<hr/></td>
  16.     <td>poscodet<hr/></td>
  17.     <td>country<hr/></td>
  18.   </tr>
  19.  
  20.  
  21.    <tr width = "50%" >
  22.     <td>(name)<hr/></td>
  23.     <td>Reason<hr/></td>
  24.     <td>phone<hr/></td>
  25.     <td>add<hr/></td>
  26.     <td>poscodet<hr/></td>
  27.     <td>country<hr/></td>
  28.   </tr>
  29. </table>
  30. </div>
  31.  
  32. <% end %>
  33. </body>
  34. </html>
  35.  
Jun 7 '11 #3
Wiinie
47
This is a css that i just update
Expand|Select|Wrap|Line Numbers
  1. @media screen 
  2. {
  3. div#print {    display:block;
  4.     height: 100%;
  5.     width: 100%;
  6.     font-family:verdana,sans-serif;font-size:14px;    
  7.     }
  8.  h2,h1, h3,a {display: none}
  9.       }
  10.  
  11. @media print
  12.   {
  13.      div#print { 
  14.         display:block;
  15.         height: 100%;
  16.         width: 100%;
  17.         div#print {font-family:times,serif;font-size:10px;}
  18.       }
  19. }  
  20. @media screen,print
  21.   {
  22.   div#print {font-weight:bold;}
  23.   }
  24. }
  25.  
please help... thanks
Jun 7 '11 #4
Frinavale
9,735 Expert Mod 8TB
Your CSS looks okay to me...
What seems to be the problem now?
Jun 8 '11 #5
Wiinie
47
Hi Frinavale,

when i print. i cannot print the div and plus.. i cannot make 2 options of printing (print whole page - print div)

please give me some advices
Jun 8 '11 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Yaron Cohen | last post by:
Hi, I would like to ask for your help. I am using IE5.5. I have a wide page with horizontal scroll bar. The problem is that I get only 1 page when printing it using "file->print" or...
1
by: geotso | last post by:
Hi I have a large page, divided in three sub-topics. I also have two external stylesheets, each one giving different printing option, like this: 1. fullprint.css to print the whole page 2....
3
by: Sir Loin of Beef | last post by:
I would like to create a table with a bar of text that spans the whole page. Here is what I have so far: <table border=0 width="100%" > <tr> <td><img src="SANimages/magnify.gif"></td> <td...
5
by: Alan | last post by:
While not rs.eof <td><%=rs("InvoiceNo")%></td> <td><%=rs("Name")%></td> <td><a href="InvoicePrint.asp?WInv=<%=rs("InvoiceNo")%>"></a></td> <td>Print this invoice</td> rs.MoveNext Wend Now...
4
by: ares | last post by:
Hi! I'm a new bee in asp.net. I have a page that includes a table and a repeater web control, they have been filled dynamically with a stored procedure. So I would like to print this page with a...
12
by: urs | last post by:
Hi, please look at the ASP.NET 2 site http://www.prismatest.ch/catalog/EM.ASPX (user=prismashop, password=minicooper). Use the ">" Button to go to the next pages. You will notice that the page...
9
by: igotyourdotnet | last post by:
I need to create a print preview page BUT my page I need to print has a grid and in the grid I have 2 or 3 columns that have links I want to hide the columns with the links on my print preview page...
1
by: henning | last post by:
Hello, I'm involved in the development of a set of web pages that are meant to be used on touch screens. We use ordinary HTML, PHP and javascript for the pages. I wold prefer a serverside...
0
by: ra220511 | last post by:
hello ive only started using ajax for first time today . i am trying to use an update panel in asp.net but my whole page keeps refresh rather than just the content area. can any one help. ...
1
by: hemantkamb | last post by:
Hi…. I have created one website with Master and content page . I have taken TreeView Control on master page. And I wants that when I click to tree node the value of tree node is added to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.