Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot print on another paper tray via IPP

I'm trying to print a document on the second paper tray with IPP (Internet Printing Protocol). I'm using this npm IPP-Library.

But at any time i try to print a document my printer shows a message that i need to add paper to the first paper tray and the console output of says Printed: successful-ok.

var ipp = require("ipp");
var PDFDocument = require("pdfkit");
var concat = require("concat-stream");

var doc = new PDFDocument;
doc.text("Hello World");

doc.pipe(concat(function (data) {
    var printer = ipp.Printer("MY_URL");

    var file = {
        "operation-attributes-tag": {
            "requesting-user-name": "admin",
            'attributes-charset': 'utf-8',
            'attributes-natural-language': 'de'
        },
        "printer-attributes": {
            "media-col": {
                "media-source": "tray-2"
            },
        },
        data: data
    };
    printer.execute("Print-Job", file, function (err, res) {
        console.log("Printed: " + res.statusCode);
    });
}));

doc.end();

The other variant i tried is following (from here):

var PDFDocument = require("pdfkit");
let fs = require('fs')
var ipp = require('ipp');
var uri = "http://10.1.205.71";


var msg = new Buffer(
  '0200'+ //Version
  '000201e6d5f2'+
  '01'+ //Operation attributes tag (your information in the Operation attributes might be different)
    '47'+ //charset tag
    '0012'+ //length
    '617474726962757465732d63686172736574'+ //attributes-charset
    '0005'+ //length
    '7574662d38'+ //utf-8
    '48'+ //natural language tag
    '001b'+ //length
    '617474726962757465732d6e61747572616c2d6c616e6775616765'+//attributes-natural-language
    '0002'+//length
    '656e'+ //en
    '45'+ // URI tag
    '000b'+ //length
    '7072696e7465722d757269'+ //printer-uri
    '0012'+//length
    '687474703a2f2f31302e312e3230352e3731'+//http://10.1.205.71
    '49'+ //mimeMediaType tag
    '000f'+ //length
    '646f63756d656e742d666f726d6174'+ //document format
    '000f'+ //length
    '6170706c69636174696f6e2f706466'+ //application/pdf
  '02'+ //job attributes tag
    '34'+ //begin collection
      '0009'+ //length
      '6d656469612d636f6c'+ //media-col
      '0000'+ //value length
      '4a'+ //collection entry
      '0000'+ //name length
      '000c'+ //value length
      '6d656469612d736f75726365'+ //media-source
      '44'+ // collection entry
      '0000'+ //name length
      '0006'+ //value length
      '747261792d32'+ //tray-2
    '37'+ //end of collection
    '00000000'+ //name length and value length
  '03', 'hex');

var doc = new PDFDocument;
doc.text("Hello World");

var buffers = [];
doc.on('data', buffers.push.bind(buffers));
doc.on('end', function(){
  var buf = Buffer.concat(buffers);
  var catBuf = Buffer.concat([msg, buf]);
  ipp.request(uri, catBuf, function(err, res){
    if(err){
      return console.log(err);
    }
    console.log(JSON.stringify(res,null,2));
  });
});
doc.end();

But then i got this error message:

{ 
Error
    at new IppResponseError (/Users/alex/dev/print/printing/node_modules/ipp/lib/request.js:72:17)
    at ClientRequest.<anonymous> (/Users/alex/dev/print/printing/node_modules/ipp/lib/request.js:40:8)
    at Object.onceWrapper (events.js:293:19)
    at emitOne (events.js:96:13)
    at ClientRequest.emit (events.js:191:7)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:522:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)
    at Socket.socketOnData (_http_client.js:411:20)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:191:7)
  name: 'IppResponseError',
  statusCode: 400,
  message: 'Received unexpected response status 400 from the printer',
  stack: 'Error\n    at new IppResponseError (/Users/alex/dev/print/printing/node_modules/ipp/lib/request.js:72:17)\n    at ClientRequest.<anonymous> (/Users/alex/dev/print/printing/node_modules/ipp/lib/request.js:40:8)\n    at Object.onceWrapper (events.js:293:19)\n    at emitOne (events.js:96:13)\n    at ClientRequest.emit (events.js:191:7)\n    at HTTPParser.parserOnIncomingClient [as onIncoming] (_http_client.js:522:21)\n    at HTTPParser.parserOnHeadersComplete (_http_common.js:99:23)\n    at Socket.socketOnData (_http_client.js:411:20)\n    at emitOne (events.js:96:13)\n    at Socket.emit (events.js:191:7)' }
400 'response'

My printer does not support IPP, but i shared it on my Macbook, which provides an IPP service for all shared printers. If i'm using the first paper tray and have paper in there everything is fine, but for my project it is necessary to print on other trays, too.

The attributes' list returned from Get-Printer-Attributes lists among other trays the second paper as supported media-source, but only the first paper tray works.

Does anyone have an idea how to print successfully on another paper tray?

Update: I also tried another printer, but i got the same error.

Update 22.06.17: It's still confused and don't have any clue how to fix this.

like image 908
Batajus Avatar asked May 23 '17 20:05

Batajus


People also ask

How do I print from second tray?

Right-click your product, and then select Printing Preferences. From the Printing Preferences menu, select Paper/Quality. From the Paper Source drop-down menu, select Tray 2. From the Paper Size drop-down menu, select the appropriate paper size for the print job.

Why is my printer using bypass tray?

The bypass tray, also known as the multi-purpose tray or general-purpose tray, is a tray on your copier that can be used to print jobs on media that cannot be run from the main trays of your device. Use it for OHP transparencies, adhesive labels, translucent paper, and paper that cannot be loaded in the paper trays.


1 Answers

It appears that this pull request might be able to solve the issue you're having. Until the author of ipp merges the pull request, you can update your npm package to point to that patch by running the following in your project directory:

npm i --save ipp@github:jaymcaliley/ipp
like image 122
Patrick Roberts Avatar answered Oct 24 '22 13:10

Patrick Roberts