Skip to content

Instantly share code, notes, and snippets.

@tong-odoo
Last active November 15, 2022 01:54
Show Gist options
  • Save tong-odoo/600f2470900e87f555fcf1b38938c478 to your computer and use it in GitHub Desktop.
Save tong-odoo/600f2470900e87f555fcf1b38938c478 to your computer and use it in GitHub Desktop.
Javascript Example
function printPdf (url) {
let iframe = env._printIframe;
if (!env._printIframe) {
iframe = env._printIframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.style.display = 'none';
iframe.onload = function() {
iframe.focus();
iframe.contentWindow.print();
env.services.ui.unblock();
};
}
iframe.src = url;
}
// printPdf(url + `?context=${encodeURIComponent(JSON.stringify({test: 'test'}))}`)
export default printPdf;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment