问题
In Chrome, when hitting Ctrl + P you can choose 'Save to PDF'. The default file name is equal to the title of the html page the user wants to print. Can this be changed, without changing the actual title of the html page? I'd like to have a date & time in the PDF's name, but I don't want the date & time in the title of my html page.
回答1:
So if you can put a print button in somewhere and link it to a function similar to the following:
function printWithSpecialFileName(){
var tempTitle = document.title;
document.title = "Special File Name.pdf";
window.print();
document.title = tempTitle;
}
回答2:
This is a functionality of a print-to-PDF printer driver, and as far as I could verify, you have no control over it. So, unfortunately, the default file name will be the page title...
来源:https://stackoverflow.com/questions/26905908/chrome-save-to-pdf-custom-filename