0

I want to show the pdf inside the modal window using ajax, The url I am calling is sending response type as "application/pdf" , when I show the http.responseText into the modal div, it shows some unreadable text.

>>> endobj 15 0 obj <> endobj 16 0 obj <>/ProcSet[/PDF/Text/ImageC]/XObject<>>>/Rotate 0/Type/Page>> endobj 17 0 obj <>stream h޴�mo�rǿ�y���|&�I�$��"No�.���M8�a+ͷ��7C��Vd7�r�\�p8�3��a;�z[=�v�R?�-�8��mEtB:�N����:q��ԩ��괦'��u;��/����⻫��~��~~>|~��{����^=�~�������ǯ����y�?zt�ͫ�7�m�w�.����O�ᷙp}������葦�ۛ�Wo��gO�_��������~�~{���Ͼ|�ꧫ�/�������u���3�}�E�R�����W7��M__������n-���W>���7/.~{��W������mv˶m���7��^����.y����>t��R��0���_�.����o��|� ?�ysu�엋��z�������y\<��|q��˗?��:lOo�~��aċ~}eS�����Wo.�sn��b[����S����������+��������}��_/__,�^<�Q;��ᑧ��tz� @t���m���v�l�͞����.0�a�v�-b� z��."K;7��6=Z��=�8�G���!��9�����Ɓ��6� z��C��W�X� (�i��x�Ck~�m�[��U�KaN>�Re4�u���2^f�@8֪� ����&�E�\m�b�н/ދ��D�~�1^r:j=�����I,��fJ�&ę���82�� � ǃ�a�`�Q�9�{fa�:q{(j����@q���c�SD���{@�f�����) �uHeϥX�d=��;D�&p�������s�9�!zN���KT�aG���T'����� "��1ky�2������І(���W-�^�'b�A廒�i��#���Ў�i?�6\��\��c�sz�:��V�ut��.�$���4����9ݏ���f�B���Dw�Yp����^!�J��&�i���!/�p����1�[L�C1�E�[6B�� j� R�ÑlӯF��(u�l�0���\��

Aditya Rai
  • 139
  • 8
  • 3
    The url that you're calling - set that as an `iframe`s `src`, and embed the `iframe` in the modal. Easy one that. –  Feb 18 '17 at 14:44
  • 2
    Possible duplicate of [Display PDF using an AJAX call](http://stackoverflow.com/questions/14559060/display-pdf-using-an-ajax-call) – Nikunj Sardhara Feb 18 '17 at 14:48
  • "show pdf on web page ajax" google this keyword and then click on first result. Learn to google first. – Nikunj Sardhara Feb 18 '17 at 14:49

1 Answers1

0

You're not going to get text by returning the pdf, you have to have a program that will interpret that data, which is normally the pdf reader plugin that most modern browsers are equipped with.

Use an iframe in your modal:

<div class="modal">
    <iframe src="/url-to-pdf"></iframe>
</div>

This is a rough example, but you get the idea. If this is embedded in your html, the iframe will be loaded automatically, so you may want to choose when to invoke it via javascript.

Captain Hypertext
  • 2,446
  • 4
  • 27
  • 36