, , , . js-base64-file
const Base64File=require('js-base64-file');
const b64PDF=new Base64File;
const file='yourPDF.pdf';
const path=`${__dirname}/path/to/pdf/`;
const doc = new PDFDocument();
doc.addPage();
const data=b64PDF.loadSync(path,file);
console.log('Base64 PDF representation', pdfAsText);
b64PDF.save(data,path,`copy-b64-${file}`);
, , async.
b64PDF.load(
path,
file,
function(err,base64){
if(err){
process.exit(1);
}
console.log('ASYNC: you could send this PDF via ws or http to the browser now\n');
b64PDF.save(base64,path,`copy-async-${file}`);
}
);
, . , base64