Chrome save to PDF custom filename

◇◆丶佛笑我妖孽 提交于 2020-01-22 12:18:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!