Reputation: 1542
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.
Upvotes: 2
Views: 5136
Reputation: 1124
Upvotes: 0
Reputation: 22167
In my case i just share the printer : (like share with another)
So URL gonna be (you will be found by findPrinters.js)
http://My-Computer-Name.local.:631/printers/my_printer_name
This should be help if your printer donesnt connect (like USB) with your computer. But connect via lan.
Upvotes: 0
Reputation: 48003
You can check the API docs. The first parameter (string) is an operation defined by IPP.
Description about Print-Job
operation is given here
3.2.1 Print-Job Operation This REQUIRED operation allows a client to submit a print job with only one document and supply the document data (rather than just a reference to the data). See Section 15 for the suggested steps for processing create operations and their Operation and Job Template attributes.
You 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 :
13.1.5.2 server-error-operation-not-supported (0x0501) The IPP object does not support the functionality required to fulfill the request. This is the appropriate response when the IPP object does not recognize an operation or is not capable of supporting it. See sections 3.1.6.1 and 3.1.7.
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 :
To find out if your printer supports IPP: - Google your printer's specs - Try: telnet YOUR_PRINTER 631. If it connects, that's a good sign. - Use the '/examples/findPrinters.js' script.
Upvotes: 1