-1

I am fetching data following this answer. It works very well for html pages. But I am trying to get link to pdf file.

                          fetch(v3).then(function(d) {
                                console.log(d);
                                return d.text();
                            }).then(function(h) {
                                console.log(h); //--------------------
//--------------------------------------
                            }).catch(function(err) {
                                console.log(err);
                            })

console.log(h) in above code return

%PDF-1.5

%����

1 0 obj

<</Type/Catalog/Pages 2 0 R/Lang(en-SG) /StructTreeRoot 26 0 R/MarkInfo<</Marked true>>>>

endobj

2 0 obj

<</Type/Pages/Count 4/Kids[ 3 0 R 15 0 R 22 0 R 24 0 R] >>

endobj

3 0 obj

<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 5 0 R/F2 9 0 R/F3 11 0 R/F4 13 0 R>>/ExtGState<</GS7 7 0 R/GS8 8 0 R>>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/MediaBox[ 0 0 841.92 595.32] /Contents 4 0 R/Group<</Type/Group/S/Transparency/CS/DeviceRGB>>/Tabs/S/StructParents 0>>

endobj

4 0 obj

<</Filter/FlateDecode/Length 7669>>

stream

x���K��8������t��l�D�za����cwo?�����w�����0v��*=��_>��%2�L*m�
��`D(�"��(���������S�׿^?9����<��^]����������׿�����N7w��/>�qR���xxs���ߪo�}Z���n�?�;�WM5
VO�ꦮnyu�|����R�>~���Ǐ��������˷��1)�T������z�A�<�1T������m�ߞ?~�jW���^���G������Q��sdiG۾f�S��v���������Q=���■�����mWO������<~�����Uk~�Տ��^��� �śU��G��f���jE݌US�B�z����ee�m���J/۶��X��u�P�����a�%v��+��>�y����VO��2�o�bws�A~�q�S�>��b`�@�|zx�_u�r�{��ݮ��av/y��K�#�����/�m��2�̓J龺W��k!�|���V*��x3�u�%���/T…

My question is how to parse this data into meaningful data?

Mayank Kumar Chaudhari
  • 16,027
  • 10
  • 55
  • 122

1 Answers1

1

Solved using pdf.js.

You can find more details at following official repo

https://github.com/mozilla/pdf.js

Mayank Kumar Chaudhari
  • 16,027
  • 10
  • 55
  • 122