You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fromPILimportImagefromescpos_thermalimportPillowEscposImage, DitherMode# Convert any image to printer-ready monochromepil_image=Image.open("photo.jpg")
mono=PillowEscposImage.to_monochrome(pil_image, dither=DitherMode.FLOYDSTEINBERG)
mono.save("preview.png") # Preview what will print
Printer Status
withPrinter(connector) asprinter:
# Check printer statusifprinter.is_online():
print("Printer is online")
ifprinter.has_paper():
print("Paper is loaded")
else:
print("Paper is low or out!")
ifprinter.has_error():
print("Printer has an error")
Cash Drawer
withPrinter(connector) asprinter:
# Open cash drawerprinter.pulse() # Pin 0, default timingprinter.pulse(pin=1, on_ms=200, off_ms=400) # Pin 1, custom timing# Check drawer status (requires compatible hardware)ifprinter.is_drawer_open():
print("Drawer is open!")
Logging
importlogging# Enable debug logginglogging.basicConfig(level=logging.DEBUG)
logger=logging.getLogger('escpos')
logger.setLevel(logging.DEBUG)
# Now printer operations will log debug infowithPrinter(connector) asprinter:
printer.text("Debug logging enabled\n")
Printer Profiles
fromescpos_thermalimportPrinter, CapabilityProfilefromescpos_thermal.connectorsimportNetworkConnector# List available profilesprofiles=CapabilityProfile.get_profile_names()
print(profiles)
# Use a specific profileprofile=CapabilityProfile.load("TM-T88IV")
withPrinter(NetworkConnector("192.168.1.100"), profile) asprinter:
printer.text("Using TM-T88IV profile\n")