python-escpos icon indicating copy to clipboard operation
python-escpos copied to clipboard

Extend for slip printers

Open patkan opened this issue 8 years ago • 1 comments

taken from #18:

This comment is not directly related to Issue #18:

I am describing a possible extension, which I intend to resubmit later as a new 
issue.

Here is an experiment, for people who have a combination thermal & slip 
printer. The paper type can be selected:

HW_PRINT_ROLL = '\x1B\x63\x30\x03' # 80mm roll, thermal
HW_PRINT_SLIP = '\x1B\x63\x30\x04' # Slip / Cheque, dot matrix

Common settings, like the type face and character geometry, can be set on the 
dot matrix slip printer, the same way as done for the thermal engine.

E.paper('slip')

E.set('left','A','B',1,2)

If anyone tests this, please be mindful of both the logical and physical length 
of your slip. My printer seems not to sense the end of a narrow slip. It is 
okay with an A4 sheet.

PAPER_SLIP_OUT  = '\x1B\x4B\xC0' # Eject slip or cheque

The method I use to eject is a slip-reverse command. It reverses the feed 
direction on a flat paper path TM-H5000II, and feeds a slip out forward on the 
TM-H6000.

E.cut('slip')

Always return to the roll paper type when finished.

E.paper('roll')


% hg diff

diff -r 849dabb63ce0 escpos/constants.py
--- a/escpos/constants.py   Thu May 30 08:56:33 2013 -0700
+++ b/escpos/constants.py   Sat Jan 18 15:14:30 2014 +1100
@@ -10,16 +10,21 @@
 HW_INIT   = '\x1b\x40'         # Clear data in buffer and reset modes
 HW_SELECT = '\x1b\x3d\x01'     # Printer select
 HW_RESET  = '\x1b\x3f\x0a\x00' # Reset printer hardware
+# Printer paper
+HW_PRINT_ROLL = '\x1B\x63\x30\x03' # 80mm roll, thermal
+HW_PRINT_SLIP = '\x1B\x63\x30\x04' # Slip / Cheque, dot matrix
 # Cash Drawer
 CD_KICK_2 = '\x1b\x70\x00'     # Sends a pulse to pin 2 [] 
 CD_KICK_5 = '\x1b\x70\x01'     # Sends a pulse to pin 5 [] 
 # Paper
 PAPER_FULL_CUT  = '\x1d\x56\x00' # Full cut paper
 PAPER_PART_CUT  = '\x1d\x56\x01' # Partial cut paper
+PAPER_SLIP_OUT  = '\x1B\x4B\xC0' # Eject slip or cheque
 # Text format   
 TXT_NORMAL      = '\x1b\x21\x00' # Normal text
 TXT_2HEIGHT     = '\x1b\x21\x10' # Double height text
 TXT_2WIDTH      = '\x1b\x21\x20' # Double width text
+TXT_4SQUARE     = '\x1b\x21\x30' # Quad area text
 TXT_UNDERL_OFF  = '\x1b\x2d\x00' # Underline font OFF
 TXT_UNDERL_ON   = '\x1b\x2d\x01' # Underline font 1-dot ON
 TXT_UNDERL2_ON  = '\x1b\x2d\x02' # Underline font 2-dot ON
diff -r 849dabb63ce0 escpos/escpos.py
--- a/escpos/escpos.py  Thu May 30 08:56:33 2013 -0700
+++ b/escpos/escpos.py  Sat Jan 18 15:14:30 2014 +1100
@@ -189,8 +189,8 @@
             self._raw(TXT_NORMAL)
             self._raw(TXT_2HEIGHT)
         elif height == 2 and width == 2:
-            self._raw(TXT_2WIDTH)
-            self._raw(TXT_2HEIGHT)
+            self._raw(TXT_NORMAL)
+            self._raw(TXT_4SQUARE)
         else: # DEFAULT SIZE: NORMAL
             self._raw(TXT_NORMAL)
         # Type
@@ -203,7 +203,6 @@
         elif type.upper() == "U2":
             self._raw(TXT_BOLD_OFF)
             self._raw(TXT_UNDERL2_ON)
-            self._raw(TXT_ITALIC_OFF)
         elif type.upper() == "BU":
             self._raw(TXT_BOLD_ON)
             self._raw(TXT_UNDERL_ON)
@@ -227,6 +226,15 @@
             self._raw(TXT_ALIGN_LT)


+    def paper(self, type='ROLL'):
+        if type.upper() == '':
+            self._raw(HW_PRINT_ROLL)
+        elif type.upper() == 'ROLL':
+            self._raw(HW_PRINT_ROLL)
+        elif type.upper() == 'SLIP':
+            self._raw(HW_PRINT_SLIP)
+
+
     def cut(self, mode=''):
         """ Cut paper """
         # Fix the size between last line and cut
@@ -234,6 +242,10 @@
         self._raw("\n\n\n\n\n\n")
         if mode.upper() == "PART":
             self._raw(PAPER_PART_CUT)
+        if mode.upper() == "FULL":
+            self._raw(PAPER_FULL_CUT)
+        if mode.upper() == "PART":
+            self._raw(PAPER_SLIP_OUT)
         else: # DEFAULT MODE: FULL CUT
             self._raw(PAPER_FULL_CUT)

patkan avatar Apr 14 '16 21:04 patkan

Any news about this ? I was looking for this feature too. Could this be merged ? Is something missing for it to work ? Thanks

kedare avatar Jul 04 '22 07:07 kedare