简体   繁体   中英

How do I set pdf file name in windows.open() using JavaScript?

I have generated the PDF, but when the pdf is opened in a new tab, the name is changed with some random alphanumeric numbers like this "98d49355-2a77-497c-a064-ccd72ed1e3df".

`

 html2pdf().from(element).set(opt).toPdf().get('pdf').then(function (pdf) {
                console.log(pdf.output('bloburl'));
                window.open(pdf.output('bloburl'), '_blank');
                
            });

` pdf图像

Try the below code:

 html2pdf().from(element).set(opt).toPdf().get('pdf').then(function (pdf) {
                console.log(pdf.output('bloburl'));
                var newWindow= window.open(pdf.output('bloburl'), '_blank');
                newWindow.document.title = "YOUR PDF NAME HERE!";
            });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM