changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
SIZE 76 mm,95 mm
|
SIZE 76 mm,101 mm
|
||||||
GAP 2 mm,0
|
GAP 4 mm,0
|
||||||
DIRECTION 1
|
DIRECTION 1
|
||||||
DENSITY 8
|
DENSITY 8
|
||||||
CLS
|
CLS
|
||||||
|
|||||||
10
print/test.txt
Normal file
10
print/test.txt
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
SIZE 76 mm,101 mm
|
||||||
|
GAP 4 mm,0
|
||||||
|
DIRECTION 1
|
||||||
|
DENSITY 8
|
||||||
|
CLS
|
||||||
|
QRCODE 10,10,H,4,A,0, "ABCabc123"
|
||||||
|
QRCODE 160,160,H,4,A,0, "123ABCabc"
|
||||||
|
QRCODE 310,310,M,4,A,0,M2, "印表機 ABCabc123"
|
||||||
|
PRINT 1,1
|
||||||
|
CUT
|
||||||
32
print/tspl_repl.py
Normal file
32
print/tspl_repl.py
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import win32print
|
||||||
|
|
||||||
|
PRINTER_NAME = "Xprinter XP-350BM"
|
||||||
|
|
||||||
|
def send(tspl_text):
|
||||||
|
h = win32print.OpenPrinter(PRINTER_NAME)
|
||||||
|
try:
|
||||||
|
win32print.StartDocPrinter(h, 1, ("TSPL REPL", None, "RAW"))
|
||||||
|
win32print.StartPagePrinter(h)
|
||||||
|
win32print.WritePrinter(h, tspl_text.encode('utf-8'))
|
||||||
|
win32print.EndPagePrinter(h)
|
||||||
|
win32print.EndDocPrinter(h)
|
||||||
|
finally:
|
||||||
|
win32print.ClosePrinter(h)
|
||||||
|
|
||||||
|
print(f"TSPL REPL — sending to: {PRINTER_NAME}")
|
||||||
|
print("Type TSPL commands one per line. Type 'PRINT 1,1' to trigger print.")
|
||||||
|
print("Type 'exit' to quit.\n")
|
||||||
|
|
||||||
|
buffer = []
|
||||||
|
|
||||||
|
while True:
|
||||||
|
line = input("tspl> ").strip()
|
||||||
|
if line.lower() == "exit":
|
||||||
|
break
|
||||||
|
buffer.append(line)
|
||||||
|
# Auto-send whenever a PRINT command is entered
|
||||||
|
if line.upper().startswith("PRINT"):
|
||||||
|
full_command = "\n".join(buffer) + "\n"
|
||||||
|
send(full_command)
|
||||||
|
print(">> Sent to printer.\n")
|
||||||
|
buffer = []
|
||||||
Reference in New Issue
Block a user