Nodejs jsPdf image is not rendring when upload generated pdf to google drive or Box

19 views Asked by At

I am required to Create a PDF and upload it to Google Drive and BOX, not going to download PDF in NodeJS. For that I use JsPDF library Below is my code. JsPDF version used - 2.5.1

import JsPDF from 'jspdf'
var doc = new JsPDF()
doc.setFontSize(40)
doc.text('INVOICE', 170, 30)
var myImage = '<base64 image>'
doc.addImage(myImage, 'PNG', 15, 40, 100, 50)

var pdfStream = doc.output()

 // Upload pdfStream and create file in google drive.
 const uploadToDrivePDF = await googleDriveService.upload(googleAuth, {
       name: 'Test.pdf,
      stream: pdfStream,
     convertTo: 'pdf',
    })    

By using above code, pdf successfully created on drive but image is not included in the pdf, only text is showing. I searched lot but not getting proper solution for this.

0

There are 0 answers