mirror of
				https://github.com/python-escpos/python-escpos
				synced 2025-10-23 09:30:00 +00:00 
			
		
		
		
	Support changing the line spacing.
This commit is contained in:
		@@ -565,6 +565,29 @@ class Escpos(object):
 | 
			
		||||
        else:
 | 
			
		||||
            self._raw(TXT_INVERT_OFF)
 | 
			
		||||
 | 
			
		||||
    def line_spacing(self, spacing=30, divisor=180):
 | 
			
		||||
        """ Set line character spacing.
 | 
			
		||||
 | 
			
		||||
        There are different commands for setting the line spacing, using
 | 
			
		||||
        a different denominator:
 | 
			
		||||
 | 
			
		||||
        + line_spacing/360 of an inch, 0 <= line_spacing <= 255
 | 
			
		||||
        3 line_spacing/180 of an inch, 0 <= line_spacing <= 255
 | 
			
		||||
        A line_spacing/60 of an inch, 0 <= line_spacing <= 85
 | 
			
		||||
 | 
			
		||||
        Some printers may not support all of them. The most commonly
 | 
			
		||||
        available command (using a divisor of 180) is chosen.
 | 
			
		||||
        """
 | 
			
		||||
        if divisor not in LINESPACING_FUNCS:
 | 
			
		||||
            raise ValueError("divisor must be either 360, 180 or 60")
 | 
			
		||||
        if (divisor in [360, 180] \
 | 
			
		||||
                and (not(0 <= spacing <= 255))):
 | 
			
		||||
            raise ValueError("spacing must be a int between 0 and 255 when divisor is 360 or 180")
 | 
			
		||||
        if divisor == 60 and (not(0 <= spacing <= 85)):
 | 
			
		||||
            raise ValueError("spacing must be a int between 0 and 85 when divisor is 60")
 | 
			
		||||
 | 
			
		||||
        self._raw(LINESPACING_FUNCS[divisor] + six.int2byte(spacing))
 | 
			
		||||
 | 
			
		||||
    def cut(self, mode=''):
 | 
			
		||||
        """ Cut paper.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user