title: Save pdf response
body: <p>I'm trying to save a pdf file sent by my node.js server.
  the Pdf is created with <a href="http://pdfkit.org/" rel="nofollow">pdfkit</a> .
  this is the log of the response : </p>
  
  <pre><code>    {"readyState":4,"responseText":"%PDF-1.3\n%����\n5 0 obj\n&lt;&lt;\n/Type /Page\n/Parent 1 0 R\n/MediaBox [0 0 612 792]\n/Contents 3 0 R\n/Resources 4 0 R\n&gt;&gt;\nendobj\n4 0 obj\n&lt;&lt;\n/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n&gt;&gt;\nendobj\n10 0 obj\n&lt;&lt;\n/Type /ExtGState\n/ca 1\n&gt;&gt;\nendobj\n8 0 obj\n&lt;&lt;\n/Type /Page\n/Parent 1 0 R\n/MediaBox [0 0 612 792]\n/Contents 6 0 R\n/Resources 7 0 R\n&gt;&gt;\nendobj\n7 0 obj\n&lt;&lt;\n/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n/Font &lt;&lt;\n/F1 9 0 R\n&gt;&gt;\n/ExtGState &lt;&lt;\n/Gs1 10 0 R\n&gt;&gt;\n&gt;&gt;\nendobj\n14 0 obj\n&lt;&lt;\n/S /URI\n/URI (http://google.com/)\n&gt;&gt;\nendobj\n15 0 obj\n&lt;&lt;\n/Subtype /Link\n/A 14 0 R\n/Type /Annot\n/Rect [100 665 260 692]\n/Border [0 0 0]\n&gt;&gt;\nendobj\n13 0 obj\n&lt;&lt;\n/Type /Page\n/Parent 1 0 R\n/MediaBox [0 0 612 792]\n/Contents 11 0 R\n/Resources 12 0 R\n/Annots [15 0 R]\n&gt;&gt;\nendobj\n12 0 obj\n&lt;&lt;\n/ProcSet [/PDF /Text /ImageB /ImageC /ImageI]\n/ExtGState &lt;&lt;\n/Gs1 10 0 R\n&gt;&gt;\n/Font &lt;&lt;\n/F1 9 0 R\n&gt;&gt;\n&gt;&gt;\nendobj\n16 0 obj\n&lt;&lt;\n/Producer (PDFKit)\n/Creator (PDFKit)\n/CreationDate (D:20160409123048Z)\n&gt;&gt;\nendobj\n9 0 obj\n&lt;&lt;\n/Type /Font\n/BaseFont /Helvetica\n/Subtype /Type1\n/Encoding /WinAnsiEncoding\n&gt;&gt;\nendobj\n2 0 obj\n&lt;&lt;\n/Type /Catalog\n/Pages 1 0 R\n&gt;&gt;\nendobj\n1 0 obj\n&lt;&lt;\n/Type /Pages\n/Count 3\n/Kids [5 0 R 8 0 R 13 0 R]\n&gt;&gt;\nendobj\n3 0 obj\n&lt;&lt;\n/Length 23\n/Filter /FlateDecode\n&gt;&gt;\nstream\nx�3T0\u0000B]C ani����\u0005\u0000\u001dI\u0003\\\nendstream\nendobj\n11 0 obj\n&lt;&lt;\n/Length 117\n/Filter /FlateDecode\n&gt;&gt;\nstream\nx�e�A\n\u00021\u0010\u0004�����f&amp;n&amp;\u0006d\u000f��g%/p����\u0004|��Y�.\n�\u0016b�J\u001c�D�\u0017¾}\u001e���D��[��-\bs\u0017�w�!��B�I���D��p\u0014�n7솭�\u001c5E֒7N��\u0016mz�2R}�Pq�\u0017Zg\u001ep\nendstream\nendobj\n6 0 obj\n&lt;&lt;\n/Length 152\n/Filter /FlateDecode\n&gt;&gt;\nstream\nx�e�A\n�@\fE�9E.`�d:�\u0005qQԮ����#�\u0015���͸p#\u001f��O�Frm؇��y�\u0017��7$`\"T�\u001a��&amp;hO��T`�m5�h\u0014�ނ�\u0005-:��T�\u0006봘�����t���A��=�;\u001c\u0013�k�Gp$\\�$N\u000f�\u001f���}��e\u001c0��c#^p�OhǕ��B�\u000f-�,�\nendstream\nendobj\nxref\n0 17\n0000000000 65535 f \n0000001091 00000 n \n0000001042 00000 n \n0000001161 00000 n \n0000000119 00000 n \n0000000015 00000 n \n0000001445 00000 n \n0000000335 00000 n \n0000000231 00000 n \n0000000945 00000 n \n0000000186 00000 n \n0000001255 00000 n \n0000000733 00000 n \n0000000609 00000 n \n0000000453 00000 n \n0000000509 00000 n \n0000000852 00000 n \ntrailer\n&lt;&lt;\n/Size 17\n/Root 2 0 R\n/Info 16 0 R\n&gt;&gt;\nstartxref\n1669\n%%EOF\n","status":200,"statusText":"OK"}
  </code></pre>
  
  <p>and this is my client code :</p>
  
  <pre><code>var data = {};
  data.azione = "getEtichettaProdotto";
  
  //Scarico i dati anagrafica
  $.ajax({
      type: 'POST',
      data: JSON.stringify(data),
      contentType: 'application/json',
      url: 'http://46.101.209.16/endpoint',                       
      complete : function(etichettas) {
          console.log(JSON.stringify(etichettas));
  
          var blob = new Blob([etichettas.responseText], {type: "application/pdf"});
          saveAs(blob, "Label.pdf");
      }//SUCCESS
  });
  </code></pre>
  
  <p>and my node.js code :</p>
  
  <pre><code>    PDFDocument = require('pdfkit');
  
  function creaEtichetta(req, res){
      doc = new PDFDocument
          size: 'a4'
          bufferPages: true
  
  
      doc.pipe(res);
      doc.addPage().fontSize(25).text('Here is some vector graphics...', 100, 100);
  
      doc.save()
     .moveTo(100, 150)
     .lineTo(100, 250)
     .lineTo(200, 250)
     .fill("#FF3300");
  
     doc.addPage().fillColor("blue").text('Here is a link!', 100, 100).link(100, 100, 160, 27, 'http://google.com/')
  
      doc.end();
  }
  exports.creaEtichetta = creaEtic
  </code></pre>
  
  <p>please help, I'm trying by a week.
  and sorry for bad english, i'm italian.</p>