Last active
November 11, 2024 00:03
-
-
Save amirhp-com/d868121da0a0ea728cc348a759aba22f to your computer and use it in GitHub Desktop.
Directly Open Print Dialog for a PDF from URL
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
/* | |
* Directly Open Print Dialog for a PDF from URL | |
* https://www.linkedin.com/posts/activity-7242424929344753664-4Zrk | |
* Developer: Amirhp.com | |
* Contact: [email protected] | |
* | |
* 1. add following iframe and load pdf into it: | |
* 2. <iframe id="print_pdf_iframe" src="https://site.com/sample.pdf" frameborder="0"></iframe> | |
* 3. Then for print button, add print_pdf function as command | |
*/ | |
function print_pdf() { | |
var PDF = document.getElementById("print_pdf_iframe"); | |
if (PDF) { | |
PDF.focus(); | |
PDF.contentWindow.print(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment