Adding a button to print a file

  • Thread starter Lloyd Codrington
  • Start date
L

Lloyd Codrington

I am building a web page that consist of a form but because of the size I
want to give the website users the option to print the form on their printer.
The form will be stored as a Word file and a plain text file on the server.
How do I create a button to print the file.
 
M

Murray

You don't.

You can only print the file that is open in the browser. And using anything
other than the browsers FILE | Print option will fail on IE5x/Mac.
 
L

Lloyd Codrington

Evening Murray,

Thanks for the answer. Would it be possible to print the form from the
displayed page but not the rest of the page content? And if so how would I
go about incorparating a button to do so?

Thanks
Lloyd
 
M

Murray

Yes - that would be possible, although horribly redundant since everyone
already knows about FILE | Print! 8)

Put this in the head of the document -

<script type="text/javascript">
function print_page(where){
var is_mac=(navigator.platform.indexOf("ac") != -1);
(document.all && is_mac)?
alert("Select \"Print\" from the menu") : where? where.window.print() :
window.print();
}

function writeOutPrintLink(){
document.getElementById('printLink').innerHTML = '<a
href="javascript:print_page();">Print this</a>'

}

</script>

Put this in the body of the document -

<body onload="writeOutPrintLink();">
<span id="printLink"></span>

That way, the link only shows up if you have javascript, and will only
appear where that <span> tag is placed..
 
R

Rob Giordano \(Crash\)

Create a "fillable" pdf.


Lloyd Codrington said:
Evening Murray,

Thanks for the answer. Would it be possible to print the form from the
displayed page but not the rest of the page content? And if so how would
I
go about incorparating a button to do so?

Thanks
Lloyd
 
L

Lloyd Codrington

Great. Thanks.

Lloyd

Murray said:
Yes - that would be possible, although horribly redundant since everyone
already knows about FILE | Print! 8)

Put this in the head of the document -

<script type="text/javascript">
function print_page(where){
var is_mac=(navigator.platform.indexOf("ac") != -1);
(document.all && is_mac)?
alert("Select \"Print\" from the menu") : where? where.window.print() :
window.print();
}

function writeOutPrintLink(){
document.getElementById('printLink').innerHTML = '<a
href="javascript:print_page();">Print this</a>'

}

</script>

Put this in the body of the document -

<body onload="writeOutPrintLink();">
<span id="printLink"></span>

That way, the link only shows up if you have javascript, and will only
appear where that <span> tag is placed..
 
M

Mark E.

Murray,
Can you specify where in the header and where in the body those two pieces
of code need to go?
 
Top