open PDF in new window using built-in browser viewer
This commit is contained in:
parent
303e70bb58
commit
24ec89c220
|
@ -109,8 +109,10 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
||||||
let blob: Blob = null;
|
let blob: Blob = null;
|
||||||
let type: string = null;
|
let type: string = null;
|
||||||
const fileNameLower = fileName.toLowerCase();
|
const fileNameLower = fileName.toLowerCase();
|
||||||
|
let doDownload = true;
|
||||||
if (fileNameLower.endsWith('.pdf')) {
|
if (fileNameLower.endsWith('.pdf')) {
|
||||||
type = 'application/pdf';
|
type = 'application/pdf';
|
||||||
|
doDownload = false;
|
||||||
} else if (fileNameLower.endsWith('.xlsx')) {
|
} else if (fileNameLower.endsWith('.xlsx')) {
|
||||||
type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
type = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
||||||
} else if (fileNameLower.endsWith('.docx')) {
|
} else if (fileNameLower.endsWith('.docx')) {
|
||||||
|
@ -141,10 +143,13 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
|
||||||
navigator.msSaveBlob(blob, fileName);
|
navigator.msSaveBlob(blob, fileName);
|
||||||
} else {
|
} else {
|
||||||
const a = win.document.createElement('a');
|
const a = win.document.createElement('a');
|
||||||
a.href = win.URL.createObjectURL(blob);
|
if (doDownload) {
|
||||||
a.download = fileName;
|
a.download = fileName;
|
||||||
a.style.position = 'fixed';
|
} else {
|
||||||
a.target = '_blank';
|
a.target = '_blank';
|
||||||
|
}
|
||||||
|
a.href = win.URL.createObjectURL(blob);
|
||||||
|
a.style.position = 'fixed';
|
||||||
win.document.body.appendChild(a);
|
win.document.body.appendChild(a);
|
||||||
a.click();
|
a.click();
|
||||||
win.document.body.removeChild(a);
|
win.document.body.removeChild(a);
|
||||||
|
|
Loading…
Reference in New Issue