如何从 GET 申请中获取 pdf 存档的字节数组?

How to get a byte array of a pdf archive from a GET requisition?

我有一个 api 从 pdf 文件重命名字节数组,但是当我执行获取请求时,我无法获取该字节数组。浏览器控制台中出现以下消息:

ERROR {…} ​ error: {…} ​​ error: SyntaxError: "JSON.parse: unexpected character at line 1 column 1 of the JSON data" Angular 8 ​​ text: "%PDF-1.5\n%����\n3 0 obj\n<>stream\nx���Mj�0\u0010��:�[:\u001bU?�~�-���bj�\u000b]�X\t\u000eN�8�!s�^��\u0017u\u000b�)8\u000chxo�'�\u0013yqD*\u0018��J�:�N\u0004\u0016a���\n��\u0005ܞ<�rp\u0006�!��킶�0���M�[\u001a\u001bh˨�?f\u0013̬�4[\u0012��+r_\u0017���:��\u000c�;kW\u001fm/�X�@n%M,474�������qC�<]>�,�g\u0013��A)C�\u0018\"f�DB\"��\u001c!\u0014G_W���\u0013�E�\u0018�Ծ�,�\u0007b��0��?��7�_�R\nendstream\nendobj\n1 0 obj\n<>/Contents 3 0 R/Type/Page/Resources<>/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]/Font<>>>/Parent 4 0 R/MediaBox[0 0 595 842]>>\nendobj\n5 0 obj\n[1 0 R/XYZ 0 852 0]\nendobj\n2 0 obj\n<>\nendobj\n4 0 obj\n<>\nendobj\n6 0 obj\n<>\nendobj\n7 0 obj\n<>\nendobj\n8 0 obj\n<>>>\nendobj\n9 0 obj\n<>\nendobj\nxref\n0 10\n0000000000 65535 f \n0000000301 00000 n \n0000000577 00000 n \n0000000015 00000 n \n0000000665 00000 n \n0000000542 00000 n \n0000000728 00000 n \n0000000782 00000 n \n0000000814 00000 n \n0000000917 00000 n \ntrailer\n<<0f3db8438dad491480ff1017eef9db67>]/Root 8 0 R/Size 10>>\nstartxref\n1125\n%%EOF\n" ​​ : Object { … } ​ headers: Object { normalizedNames: Map(0), lazyUpdate: null, lazyInit: lazyInit() } ​ message: "Http failure during parsing for http://localhost:9000/jasper/relatorio/testejasper" ​ name: "HttpErrorResponse" ​ ok: false ​ status: 200 ​ statusText: "OK" ​ url: "http://localhost:9000/jasper/relatorio/testejasper" ​ : Object { constructor: HttpErrorResponse() } core.js:15724 Angular 4 RxJS 5 Angular 11

如何在不发生此错误的情况下获取此字节数组?

我也试过将这个配置传递给请求:

new HttpHeaders({Accept: 'application/pdf', 'Content-Type': 'application/pdf', responseType: 'blob'});

responseType 不应在 header 中。这是一个单独的参数。

this.http.get(url, { headers: ... , responseType: 'blob' })