{"id":13754640,"url":"https://github.com/williamkapke/ipp","last_synced_at":"2025-05-16T08:05:20.496Z","repository":{"id":7090773,"uuid":"8381667","full_name":"williamkapke/ipp","owner":"williamkapke","description":"Internet Printing Protocol (IPP) for nodejs","archived":false,"fork":false,"pushed_at":"2022-08-17T09:24:03.000Z","size":126,"stargazers_count":424,"open_issues_count":47,"forks_count":114,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-05-12T19:13:27.565Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/williamkapke.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-23T20:48:50.000Z","updated_at":"2025-04-17T02:04:27.000Z","dependencies_parsed_at":"2022-08-19T21:10:37.570Z","dependency_job_id":null,"html_url":"https://github.com/williamkapke/ipp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamkapke%2Fipp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamkapke%2Fipp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamkapke%2Fipp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/williamkapke%2Fipp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/williamkapke","download_url":"https://codeload.github.com/williamkapke/ipp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T10:00:31.851Z","updated_at":"2025-05-16T08:05:15.487Z","avatar_url":"https://github.com/williamkapke.png","language":"JavaScript","readme":"# Internet Printing Protocol (IPP) for nodejs\n---\n\nA pure Javascript implementation of the IPP/2.0 protocol that has no dependencies.\n\nThe IPP protocol was started in the 90's and is still being worked on today. It is a very indepth protocol that spans many \nRFCs- some of which are dead while others were herded into IPP/v2.x.\n\nThere are millions of printers that support IPP. If you have one, this module will allow you to send/recieve data to/from \nthe printer.\n\nTo find out if your printer supports IPP:\n\n* Google your printer's specs\n* Try: `telnet YOUR_PRINTER 631`. If it connects, that's a good sign.\n* Use the ['/examples/findPrinters.js'](https://github.com/williamkapke/ipp/tree/master/examples/findPrinters.js) script.\n\nI have a pretty good starting point here. I created reference files \n(`attributes`, `enums`, `keywords`, `operations`, `status-codes`, `versions` and `tags`) and tried to include as many \nlinks in the comments to the ref docs as I could.\n\n\n### Install\n```bash\n$ npm install ipp\n```\n\n\n## Printer(url [,options])\n```javascript\nvar ipp = require('ipp');\nvar PDFDocument = require('pdfkit');\n\n//make a PDF document\nvar doc = new PDFDocument({margin:0});\ndoc.text(\".\", 0, 780);\n\ndoc.output(function(pdf){\n\tvar printer = ipp.Printer(\"http://NPI977E4E.local.:631/ipp/printer\");\n\tvar msg = {\n\t\t\"operation-attributes-tag\": {\n\t\t\t\"requesting-user-name\": \"William\",\n\t\t\t\"job-name\": \"My Test Job\",\n\t\t\t\"document-format\": \"application/pdf\"\n\t\t},\n\t\tdata: pdf\n\t};\n\tprinter.execute(\"Print-Job\", msg, function(err, res){\n\t\tconsole.log(res);\n\t});\n});\n```\n\nTo interact with a printer, create a `Printer` object.\n\n\u003e Technically speaking: a `Printer` object does not need to be an actual printer. According to the IPP spec, it\n\u003e could be any endpoint that accepts IPP messages. For example; the IPP object __could__ be persistant media- like a\n\u003e CD ROM, hard drive, thumb drive, ...etc.\n\n**options:**\n* `charset` - Specifies the value for the 'attributes-charset' attribute of requests. Defaults to `utf-8`.\n* `language` - Specifies the value for the 'attributes-natural-language' attribute of requests. Defaults to `en-us`.\n* `uri` - Specifies the value for the 'printer-uri' attribute of requests. Defaults to `ipp://+url.host+url.path`.\n* `version` - Specifies the value for the 'version' attribute of requests. Defaults to `2.0`.\n\n\n\n\n\n### printer.execute(operation, message, callback)\nExecutes an IPP operation on the Printer object.\n\n* 'operation' - There are many operations defined by IPP. See: [/lib/enums.js](https://github.com/williamkapke/ipp/blob/master/lib/enums.js#L52).\n* 'message - A javascript object to be serealized into an IPP binary message.\n* 'callback(err, response)' - A function to callback with the Printer's response.\n\n## ipp.parse(buffer)\n\nParses a binary IPP message into a javascript object tree.\n\n```javascript\nvar ipp = require('ipp');\nvar data = new Buffer(\n    '0200' +\t//version 2.0\n\t\t'000B' +\t//Get-Printer-Attributes\n\t\t'00000001'+\t//reqid\n\t\t'01' +\t\t//operation-attributes-tag\n\t\t//blah blah the required bloat of this protocol\n\t\t'470012617474726962757465732d6368617273657400057574662d3848001b617474726962757465732d6e61747572616c2d6c616e67756167650002656e' +\n\t\t'03'\t\t//end-of-attributes-tag\n\t,'hex');\n\n\nvar result = ipp.parse(data);\nconsole.log(JSON.stringify(result,null,2));\n//  ta-da!\n//{\n//\t\"version\": \"2.0\",\n//\t\"operation\": 11,\n//\t\"id\": 1,\n//\t\"operation-attributes-tag\": {\n//\t\t\"attributes-charset\": \"utf-8\",\n//\t\t\"attributes-natural-language\": \"en\"\n//\t}\n//}\n```\n\n## ipp.serialize(msg)\nConverts an IPP message object to IPP binary.\n\nSee [request](#request) for example.\n\n\u003ca id=\"request\"\u003e\u003c/a\u003e\n## ipp.request(url, data, callback)\n\nMakes an IPP request to a url.\n\n```javascript\nvar ipp = require('ipp');\nvar uri = \"your_printer\";\nvar data = ipp.serialize({\n\t\"operation\":\"Get-Printer-Attributes\",\n\t\"operation-attributes-tag\": {\n\t\t\"attributes-charset\": \"utf-8\",\n\t\t\"attributes-natural-language\": \"en\",\n\t\t\"printer-uri\": uri\n\t}\n});\n\nipp.request(uri, data, function(err, res){\n\tif(err){\n\t\treturn console.log(err);\n\t}\n\tconsole.log(JSON.stringify(res,null,2));\n})\n//  ta-da!.. hopefully you'll see a ton of stuff from your printer\n```\n\n## Browser Support?\nSee [this thread](https://github.com/williamkapke/ipp/issues/3)\n\n## License\n\nMIT\n","funding_links":[],"categories":["4. 工具"],"sub_categories":["4.2 系统相关"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamkapke%2Fipp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwilliamkapke%2Fipp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwilliamkapke%2Fipp/lists"}