Skip to content

banterability/little-print

Repository files navigation

little-print

Latest Version

A dependency-free wrapper for Nord Projects' Device Keys API for Little Printer.

Usage

Instantiate a LittlePrint class:

import LittlePrint from "little-print";

const printer = new LittlePrint({
  deviceKey: "abcd1234", // required
  appName: "README", // optional
});

Your deviceKey is everything following device.li/ on Nord Projects' Device Keys website.

printHTML(html: String)

Prints a provided HTML document.

Input

await printer.printHTML(`
  <em>*slaps roof of printer*</em>
  <h1>You can fit</h1>
  <ul>
    <li>so</li>
    <li>much</li>
    <li>markup</li>
  </ul>
  <h2>in this bad boy!</h2>
`);
// returns {statusCode, headers, body}, if you care

Output

output of printHTML example

printImage(path: Path)

Prints a GIF, JPEG, or PNG image.

Input

await printer.printImage("./first_time.jpg");
// returns {statusCode, headers, body}

Output

output of printImage example

printText(text: String)

Prints a provided string.

Input

await printer.printText(
  `The story begins in any of the three dozen taquerias supplying the Bay Area Feeder Network, an expansive spiderweb of tubes running through San Francisco's Mission district as far south as the "Burrito Bordeaux" region of Palo Alto and Mountain View.`,
);
// returns {statusCode, headers, body}

Output

output of printText example