Home » Developer & Programmer » Application Express, ORDS & MOD_PLSQL » Print button (ApEx 4.1)
Print button [message #502879] Mon, 11 April 2011 04:29 Go to next message
liamchristiaans
Messages: 1
Registered: April 2011
Junior Member
I'm trying to create a print button that will let me print a report based on a table, I cannot use apex's default print button setting because when apex was set up the print server was not configured. Now I'm resorting to using a javascript print button but it only prints the current screen(buttons and all) and not the whole report as I need. My code for the button is as follows:






<script language="JavaScript">
function printPage()
{
if(document.all) {
document.all.divButtons.style.visibility = 'hidden';
document.all.divButtons1.style.visibility = 'hidden';
// document.all.CONFIGURE_29.style.visibility = 'hidden';
window.print();
document.all.divButtons.style.visibility = 'visible';
document.all.divButtons1.style.visibility = 'visible';
// document.all.CONFIGURE_29.style.visibility = 'visible';
}
else
{
document.getElementById('divButtons').style.visibility = 'hidden';
document.getElementById('divButtons1').style.visibility = 'hidden';
// document.getElementById('CONFIGURE_29').style.visibility = 'hidden';
window.print();
document.getElementById('divButtons').style.visibility = 'visible';
document.getElementById('divButtons1').style.visibility = 'visible';
// document.getElementById('CONFIGURE_29').style.visibility = 'visible';
}
}
function closePage() {
window.close();
}
</script>








<table width="50%" cellspacing="0" cellpadding="0" border="0" align="right">
<tr>
<td align="right" width="50%"><br><div id="divButtons" name="divButtons">
<input type="button" value = "Print" onclick="printPage()" style="font:bold 12px verdana;">
</div><br></td>
<td width="5%" align="left">
<br><div id="divButtons1" name="divButtons1">
<input type="button" value = "Close" onclick="closePage()" style="font:bold 12px verdana;">
</div><br></td>
<td width="5%"></td>
</tr>
</table>

Re: Print button [message #503190 is a reply to message #502879] Wed, 13 April 2011 07:49 Go to previous message
c_stenersen
Messages: 255
Registered: August 2007
Senior Member
You could have a button taking you to printer-friendly mode. (Meaning that the printer friendly template will be used, and the full list of results will be shown in all reports.) Printer friendly is the last parameter in the f?p url structure. (f?p=appno:page:session:request:debug:clear cache:item names:item values:printer friendly)

But this will of course not print the page. It will just display the page differently. So then you'd have to do something in your printer friendly template (Or include some code in your page in some other way) for the printing itself. I searched a bit for how to use a button to print a different page than the one you're watching by using javascript (so that you could make it print the printer friendly version even though you're still watching the regular one), and there are some ways being suggested using iframes, but I haven't tested any of it. But I guess you could search around a bit.
Previous Topic: File upload to database table
Next Topic: Best way to install APEX v4
Goto Forum:
  


Current Time: Thu Apr 18 00:36:03 CDT 2024