admin管理员组

文章数量:1023848

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 es 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?

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 es 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?

Share Improve this question edited Dec 15, 2014 at 16:45 Jakal asked Dec 15, 2014 at 16:30 JakalJakal 783 silver badges14 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 3

It seems that unfortunately it can't be done from the browser.

It looks like the file name es from the PDF printer, not the browser, as mented 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./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.

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 es 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?

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 es 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?

Share Improve this question edited Dec 15, 2014 at 16:45 Jakal asked Dec 15, 2014 at 16:30 JakalJakal 783 silver badges14 bronze badges 0
Add a ment  | 

1 Answer 1

Reset to default 3

It seems that unfortunately it can't be done from the browser.

It looks like the file name es from the PDF printer, not the browser, as mented 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./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.

本文标签: Setting filename of pdf from javascript print method in Internet Explorer not workingStack Overflow