diff --git a/doc/user/methods.rst b/doc/user/methods.rst index 976bde6..10f4fb8 100644 --- a/doc/user/methods.rst +++ b/doc/user/methods.rst @@ -65,8 +65,8 @@ text("text") Prints raw text. Raises ``TextError`` exception. -set("align", "font", "type", width, height) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +set("align", "font", "type", width, height, invert) +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Set text properties. * ``align`` set horizontal position for text, the possible values are: @@ -79,6 +79,7 @@ Set text properties. * ``type`` type could be ``B`` (Bold), ``U`` (Underline) or ``normal``. *Default:* normal * ``width`` is a numeric value, 1 is for regular size, and 2 is twice the standard size. *Default*: 1 * ``height`` is a numeric value, 1 is for regular size and 2 is twice the standard size. *Default*: 1 +* ``invert`` is a boolean value, True enables white on black printing. *Default*: False cut("mode") ^^^^^^^^^^^ diff --git a/escpos/constants.py b/escpos/constants.py index c7e5309..59a8853 100644 --- a/escpos/constants.py +++ b/escpos/constants.py @@ -64,6 +64,8 @@ TXT_FONT_B = ESC + '\x4d\x01' # Font type B TXT_ALIGN_LT = ESC + '\x61\x00' # Left justification TXT_ALIGN_CT = ESC + '\x61\x01' # Centering TXT_ALIGN_RT = ESC + '\x61\x02' # Right justification +TXT_INVERT_ON = GS + '\x42\x01' # Inverse Printing ON +TXT_INVERT_OFF = GS + '\x42\x00' # Inverse Printing OFF # Char code table CHARCODE_PC437 = ESC + '\x74\x00' # USA: Standard Europe diff --git a/escpos/escpos.py b/escpos/escpos.py index b8b8342..21eb452 100644 --- a/escpos/escpos.py +++ b/escpos/escpos.py @@ -451,7 +451,7 @@ class Escpos(object): colCount = self.columns if columns is None else columns self.text(textwrap.fill(txt, colCount)) - def set(self, align='left', font='a', text_type='normal', width=1, height=1, density=9): + def set(self, align='left', font='a', text_type='normal', width=1, height=1, density=9, invert=False): """ Set text properties by sending them to the printer :param align: horizontal position for text, possible values are: @@ -476,6 +476,8 @@ class Escpos(object): :param width: text width, normal (1) or double width (2), *default*: 1 :param height: text height, normal (1) or double height (2), *default*: 1 :param density: print density, value from 0-8, if something else is supplied the density remains unchanged + :param invert: True enables white on black printing, *default*: False + :type invert: bool """ # Width if height == 2 and width == 2: @@ -541,6 +543,11 @@ class Escpos(object): self._raw(PD_P50) else: # DEFAULT: DOES NOTHING pass + # Invert Printing + if invert: + self._raw(TXT_INVERT_ON) + else: + self._raw(TXT_INVERT_OFF) def cut(self, mode=''): """ Cut paper.