etiquette

package module
v0.0.0-...-797c769 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 7 Imported by: 0

README

Etiquette

Print labels on a Brother P-touch P700 printer from the command line, without any special drivers.

echo "Label" | etiquette /dev/usb/lpN

Features

  • Print a list of newline delimited labels from stdin as one job, only wasting the ~25mm of feed tape once per job:

    echo -e "Label 1\nLabel 2" | etiquette /dev/usb/lpN
    

    (Make sure to remove labels as they feed out, otherwise small ones can pile up and slow down the printer, offsetting the text on the next labels.)

  • Detect tape size loaded into printer, and automatically pick corresponding font size.

  • Print pre-rendered images, for example QR codes:

    qrencode --symversion=3 --strict-version --size 4 --margin 1 -o- "http://go.afab.re/etiquette" | etiquette -img /dev/usb/lpN
    
  • Preview the output as a PNG:

    echo "Label" | ./etiquette -preview label.png /dev/usb/lpN
    

Requirements

  • Linux usblp driver.
  • Printer should show up as /dev/usb/lpN.
  • Permission to access /dev/usb/lpN. Typically add yourself to the lp group:
    • sudo usermod -aG lp $USER; newgrp lp

Install

With a working Go installation:

go install go.afab.re/etiquette/cmd/etiquette@latest

Alternatives

  • ptouch-print

    • Doesn't support printing and cutting multiple labels at a time.
    • Font size varies based on text: labels with descenders (eg g) will use a smaller font than those without.
  • B-Label

    • Doesn't support printing multiple labels at a time.
    • Doesn't output anything with the P700 printer.
  • ptouch-driver

    • CUPS driver.

    • Need to manually specify label length, defaults to 100mm. Eg:

      lp -d PT-P700 -o PageSize=Custom.17x70 -o landscape
      
    • Supports printing and cutting multiple labels at a time.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Image

func Image(b Bounds, img image.Image) (*monochrome.Image, error)

Image converts an image to one suitable for printing: - Monochrome. - Padded out to bounds.

func Text

func Text(b Bounds, text string, opts TextOpts) (*monochrome.Image, error)

Text renders text as an image suitable for printing.

Types

type Bounds

type Bounds struct {
	// Dx is the exact width the image must be, in pixels.
	Dx int
	// Dy is the minimum height of the image, in pixels.
	MinDy int
}

type TextOpts

type TextOpts struct {
	DPI  int
	Font *opentype.Font
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL