I want to download pdf directly from api response but the format that i am getting from api response is this :
%PDF-1.7 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R 9 0 R ] /Count 2 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R /F2 11 0 R
/MediaBox [0.000 0.000 595.280 841.890] endobj 4 0 obj [/PDF /Text ] endobj 5 0 obj << /Producer (��dompdf 1.2.1 CPDF) /CreationDate (D:20221029062939 00'00') /ModDate (D:20221029062939 00'00') endobj 6 0 obj << /Type /Page /MediaBox [0.000 0.000 595.280 841.890] /Parent 3 0 R /Contents 7 0 R endobj 7 0 obj << /Filter /FlateDecode /Length 189 >> stream x�u��J�@F�<�W���3���"��N,B2w�$˾�R����;�[HB
���І�t�=V1)�����s�XR�v�ի�:&v�9g<>KHAa�^S����Mc�us<| ��)lef2B��m�c̸&(Y�;_R.Ѵ��Zk�ZƐ�~��ˀ�Y������n�%��|/QO�J���P� endstream endobj 8 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding endobj 9 0 obj << /Type /Page /MediaBox [0.000 0.000 595.280 841.890] /Parent 3 0 R /Contents 10 0 R endobj 10 0 obj << /Filter /FlateDecode /Length 949 >> stream x��W�n�F}�WHk��K��$N�)�XA�>0��&B�I���wIi�2d]A��Μ���g�IΡ�Yߞ ����?*�p�2�1�8��7�7g$٫��3g8�
�� ������� �?υV/���{�\�JZ&�Dv�4�{���c�͗�YɄ h~_mʶ�ќ3��f���8ôt? o6��ɜ��4�s�����6=�e��DVP%{�m�|��XV]���c$<S�*�"g�ͤ�\�r����t.Qi��=��N �r�!��]?Q���{�bwpĻ2o��ϗ0�)i�tfI�if �1�KG@��b��ME�?���mK��cg���DMfB̸F _g�2E\��4������>=f� h:%�QU���T|���"��z�Y���ͫrP�$ӹ&�fD�j�[H/xWn \5��q��?l�Э0m�{L��? I7��0�������N�3KBN3;*�-��}�]���MB�栄��9һF*�&Hf��$-V�r5�3�-Vk�GzÜn�=����5�訪,(��Zl�i�bӠ����<7��8]���$A�L tG��4i�S�I3 ��%�?e<�QsQ�Y�\[3V�4(-��@a/��̓>yUĬ�x۹�[Xg��w��V�����*��a���jUǦyIQs<ϓ�vU-������}��H�e�L��'<N���!˱#��^ge���۪�v�൵�:�/�E��|y.�����3|�
�W@r����c�ϋ���x��"�I�QIj�����j�w��t�]p�X�*/�g�e�p�\�>����%ʜ7�������w���$#��8)աk��Ep̓��ŎH�N��R�� �����ɕ�X����� &I52���\�z̷�����oc�� ||=��ž�� �pM�'��s���]�X�$�ԭk�d����I endstream endobj 11 0 obj << /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding endobj xref 0 12 0000000000 65535 f 0000000009 00000 n 0000000074 00000 n 0000000120 00000 n 0000000291 00000 n 0000000320 00000 n 0000000469 00000 n 0000000572 00000 n 0000000833 00000 n 0000000940 00000 n 0000001044 00000 n 0000002066 00000 n trailer << /Size 12 /Root 1 0 R /Info 5 0 R /ID[<71468b7d13dde79b89173b27b85d8251><71468b7d13dde79b89173b27b85d8251>] startxref 2179 %%EOF
So any one has idea how to download this kind of file directly!
I tried using
fileDownload(apiCall.data, `customer-${payload.customer_id}.pdf`);
CodePudding user response:
You want to download the PDF to the user. Just put a anchor tag in the template, so the download can be done with a link.
<a href="customer-${payload.customer_id}.pdf">Download PDF</a>
Note: It seems you are using the React File Download (npm). This is to download a file (data) to use in javascript. I suppose the file should be downloaded to the user.
CodePudding user response:
You want to download the PDF to the user. It can be done with a simple call.
window.location = "<URL computed from javacript>"