0

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

Neha
  • 2,136
  • 5
  • 21
  • 50
  • `fs.readFileSync` is on your Node server, you haven't shown us that code. Edit: just realised you are using Laravel so that's what the error will be related too. – JustCarty May 18 '21 at 08:25
  • https://stackoverflow.com/questions/27019242/node-js-fs-module-inside-browser – Ben Gooding May 18 '21 at 23:03

0 Answers0