I am generating PDF through PDFkit npm and want to upload it in media manager but media manager method upload() only supports Buffer of the file and URL of the file.
I tried to get buffer of the file by installing Buffer npm and for Blob used blob-stream npm but both are not working.
Here is the code of Blob
export function testPDF(parameter) {
const doc = new PDFDocument();
const stream = doc . pipe(blobStream ());
doc . end ();
stream . on ( ‘finish’ , function () {
const blob = stream . toBlob ( ‘application/pdf’ );
const ul **=** stream . toBlobURL ( 'application/pdf' );
consol.log( url);
});
}
Here the code of Buffer
let buffers = ;
pdf.on(‘data’, buffers.push.bind(buffers));
pdf.on(‘end’, () => {
let pdfData = Buffer .concat(buffers);
});
pdf.text(‘Hello’, 100, 100);
pdf.end();