README

Thu, 24 Sep 2009 22:29:12 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Thu, 24 Sep 2009 22:29:12 +0100
changeset 20
f8ca98e5f586
parent 18
fd1c6f6066da
permissions
-rw-r--r--

remove accidentally-included debug code (oops!)

philpem@17 1 libptouch: Linux printer driver library for P-Touch label printers
philpem@17 2 (C) 2009 Philip Pemberton <philpem@philpem.me.uk>.
philpem@17 3
philpem@17 4
philpem@17 5
philpem@17 6 Table of Contents
philpem@17 7 =================
philpem@17 8 1. What is libptouch?
philpem@17 9 2. Supported printers
philpem@18 10 3. Building and Installing libptouch
philpem@17 11 T. TODO, aka Things That Don't Work Yet.
philpem@17 12 R. References
philpem@17 13
philpem@17 14
philpem@17 15 1. What is libptouch?
philpem@17 16 =====================
philpem@17 17 libptouch is a library that allows a user-mode application to print labels
philpem@17 18 using a Brother P-touch series label printer. The goal of the libptouch
philpem@17 19 project is to create a driver that will allow any Linux application to
philpem@17 20 print to a P-touch printer, using a common raster image as a source.
philpem@17 21
philpem@17 22 Brother only release official Linux drivers for a small number of P-touch
philpem@17 23 printers, and these all rely on the CUPS printing system to function (not to
philpem@17 24 mention the fact that the print filter is completely closed-source). On top
philpem@17 25 of the added complexity of having to feed data through CUPS or LPR, the print
philpem@17 26 quality was actually pretty poor -- the fonts were covered in jagged edges,
philpem@17 27 and printed barcodes looked like they'd been fed through a blender (needless
philpem@17 28 to say my PSC 5281 scanner wouldn't read them).
philpem@17 29
philpem@17 30 As a result of this, I started working on a library that could take a number
philpem@17 31 of Libgd images, and feed them to the P-touch in sequence. On top of that, I
philpem@17 32 wanted to be able to set printing parameters (that is, turn the auto-cutter
philpem@17 33 and mirroring options on and off) without having to butcher command lines
philpem@17 34 and drop to a shell. Finally, I wanted to be able to run my applications as a
philpem@17 35 (relatively) unprivileged user -- the printing apps should not need to be
philpem@17 36 'setuid root'.
philpem@17 37
philpem@17 38 So I set to work finding out all I could about the P-touch protocol. It turns
philpem@17 39 out that the standard mode for my PT-2450DX printer was the so-called "PT-CBP"
philpem@17 40 mode, and that documentation for this printing protocol had been released for
philpem@17 41 another printer in the P-touch series, the PT-9500PC[1]. Using the protocol
philpem@17 42 details in the PT-9500PC documentation, and after many long nights of coding,
philpem@17 43 lots of cups of tea and much wasted label tape, I created a library that would
philpem@17 44 eventually be released as libptouch.
philpem@17 45
philpem@17 46
philpem@17 47 2. Supported printers
philpem@17 48 =====================
philpem@17 49
philpem@17 50 NOTE: If you don't see your printer on this list, ask me about adding it.
philpem@17 51
philpem@17 52 +--------------+--------------------------------------------------------------+
philpem@17 53 | Printer | Features |
philpem@17 54 | Model +----+----+----------------------------------------------------+
philpem@17 55 | Number | S | AC | HC | PHW | DPI | MTH | MPH | |
philpem@17 56 +--------------+----+----+----+-----+-----+------+------+---------------------+
philpem@17 57 | PT-2450DX | Y | Y | | 128 | 180 | 24mm | 18mm | |
philpem@17 58 +--------------+----+----+----+-----+-----+-----------------------------------+
philpem@17 59
philpem@17 60 S = Supported/Tested
philpem@17 61 Y = Fully working
philpem@17 62 P = Partially working
philpem@17 63 ? = Not tested
philpem@17 64 AC = Auto Cutter
philpem@17 65 HC = Half Cut
philpem@17 66 MI = Mirror
philpem@17 67 PHW = Printhead width (pixels)
philpem@17 68 DPI = Dots per inch
philpem@17 69 MTH = Max label tape height (mm)
philpem@17 70 MPH = Max printing height (mm)
philpem@17 71
philpem@17 72 "Y" = Yes
philpem@17 73 " " = No
philpem@17 74
philpem@17 75
philpem@18 76 3. Building and Installing libptouch
philpem@18 77 ====================================
philpem@17 78 To build libptouch, you will need:
philpem@17 79 GNU gcc version 3.1 or later (libptouch is tested with gcc 4.3.3)
philpem@17 80 GNU make version 3.80 or later (libptouch is tested with make 3.81)
philpem@18 81 libgd version 2.0 or later (libptouch is tested with libgd 2.0.36)
philpem@18 82
philpem@18 83 To build the documentation, you will also need:
philpem@18 84 doxygen version 1.5 or later (libptouch is tested with doxygen 1.5.8)
philpem@17 85
philpem@17 86 Briefly, this means any common Linux distribution (Debian or RedHat based)
philpem@17 87 released in 2006 or later should successfully build libptouch. As for other
philpem@17 88 Unices, or older versions of Linux.... you're on your own.
philpem@17 89
philpem@17 90 On Ubuntu or Debian, the following command will install all the packages
philpem@17 91 necessary to build libptouch:
philpem@17 92 $ sudo apt-get install build-essential libgd2-xpm-dev
philpem@17 93
philpem@17 94 Once you have installed the necessary tools and libraries, you can compile
philpem@17 95 libptouch by using the following command:
philpem@17 96 $ tar -zxf libptouch-$VERSION.tgz
philpem@17 97 $ cd libptouch-$VERSION
philpem@17 98 $ make
philpem@17 99
philpem@17 100 This will build the libptouch library and documentation from the source code.
philpem@17 101
philpem@18 102 To install libptouch into /usr/local, type:
philpem@18 103 $ make install
philpem@18 104
philpem@18 105 To install libptouch into another directory, say /opt/libptouch, type:
philpem@18 106 $ make install PREFIX=/opt/libptouch
philpem@18 107
philpem@18 108
philpem@18 109 4. Using libptouch
philpem@18 110 ==================
philpem@18 111 [... TODO ...]
philpem@18 112
philpem@18 113
philpem@18 114 5. Using libptouch-based Applications Without Superuser Privileges
philpem@18 115 ==================================================================
philpem@18 116 To use a libptouch-based application without superuser (root) privileges, you
philpem@18 117 must do one of two things:
philpem@18 118
philpem@18 119 1. Set the application's group ID to the user that normally owns printers
philpem@18 120 (or serial ports) on your system, then chmod the application to "g+S"
philpem@18 121 (turn the Set Group ID bit on). This will only work if all your printers
philpem@18 122 use the same interface type, e.g. all serial or all USB.
philpem@18 123
philpem@18 124 2. Add the user who will be running the application to the 'lp' or 'dialout'
philpem@18 125 group (for USB or serial printers respectively). Note that a user can be
philpem@18 126 a member of more than one group -- see your system documentation for more
philpem@18 127 information.
philpem@18 128
philpem@17 129
philpem@17 130 T. TODO, aka Things That Don't Work Yet.
philpem@17 131 ========================================
philpem@17 132 * Printers with printheads that don't have 128 dots will not work. This
philpem@17 133 basically means you can't use any printer whose maximum label tape width
philpem@17 134 is less than 24mm.
philpem@17 135
philpem@17 136 * I'd like to implement graphics inversion. Basically, where there is white,
philpem@17 137 the printer will print black. This could be useful for printing
philpem@17 138 white-on-black labels when you're out of white-on-black tape, or vice versa
philpem@17 139 :)
philpem@17 140
philpem@17 141 * There is no support for serial port printers. At all.
philpem@17 142
philpem@17 143 * The PT-PC is not, and will likely never be supported, as it uses a
philpem@17 144 different printing protocol and can only print bit image graphics on the
philpem@17 145 central 3.5mm (!) of the label tape.
philpem@17 146
philpem@17 147 * The QL-series label printers aren't supported either. I'd love to add
philpem@17 148 support for them, but I don't have a QL-series printer to play with. The
philpem@17 149 same applies to the rest of the P-touch (PT-series) printers that aren't
philpem@17 150 listed as "Supported" in the list above.
philpem@17 151
philpem@17 152 * Data compression. The later PT-series printers support "Packbits"
philpem@17 153 compression of each print line. At the moment, this isn't implemented.
philpem@17 154 Instead, a "COPY N BYTES" compression control byte is sent, followed by
philpem@17 155 a line of print data. Rinse, repeat.
philpem@17 156
philpem@17 157 * No option to set the feed amount. I'm not even 100% sure if this works
philpem@17 158 on most PT-series printers, but it might be worth implementing. See
philpem@17 159 <http://www.undocprint.org/formats/page_description_languages/brother_p-touch>.
philpem@17 160
philpem@17 161
philpem@17 162 R. References
philpem@17 163 =============
philpem@17 164 1. Brother Industries, Ltd. "PT-9500PC Command Reference, CBP-RASTER Mode
philpem@17 165 (PTCBP Mode) Volume" August 29, 2003, version 1.0.
philpem@17 166 Available online: http://etc.nkadesign.com/Printers/QL550LabelPrinter
philpem@17 167