williamkapke / ipp

Internet Printing Protocol (IPP) for nodejs
414 stars 111 forks source link

page-ranges #72

Open yusef-ho opened 5 years ago

yusef-ho commented 5 years ago

Hello what is the format of page-ranges?? currently my message is

let printMsg = {
    'operation-attributes-tag': {
        'requesting-user-name': 'Hello',
        'job-name': 'iid-',
        "document-format": "application/pdf"
    },
    "job-attributes-tag": {
        "print-color-mode": "monochrome",
        "sides": "one-sided",
        "copies": 1,
        "orientation-requested": "landscape",
        "page-ranges": "1-2",
        "number-up": 2
    },
    data: file
};

without specifying page-ranges, everything goes well. but when specify page-ranges it shows

{ version: '2.0',
  statusCode: 'client-error-bad-request',
  id: 55936282,
  'operation-attributes-tag':
   { 'attributes-charset': 'utf-8',
     'attributes-natural-language': 'en-us',
     'status-message': 'Bad page-ranges values 1-0.' } }

Thanks

caomanhquang commented 5 years ago

I have the same problem, I tried to used rangeOfInteger as defined in lib/attributes.js but there's no luck. Result is success without any error, but printer out put all pages.

@williamkapke could you help me, does library support page-ranges now?

caomanhquang commented 5 years ago

@williamkapke I've fixed lib/serializer.js a bit, now I can set page-ranges as a rangeOfInteger (e.g 1..3 or 2..4). But I still cannot set a 1setOf rangeOfInteger. When I try, it seems that only last range takes effect.

Do you know how to encode 1setOf rangeOfInteger correctly?

I read rfc2910 to see how to encode 1setOf X but it only say this: Encoding according to the rules for an attribute with more than 1 value. No more detail.

michaelrsweet commented 5 years ago

First, stop using RFC 2910. We published an update (RFC 8010 for 2910, and 8011 for 2911) over two years ago...

Second, all 1setOf values are encoded the same - the first value is encoded with the attribute name and the subsequent values are encoded with an empty (0-length) name, e.g. page-ranges=1-3,5-9,11-15 would be encoded as:

0x33 (rangeOfInteger)
0x00 0x0b (name-length)
"page-ranges" (name)
0x00 0x08 (value-length)
0x00 0x00 0x00 0x01 0x00 0x00 0x00 0x03 (1..3)
0x33 (rangeOfInteger)
0x00 0x00 (name-length)
0x00 0x08 (value-length)
0x00 0x00 0x00 0x05 0x00 0x00 0x00 0x09 (5..9)
0x33 (rangeOfInteger)
0x00 0x00 (name-length)
0x00 0x08 (value-length)
0x00 0x00 0x00 0x0b 0x00 0x00 0x00 0x0f (11..15)

That said, keep in mind that many printers don't support page-ranges, and if they do they may only support a single range... :/

caomanhquang commented 5 years ago

@michaelrsweet Thanks a lot for replying me. I understood.

My printers are HP LaserJet Pro MFP M225dw and NEC Color MultiWriter 5800C. When I check by Get-Printer-Attributes they return "page-ranges-supported": true I also tried some other ipp implementations, e.g ipptool (from CUPS), jipp (from HPInc) and pass a set of multiple ranges, it seems that only the last range in the set is used by the printer.

I'm wondering is there any way to check whether printer support multiple range or single range, do you have any advice?

michaelrsweet commented 5 years ago

Currently there is not a way to determine the maximum number of values a printer supports... :/

caomanhquang commented 5 years ago

@michaelrsweet Thank you.

fpauser commented 4 years ago

So the only solid solution is not to use page-ranges?

manuelnucci commented 4 years ago

Any update on this? @caomanhquang, what did you do in the end?

caomanhquang commented 4 years ago

@manuelnucci Because this is the problem from printer, I could not do anything to solve completely. Luckily, I control pdf content so I re-generated a new pdf file from the pages which user chose 😅

manuelnucci commented 4 years ago

Great, I'll try to do the same for the moment...

Rebnerd commented 2 years ago

rangeOfInteger how exactly did you fixed it? can you post the code ?