npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ipp-picture

v0.1.0

Published

Printing Service for easy printing of JPEG pictures to IPP, IPP Everywhere and most AirPrint printers.

Downloads

11

Readme

Printing Service npm

This is a printing service class serving following functions

  • Discover IPP Printers in the local network
  • Get Printer via IPP Protocols
  • Get Printer's Supported Job Attributes
  • Send and Print JPEG
  • Check Print Job (with Job ID)

Installing Printing Service

npm install --save c15yo-printing
// Using require()
const Printer = require('c15yo-printing')

Library usage

Create an instance of the Printer class.

// ES2015 modules
const Printer = require('c15yo-printing')
const printer = new Printer();

By initializing an instance of Printer, a mDNS discovery service will start searching and detects updates from the network.

Printer Discovery

Since printer discovery service is started since Printer instance is created. This feature queries the list of printer and returns necessary information.

getPrinters()

Return Value

{
    // Printer
    "10.0.0.254": {
        "status": "OK", // Printer query status, "OK" or "ERROR"
        "mdns": [MDNS Object], // mDNS query result in Object format
        "printer": [IPPPrinter Object], // If status is "OK", this object will be populated. Printer full attributes information in Object format
        "error": [Error] // If status is "ERROR", this object will be populated.
    },
    ... // More printers
}
MDNS Object

mDNS Object from local network discovery

{
    "addresses": [Array(String)], // Array of address
    "query": [Array(String)], // Array of MDNS queries
    "type": [Array(Object)], // Array of MDNS responses and supported protocols
    ... // Unnecessary items
}
IPP Printer Object

IPP Printer Object

{
    "version": "2.0", // IPP Protocol Version
    "statusCode": "successful-ok", // IPP Query status
    "id": 24255051, // IPP Query ID
    "operation-attributes-tag": [Object], // Printer operational configuration tags
    "printer-attributes-tag": [Object], // Printer operational attributes
}

Example

var printers = printer.getPrinters()

getPrinter(ip)

Argument: ip

Type: string

IP Address of the printer. This ip address must be from discovered printer list or null will be returned.

Return Value

{
    "status": "OK", // Printer query status, "OK" or "ERROR"
    "mdns": [MDNS Object], // mDNS query result in Object format
    "printer": [IPPPrinter Object], // If status is "OK", this object will be populated. Printer full attributes information in Object format
    "error": [Error] // If status is "ERROR", this object will be populated.
}

getPrinterAttributes(ip, callback)

Argument: ip

Type: string

IP Address of the printer.

Argument: callback

Type: function(error, result)

Arguments: error: If no error occured, this object will be undefined. Otherwise, an Error object will be returned. result: If no error occured, this object will be populated with an IPP Printer Object

Printer Operation

printJPEG(ip, buffer, meta, callback)

Send a JPEG print job to the printer

Argument: ip

Type: string

IP Address of the printer.

Argument: buffer

Type: JavaScript Buffer <buffer> | String

JPEG Buffer. e.g. fs.readFileSync('something.jpg')

Argument: meta

Type: Object

Example
{
    "job-attributes-tag": [Object], // Print job attributes. e.g. Copies, Quality, etc.
}

Argument: callback

Type: function(error, result)

Arguments: error: If no error occured, this object will be undefined. Otherwise, an Error object will be returned. result:

{
    "status": "OK", // "OK" or "ERROR"
    "data": [Object] | String, // If status is "OK", an IPP Job Object will be populated here. 
                                // If there is an error, this field will be an error message.
    "job": String // If status is "OK", a base64 encoded print job uri will be populated here.
}

getJobAttributes(ip, uri, callback)

Get processing, completed or cancelled print job details by the job id.

Argument: ip

Type: string

IP Address of the printer.

Argument: uri

Type: string

Job URI. (By decoding the base64 job id. see printJPEG=>callback.

Argument: callback

Type: function(error, result)

Arguments: error: If no error occured, this object will be undefined. Otherwise, an Error object will be returned. result:

{
    "status": "OK", // "OK" or "ERROR"
    "job": [Object] // If status is "OK", job object will be populated here.
}