I am using PDFkit.js to export pdf. My page contains images. TO add images i am using
var doc = new PDFDocument({
bufferPages: true
});
var stream = doc.pipe(blobStream());
var iframe = $('iframe')[0];
var x = 0;
var y = 0;
var img;
doc.image('http://mylogo.png', 20, 15, {width:100})
.text('Proportional to width', 0, 0);
doc.flushPages();
// end and display the document in the iframe to the right
doc.end();
stream.on('finish', function() {
iframe.src = stream.toBlobURL('application/pdf');
});
Included In script:
<script src="{{asset('/js/pdfkit.standalone.js')}}"></script>
<script src="{{asset('/js/blob-stream.js')}}"></script>
But it is not displaying Image in PDF.
ERROR: fs.readFileSync is not a function