I am using the jsPDF plugin that generates a PDF and saves it on the local file system. Now in jsPDF.js there is a piece of code that generates data in blob format in the form: -
var blob = new Blob([array], {type: "application/pdf"});
and then saves blob data on the local file system. Now, instead of saving, I need to print the PDF using the node-printer plugin .
Here is a sample code for this
var fs = require('fs'),
var dataToPrinter;
fs.readFile('/home/ubuntu/test.pdf', function(err, data){
dataToPrinter = data;
}
var printer = require("../lib");
printer.printDirect({
data: dataToPrinter,
printer:'Deskjet_3540',
type: 'PDF',
success: function(id) {
console.log('printed with id ' + id);
},
error: function(err) {
console.error('error on printing: ' + err);
}
})
fs.readFile() reads a PDF file and generates raw buffer data.
Now I want to convert the "Blob" data to a "raw buffer" so that I can print the PDF.