我收到的服务器pdf文件应该在新的浏览器窗口中打开。
我有一项向服务器发送信息的服务
public openFile(path) {
let url='/download/';
let pathFile= new HttpParams().set('pathFile', path);
return this.httpClient.get(url,{params:pathFile})
}
然后在我的组件中,我订阅了http请求
this.creditPoliciesService.openFile(path).toPromise().then (data => {});
core.js:1448 ERROR Error: Uncaught (in promise): Object: {"error":{},"text":"%PDF-1.5\r\n%����\r\n1 0 obj\r\n<</Type/Catalog/Pages 2 0 R/Lang(en-GB) >>\r\nendobj\r\n2 0 obj\r\n<</Type/Pages/Count 48/Kids[ 3 0 R 38 0 R 44 0 R 45 0 R 47 0 R 51 0 R 52 0 R 54 0 R 55 0 R 57 0 R 60 0 R 62 0 R 64 0 R 66 0 R 69 0 R 70 0 R 71 0 R 72 0 R 74 0 R 75 0 R 77 0 R 78 0 R 80 0 R 81 0 R 83 0 R 85 0 R 86 0 R 88 0 R 91 0 R 93 0 R 95 0 R 97 0 R 99 0 R 101 0 R 103 0 R 106 0 R 108 0 R 110 0 R 114 0 R 115 0 R 116 0 R 121 0 R 124 0 R 126 0 R 129 0 R 131 0 R 134 0 R 679 0 R] >>\r\nendobj\r\n3 0 obj\r\n<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R/F2 7 0 R/F3 9 0 R/F4 11 0 R/F5 13 0 R/F6 18 0 R/F7 27 0 R/F8 30 0 R/F9 32 0 R>>/XObject<</Meta23 23 0 R/Image25 25 0 R/Image34 34 0 R/Image36 36 0 R>>/ExtGState<</GS24 24 0 R/GS29 29 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 595.32 841.92] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S>>\r\nendobj\r\n4 0 obj\r\n<</Filter/FlateDecode/Length 6515>>\r\nstream\r\nx��]msܸ���*�\u0007~���:�\t��U����k'�ݜ�����\u000f�5�&�F���)߯?t7�H\u0000\r����\u0012K�3ݍF7�A\u0013�|����ע\u0010bS���OO���T�\u0015EՔ�z(�Vnʾx��IY|��{���X?����\u0007�{��1w}чF?�ٳ�����O�������Z#�M��^+�MY5����b��篫BT#�7�\u0012Q�E�ǃ��b\u0018}������z3TV��v��Z���@n=�+D�\u0011\u0013�(�ͺY]߮��Շ�u��.���\u0017�g��#�x\u0002\r���\u001e~�\f�|u{\u0003N��\u0002洅���B\u0010\u001c-^�
我想在新标签页中打开pdf
答案 0 :(得分:0)
尝试这对我有用,如果你想保存它,你需要文件保护程序
let fileURL = window.URL.createObjectURL(data);
window.open(fileURL);