dimanche 15 février 2015

Printing contents of iframe without hosted page's scrollbar


Click a button, and it runs PrintInvoice, which uses jquery printElement (hmm, version 1.2) to open a window with the div containing a button and an iframe, as well as the print dialog:



<script type="text/javascript" language="javascript">
function PrintInvoice() {
$('DIV#EInvoice').printElement({
printMode: 'popup',
leaveOpen: true,
});
}
</script>


Where the relevant elements are as follows:



<div id="EInvoiceWrapper">
<div id="EInvoice" style="overflow: hidden">
<center>
<a style="display: block; width: 100%; height: 100%; background: url(API/OAL/img/btnCloseWindow.jpg) no-repeat top center;"
href="javascript: window.close()"></a>
</center>
<br />
<iframe id="PrintableInvoice" name="PrintableInvoice" src="http://ift.tt/1F3LhKp" frameborder="0" scrolling="no" style="width:590px; height:750px !important;"></iframe>
</div>
</div>


Which correctly pops up a window with the EInvoice div contents and loads the print dialog, but the hosted page displays a vertical scroll bar.


Popup window with scrollbar


Which of course is then rendered in the print document. I need to get this page printed without the scrollbar (I am indifferent as to whether it shows in the popup window.) Currently the users cancel out of the Print dialog, right click on the actual invoice, and print from there (which does it correctly without the scrollbar).


Things I have tried: setting height on the iframe, setting height on the div, passing different settings into the printElement printBodyOptions, about a million other things.


What I think I need to do is get the page hosted within the iframe to expand to its full height, so it doesn't need to show the scrollbar. I have no control over the hosted OrderInvoice.aspx.


How can I do that? Or what other approaches might work to hide the scrollbar?





Aucun commentaire:

Enregistrer un commentaire