I'm displaying a PDF within an Iframe and I have a dynamic button which says Print. On the click of that button, I want to print only the PDF which is displayed in the iframe and not the complete page. I'm using the below code to print but it is printing the whole page.
try {
iframe = document.getElementById('id of iframe');
iframe.contentWindow.document.execCommand('print', false, null);
}
catch (e) {
window.print();
}
How can I print only the content of the iframe which is the PDF in this case?