Converting image to PDF using jspdf library on the SCA website

since there are no standard methods available in the NetSuite or SCA to convert an image to PDF we can use jspdf package via CDN URL. We can achieve this requirement by following solution:

We can use the jspdf CDN URL `https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js` to use the jspdf package by using jquery’s getScript method

$.getScript(“https://cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js”)

let doc = new jsPDF();

let base64String = “data:image/jpeg;base64,/9j/7z…”; //image to base64 converted

doc.addImage(base64String, ‘JPEG’, 5, 5, 200, 200);// 200, 200 is the size of the image rendered inPDF

doc.save(‘liquidefireJOY.pdf’);

Leave a comment

Your email address will not be published. Required fields are marked *