I am a beginner in javascript and web programming I am using node to create a pdf file and pipe it as an http response
On the client-side I am using angularjs to create blob from the response. Instead of getting a correct pdf file, i am getting a pdf page with a blank page. Did I created blob the wrong way? Is there something I missed?
I did try researching the internet, the closest thing I found is this: AngularJS: Display blob (.pdf) in an angular app
but it still does not work after i followed the instructions
my code:
$http.get('pdf-page', null, { responseType: 'arraybuffer' })
.success(function (res) {
console.log(res);
var file = new Blob([data], {type: 'application/pdf'});
var fileURL = URL.createObjectURL(file);
window.open(fileURL);
});
result of console.log(res):
%PDF-1.3 %���� 5 0 obj << /Type /Page /Parent 1 0 R /MediaBox [0 0 612 792] /Contents 3 0 R /Resources 4 0 R
endobj 4 0 obj << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] /Font << /F1 6 0 R
endobj 7 0 obj << /Producer (��PDFKit) /Creator (��PDFKit) /CreationDate (D:20150121171417Z) endobj 6 0 obj << /Type /Font /BaseFont /Helvetica /Subtype /Type1 /Encoding /WinAnsiEncoding endobj 2 0 obj << /Type /Catalog /Pages 1 0 R endobj 1 0 obj << /Type /Pages /Count 1 /Kids [5 0 R] endobj 3 0 obj << /Length 110 /Filter /FlateDecode stream x�e�A QC�=E/�����`p!�^� ������o�^�$$�F���%�����_w+q3�l�6��&�����!�h8�a�e�ș�.�0�08vrpd�H6�k�֯Zo��<���� endstream endobj xref 0 8 0000000000 65535 f 0000000462 00000 n 0000000413 00000 n 0000000519 00000 n 0000000119 00000 n 0000000015 00000 n 0000000316 00000 n 0000000208 00000 n trailer << /Size 7 /Root 2 0 R /Info 7 0 R startxref 701 %%EOF