[Fixed] Force download the pdf file – Angular 6+


I need to download the pdf file from the URL. I have tried the window.open(URL, ‘Download’) method but it does not download the file and it opens in the new browser tab.

downloadPDFFile() {
     window.open('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf', 'Download');


import * as fs from 'file-saver';
 downloadFile(url) {
            var filename = url.split('/').pop();
            try {
                fs.saveAs(url, filename);
            catch (e) {

Leave a Reply

(*) Required, Your email will not be published