Search code examples
htmlgoogle-chromepdftitle

Chrome save to PDF custom filename


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.


Solution

  • 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;
    }