How can I put a print link / button on my project page to print information?

I use Rails for my application (student register) and I need the print / button to print some student information. Please, what should I do?

+5
source share
4 answers

You can use this tag to create print links. A.

<%= link_to 'print', 'your_link_here', :onclick => 'window.print();return false;'%>

Now, if you want to print a specific section, you can use css media types

/*This css will only works when you print*/
@media print {
  body {
    background: #FFF;
 }
}
+6
source

I'm not sure that I misunderstood something, because it looks more like a javascript question, and there is one rail to it: But here is how you make the link for printing:

<a href="#" onclick="window.print();return false;">print me</a> 

. return false , .

window.print onload, :

<body onload="window.print();">
+4

,

function printPage() {
    window.print()
}

<%= link_to "print", "#", onclick: "printPage()" %>
+4

, , "display: none" divs, . , , , " Me", onload.

0

All Articles