0

I have a WSDL that sends me a PDF in byte format and I want to open this PDF in a new window with javascript. The problem is that I can't transfom the encoded bytes into PDF. I tried this code but it doesn't work I don't know if it's because I have a picture in my PDF and some lines or this version if for older browsers.

var getReleveDoc = function(i) {
  var datas = {
    'service': 'relevePrest',
    'i': $('#idNumPersonne').val(),
    'n': $('#numRlv_td' + i).text(),
    'b': $('#numBatch_td' + i).text(),
    'e': $('#codeEntite').val()
  };

  $.get('./download',
    datas,
    function(data) {
      if (data.security) {
        location.reload();
      } else if (data.erreur) {
        erreur(data.erreur);
      } else {
        var blob = new Blob([data], {
          type: "application/pdf"
        });
        var link = window.URL.createObjectURL(blob);
        window.open(link, '', 'height=650,width=840');
      }

      ready();
    });
};

Here is a little part of my generated bytes

1.4
%����
1 0 obj
<<
/Keywords ()
/Creator (BdocPDF V5.3)
/Producer (Apache FOP Version svn-trunk)
/CreationDate (D:20200120134322+00'00')
>>
endobj
2 0 obj
<<
  /N 3
  /Length 3 0 R
  /Filter /FlateDecode
>>
stream
x���wTS��Ͻ7�P����khRH
�H�.*1  J�� "6DTpDQ��2(���C��"��Q��D�qp�Id�߼y�͛��~k����g�}ֺ ����LX  ��X��ň��g`� l �p��B�F�|،l���� ��*�?�� ����Y"1 P������\�8=W�%�Oɘ�4M�0J�"Y�2V�s�,[|��e9�2�<�s��e���'��9���`���2�&c�tI�@�o��|N6 (��.�sSdl-c�(2�-�y �H�_��/X������Z.$��&\S�������M����07�#�1ؙY�r f��Yym�";�8980m-m�(�]����v�^��D���W~�
Rory McCrossan
  • 331,213
  • 40
  • 305
  • 339
Saad
  • 9
  • 1
  • 1
    Please remove the Java tag, this is not java related. – mwarren Jan 21 '20 at 14:58
  • Does this answer your question? [Opening PDF String in new window with javascript](https://stackoverflow.com/questions/2805330/opening-pdf-string-in-new-window-with-javascript) – Anurag Srivastava Jan 21 '20 at 17:53

0 Answers0