Quickest Printer Friendly HTML Report Print Button in Oracle APEX (Print Button Code with exit)

While doing a project of HTML report printing I did the following to get the best printer friendly Print and Exit Button on the HTML Report.

1.Write this code in your PL SQL reports dynamic content (after Begin) :

htp.p('<a id="b_exit" type="button1" class="button button3" class="exit" '||'href="'||APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:1:&SESSION.::&DEBUG.::::')||'">Close</a>
<input type="button1" class="button button1"  class="t-Icon t-Icon--right fa fa-print" id="print" type="button" onclick="printdiv(''div_print1'');" value="Print"/><br/>
     
<div id="div_print1" style="margin-top:5px;"> '); 

2. Enter the following code before the End of your PL SQL dynamic content.

htp.p('</div>');

3.Copy and Past in Function and Global Variable :

function printdiv(printpage)
{
var headstr = "<html><head><title></title></head><body>";
var footstr = "</body>";
var newstr = document.all.item(printpage).innerHTML;
var oldstr = document.body.innerHTML;
document.body.innerHTML = headstr+newstr+footstr;
window.print();
document.body.innerHTML = oldstr;
return false;
}

4.If you want to design print button. You can use this CSS (Inline CSS)

.button {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 16px 32px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 16px;
    margin: 4px 2px;
    -webkit-transition-duration: 0.4s; /* Safari */
    transition-duration: 0.4s;
    cursor: pointer;
}

.button1 {
    background-color: white;
    color: black;
    border: 2px solid #008CBA;
}
.button1:hover {
    background-color: #008CBA;
    color: white;
}


.button3 {
    background-color: white;
    color: black;
    border: 2px solid #f44336;
}

.button3:hover {
    background-color: #f44336;
    color: white;
}



 

Muhammad Abdullah Al Noor

Muhammad Abdullah Al Noor, An Oracle Apex Consultants and founder of Noors Technology (www.noorstech.com). Core Expertise : Database Administration, Oracle Forms and Reports Development, Oracle Apex Application Designer and Development, Linux Professional etc. Also the owner of TrainerBD Training and OraDemy E-Learning. WhatsApp +8801790721177

1 Comments

Previous Post Next Post