0

Hi I have a requirement where I will receive a PDF file from server in BLOB and needs to open it in new tab instead of directly downloading it. So, I have done the below mentioned coding in my angular 8 but the problem is after opening in new tab from there when I am downloading from the browser file name is not coming what I actually sent from the server. But if I download the file directly instead of openning in new tab the file name is coming as desired.

Code to open the file in new tab:

 const blob = new Blob([data], { type: "application/pdf" });
 const url = window.URL.createObjectURL(blob);
 const anchor = document.createElement('a');
 anchor.target = '_blank';
 anchor.click(); 

Thanks in Advance.

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Souvik
  • 1,219
  • 3
  • 16
  • 38
  • Looks like [this approach](https://stackoverflow.com/questions/19327749/javascript-blob-filename-without-link) may help – vitaliy kotov Aug 30 '20 at 20:04
  • I tried the approaches and it didn't work. So, can you tell me if any specific approach you are reffering. – Souvik Aug 30 '20 at 20:21

0 Answers0