Package Exports
- ipp-printer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ipp-printer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ipp-printer
Create a printer on your network using nothing but Node.js. This module implements version 1.1 of the IPP protocol and uses Bonjour to advertise a printer on your local network that anyone can print to.
This module is still work in progress!
Installation
npm install ipp-printer
Usage
var Printer = require('ipp-printer')
var printer = new Printer('My Printer')
printer.on('job', function (job) {
var file = fs.createWriteStream('job.js')
job.pipe(file)
})
API
new Printer([options])
The Printer object can be initialized with either the printer name as a string or an object containing:
name
- Optional name of the printer (defaults toNode JS
)port
- Optional port the printer should listen on (defaults to a random available port)
Note that the IPP standard specifies port 631 as the default IPP port, but most IPP clients are fine with connecting to another port.
Event: job
function (job) {}
Emitted each time a new job is sent to the printer. The job
is a
readable stream of the document data being printed.
Each job object have the following attributes:
id
- The id of the jobstate
- The job stateattributes
- The job attributes
Attributes example:
[
{ tag: 0x45, name: 'job-printer-uri', value: 'ipp://watson.local.:3000/' },
{ tag: 0x45, name: 'job-uri', value: 'ipp://watson.local.:3000/1' },
{ tag: 0x42, name: 'job-name', value: 'My Document Title' },
{ tag: 0x42, name: 'job-originating-user-name', value: 'watson' },
{ tag: 0x44, name: 'job-state-reasons', value: 'none' },
{ tag: 0x21, name: 'time-at-creation', value: 40 },
{ tag: 0x47, name: 'attributes-charset', value: 'utf-8' },
{ tag: 0x48, name: 'attributes-natural-language', value: 'en-us' }
]
See the ipp-encoder for an explanation of the job states and tag values.
Event: request
function (request) {}
Emitted each time a new IPP request is received. This event is more low level than the job event as it will be emitted on all incoming IPP operations.
This module currently supports the minimum set of operations required by the IPP standard:
- print-job (0x02)
- validate-job (0x04)
- cancel-job (0x08)
- get-job-attribtes (0x09)
- get-jobs (0x0a)
- get-printer-attributes (0x0b)
The request
object is a readable stream of the IPP data field. The
print-job operation is currently the only operation where the request
stream contains any data.
The request
object have the following properties supplied by the
printer client:
version
- An object containing the major and minor IPP version of the request (e.g.{ major: 1, minor: 1 }
)operationId
- The id of the IPP operationrequestId
- The id of the IPP requestgroups
- And array of IPP attribute groups
Event: error
function (error) {}
Emitted if the IPP printer encounters an error.
printer.name
The printer name.
printer.port
The port of the printer is listening on.
printer.jobs
An array of all jobs handled by the printer.
printer.server
An instance of http.Server
.
License
MIT