Last active
November 15, 2022 01:54
-
-
Save tong-odoo/600f2470900e87f555fcf1b38938c478 to your computer and use it in GitHub Desktop.
Javascript Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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