From 86ae7758816eec4ed48081774d4ff721e06c7712 Mon Sep 17 00:00:00 2001 From: belono Date: Sun, 24 Sep 2023 13:37:45 +0200 Subject: [PATCH] Fix LP waste of paper due to auto-flush + flush on close --- src/escpos/printer/file.py | 3 ++- src/escpos/printer/lp.py | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/escpos/printer/file.py b/src/escpos/printer/file.py index 77e9205..a8933ce 100644 --- a/src/escpos/printer/file.py +++ b/src/escpos/printer/file.py @@ -99,6 +99,7 @@ class File(Escpos): if not self._device: return logging.info("Closing File connection to printer %s", self.devfile) - self.device.flush() + if not self.auto_flush: + self.flush() self.device.close() self._device = False diff --git a/src/escpos/printer/lp.py b/src/escpos/printer/lp.py index 4c924b8..e0824e4 100644 --- a/src/escpos/printer/lp.py +++ b/src/escpos/printer/lp.py @@ -67,11 +67,11 @@ class LP(Escpos): :param printer_name: CUPS printer name (Optional) :param auto_flush: Automatic flush after every _raw() (Optional) - :type auto_flush: bool + :type auto_flush: bool (Defaults False) """ Escpos.__init__(self, *args, **kwargs) self.printer_name = printer_name - self.auto_flush = kwargs.get("auto_flush", True) + self.auto_flush = kwargs.get("auto_flush", False) @property def printers(self) -> dict: @@ -150,6 +150,8 @@ class LP(Escpos): if not self._device: return logging.info("Closing LP connection to printer %s", self.printer_name) + if not self.auto_flush: + self.flush() self.device.terminate() self._device = False