Git Product home page Git Product logo

thermalprinter's Introduction

DP-EH600 thermal printer

https://travis-ci.org/BoboTiG/thermalprinter.svg?branch=master

Python module to manage the DP-EH600 thermal printer (the one sold by AdaFruit).

Installation

As simple as:

python -m pip install -U thermalprinter

Usage

An example is better than thousand words:

from PIL import Image
from ThermalPrinter import *

with ThermalPrinter(port='/dev/ttyAMA0') as printer:
    # Picture
    printer.image(Image.open('gnu.png'))

    # Bar codes
    printer.barcode_height(80)
    printer.barcode_position(BarCodePosition.BELOW)
    printer.barcode_width(3)
    printer.barcode('012345678901', BarCode.EAN13)

    # Styles
    printer.out('Bold', bold=True)
    printer.out('Double height', double_height=True)
    printer.out('Double width', double_width=True)
    printer.out('Inverse', inverse=True)
    printer.out('Rotate 90°', rotate=True, codepage=CodePage.ISO_8859_1)
    printer.out('Strike', strike=True)
    printer.out('Underline', underline=1)
    printer.out('Upside down', upside_down=True)

    # Chinese (almost all alphabets exist)
    printer.out('现代汉语通用字表', chinese=True,
                chinese_format=Chinese.UTF_8)

    # Greek (excepted the ΐ character)
    printer.out('Στην υγειά μας!', codepage=CodePage.CP737)

    # Other characters
    printer.out(b'Cards \xe8 \xe9 \xea \xeb', codepage=CodePage.CP932)

    # Accents
    printer.out('Voilà !', justify='C', strike=True,
                underline=2, codepage=CodePage.ISO_8859_1)

    # Line feeds
    printer.feed(2)

thermalprinter's People

Contributors

akokkalas avatar bobotig avatar d21d3q avatar phillipthelen avatar uniphil avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

thermalprinter's Issues

[doc] Generate codepage tables

We should have a complete list of printable characters by codepage (with associated hexadecimal code to use) somewhere on the documentation. It would ease the use for everyone :)

Letter 'P' being printed every time before anything else

As in the title, every time I'm trying to print something, a new line with the letter 'P' is added.

I tried the sample code from README > Usage and got this as a result:

IMG_2207

And later I tried to print only new lines with this code...

from PIL import Image
from thermalprinter import *

with ThermalPrinter(port='/dev/serial0',baudrate=9600) as printer:
    printer.feed(5)

... with this as a result:

IMG_2206

Any idea what might be causing it?

Printing corrupted images

Greetings! Thank you for this awesome library!

I've been wondering for a while the reason why I occasionally get corrupted images (missing rows, or rows not aligned correctly). Sometimes the image printing gets halted and the printer starts spewing out random characters.

I looked into your code and noticed that the image printing script sleeps for a short amount of time for each chunk's row. This is dependant on the printer's baudrate.

See https://github.com/BoboTiG/thermalprinter/blob/master/thermalprinter/thermalprinter.py#L418 and
https://github.com/BoboTiG/thermalprinter/blob/master/thermalprinter/thermalprinter.py#L53

I managed to get my images working by setting a hardcoded self._byte_Time 0.0005 (which is somewhat close to the default timing) rather than depending on the low sleep time set by my higher baudrate 115200.

Just to let you know! Thanks again!

[WIP] Features advancement

List a missing features to implement (I do not think all are required). The description of every feature is taken from the command list of the manual.

Developer's guide.

If you want to discuss about a feature, open a new issue.

⚠️ Do not reference this issue in your commits message.

The print command

  • Print and wrap
  • Print and press enter
  • Jump to the next position TAB
  • Set the horizontal coordinates
  • Print buffer data and paper n point
  • Peripherical equipment

Formatting commands

  • Set the default row spacing of 32 points
  • Set the left blank posints
  • Set absolute print position

Character set

  • Setting / canceling custom user
  • User defined character
  • The abolition of user defined characters

Status command

  • Real time state
  • Enable / disable automatic upload status

Graphics settings command

  • Bitmap mode definition
  • Printing transmission bitmap
  • Print raster bitmap
  • Print NV bitmap
  • The definition of NV bitmap

The auxiliary function command

  • Set the control parameters of the command
  • Cancal / activation panel buttons (only for key)

✔️ List of implemented features.

The print command

  • Print buffer data and paper n (feed)

Formatting commands

  • Set the line spacing N bit (line_spacing)
  • Set the alignment, alignment left, right, center alignment (justify)
  • Set the double wide mode (double_width)
  • Cancel the double wide mode (double_width)
  • Set the left spacing (left_margin)

Character set

  • Set print format (double_height)
  • Heightening set font widening (size)
  • Cancel / set visual mode (inverse)
  • Setting / canceling 90° rotation mode (rotate)
  • To host trnsfer printer status (status)
  • Cancel / set overlapping mode (strike)
  • Setting / canceling bold font (bold)
  • Set the right character spacing (char_spacing)
  • Set / character upside down to cancel (upside_down)
  • Set underline the point height (underline)
  • Selection of Chinese mode (chinese)
  • Cancel Chinese mode (chinese)
  • Set the print mode for Chinese characters (chinese_format)
  • The choice of international character set (charset)
  • Select the character code table (codepage)

Initialization commands

  • Init printer (__init__)

Graphics settings command

  • Select the bitmap mode (image)

Barcode setup command

  • Select the HRI print mode (barcode_position)
  • Set the bar code height (barcode_height)
  • Set the bar code width (barcode_width)
  • Barcode printing (barcode)
  • Set the bar code printed of the left spacing (barcode_left_margin)

The auxiliary function command

  • Sleep parameters (sleep and wake)
  • Selection of Chinese code format (chinese_format)
  • Self testing page print (test)

Printing characters from CodePage.CP437

Hi! Probably a simple question, but can someone post an example of printing specific characters from CP437? Namely characters like the diamond (♦), heart (♥), etc? Do they have to be sent as bytes? Thanks!

Images are not being printed correctly

I tried to print example code from README > Usage and got text and barcode being printed properly:

IMG_2209

But when I try to print any image I'm just getting bunch of random characters. I made sure that the image has correct size and that the baud rate is also correct.

IMG_2210

I also tried to hardcode self._byte_Time as sugested in #9

I managed to get my images working by setting a hardcoded self._byte_Time 0.0005 (which is somewhat close to the default timing) rather than depending on the low sleep time set by my higher baudrate 115200.

but it didn't work in my case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.