Setting pdf file name from javascript print method in Internet Explorer does not work

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 to open a new window and automatically open the print dialog. When the user selects the option to print to Adobe PDF from the print dialog, an option appears in the menu to specify the pdf file name. In Firefox and Chrome, the pdf file name is set as the page title, and this is normal. However, in Internet Explorer, the pdf file name is set as the base name of the parent window. How can I set the pdf file name programmatically in Internet Explorer?

+6
source share
1 answer

It seems that this cannot be done from the browser.

It looks like the file name comes from the PDF printer, not the browser, as Teemu commented on this post: The default file name when printing from Internet Explorer .

A thread was opened on the Microsoft forum on how to set a value that will be accepted as the default file name using 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 this only applies to the static pages that you want to print by pressing Ctrl + P. When you dynamically create a document, it will consider the parent URL as the default file name.

0
source

Source: https://habr.com/ru/post/979639/


All Articles