4

I have a Peripage A4 continuous paper roll thermal printer, connected via USB-C to a MacBook with 13.3.1. Printing works fine from within all applications and via the commandline using lpr:

$ lorem --faust --lines 20 --randomize | lpr -P "PeriPage_A4" -o orientation-requested=1 prints 20 lines of random (randomized Goethe, in this case) lorem ipsum.

Is there a way I can tell lpr to "not fill an A4 page with nothingness" but rather just print the text, the stop (so that only the lines that contain text are printed), or print "one line at a time" (again, of course, without filling the rest of the page with nothing)? Other than in this example I do not know the amount of text, it varies with each print.

   Have:                   Want:

   ┌──────────────┐        ┌──────────────┐
   │lorem ipsum   │        │lorem ipsum   │
   │sit dolor et  │        │sit dolor et  │
   │eniam unque.  │        │eniam unque.  │
   │              │        └──────────────┘
   │              │               ▲
   │              │               │
   │              │               │
   │              │               │
   │              │               │
   │              │        printing stopped.
   │              │
   │              │
   │              │     lots of blank paper
   │              │           │
   │              │ ◄─────────┘
   │              │
   └──────────────┘

I have tried a Python script, but the printer does not seem to understand ESC/POS stuff:

#!/usr/bin/env python3
import sys
import time
from escpos.printer import Usb

# Configure the printer
printer = Usb(0x09c5, 0x0200, in_ep=0x81, out_ep=0x02)

# Reset the printer
printer.hw('reset')

# Read the input text from stdin
input_text = sys.stdin.read()

# Print the input text
printer.text(input_text)

# Add a small delay
time.sleep(1)

# Cut the paper
#printer.cut()

# Close the printer connection
printer.close()
Christian
  • 1,212
  • 1
  • 15
  • 30
  • Isn't this a better fit for stackoverflow? – Gantendo Apr 25 '23 at 07:28
  • I would agree, yet I have been 'deleted' with a few questions in the past few months that by now I'm afraid to post anything not _purely_ programming. – Christian Apr 25 '23 at 09:20
  • but programming and software development is offtopic here brother bear https://superuser.com/help/on-topic Well, idgaf, i hope it stays up. – Gantendo Apr 25 '23 at 09:21
  • so is the `lpr` from the first Goethe snippet printing as you want or not? – Marcin Orlowski Apr 25 '23 at 09:55
  • I'm going to vote to close as off-topic on Stack Overflow. Although there is a Python script here, it doesn't, and couldn't, affect what features the printer driver supports. – tripleee Apr 25 '23 at 10:02
  • @MarcinOrlowski No. It prints, but fills the rest of the page with white space, see my "drawing". – Christian Apr 26 '23 at 13:28
  • please don't go whinning because of some random downvotes. It's often sufficient to attract just single person to get help, so it's always worth posting, yet you should also try to make question as clear as possible - just for that single one who will come helping. Also your question got more upvotes so, stay calm :) – Marcin Orlowski Apr 26 '23 at 14:01
  • BTW: seems they are so proprietary I failed to find much about them or their drivers. Anyway, I'd also try to mail their support. Won't put you in any worse position – Marcin Orlowski Apr 26 '23 at 14:07
  • 1
    @MarcinOrlowski Thank you for the noble words of support ;) I have already contacted the support, yet so far to no avail. I'll keep this post - posted. – Christian Apr 28 '23 at 11:43

0 Answers0