I am trying print the pdf file in my local using printer. This is a code, tried to print.
fs.readFile('documents/AccountStatement.pdf', function(err, data) {
if (err)
throw err;
var printer = ipp.Printer("http://hostname:631/ipp/printer");
var msg = {
"operation-attributes-tag": {
"requesting-user-name": "KUMA1936",
"job-name": "My Test Job",
"document-format": "application/pdf"
},
data: data
};
printer.execute("Print-Job", msg, function(err, res){
console.log(res);
console.log(err);
});
});
In the above code what does printer.execute() method and "Print-Job" parameter. And what does 631 here.When i print the res,its shows
{ version: '1.1', statusCode: 'server-error-operation-not-supported', id: 442076, 'operation-attributes-tag': { 'attributes-charset': 'utf-8', 'attributes-natural-language': 'en-us' } } err is null.
You can check the API docs. The first parameter (string) is an operation defined by IPP. Description about
Print-Job
operation is given hereYou can see other IPP supported operations here. 631 is the accepted port used for IPP, which uses TCP.
You can check more about the error here, which shows :
This means that there is no error in your code. Most likely your printer is not configured or does not support IPP. Last but not the least, the
IPP.Printer
has to be given the printer IP. So check the IP you are giving is valid (your code shows you gave hostname). From the project page it is given :