var docprint = window.open("", "", "toolbar=0,location=0,menubar=0,scrollbars=1");
docprint.document.open();
docprint.document.write("<html><head><title>Title here</title></head>");
docprint.document.write("<body>body content here</body></html>");
docprint.document.close();
docprint.focus();
docprint.print();
This is my javascript code for opening a new window and automatically opening the print dialog. When the user selects the option to print to Adobe PDF from the print dialog, a menu comes up with the option to define the pdf filename. In Firefox and Chrome, the pdf filename is set as the title of the page, which is fine. However, in Internet Explorer, the pdf filename is set as the parent window's url basename. How can I set the pdf filename programatically in Internet Explorer?
It seems that unfortunately it can't be done from the browser.
It looks like the file name comes from the PDF printer, not the browser, as commented by Teemu on this post: Default File Name when printing from Internet Explorer.
There's a thread opened on the Microsoft's forum about how to set the value to be taken as the default file name on the link below:
https://answers.microsoft.com/en-us/ie/forum/ie8-windows_xp/filenames-when-printing-to-a-pdf-driver/e5541ba9-d545-e011-9577-d485645a8348
But it applies only to static pages you wanna print by hitting Ctrl + P. As you are dynamically creating a document, it will take the parent's URL as the default file name.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With