0

I am using Posiflex thermal receipt printer to print retail bills using python.

I tried with following

import os

os.startfile("C:/Users/TestFile.txt", "print")

but whenever I tried printing there is white space trailing the text resulting in wastage of paper. How can I print just raw text eliminating trailing white space?

please find image for clarity. I want to print it like 2nd one but the output is like the 1st one.

1 Answers1

0

Strip the extra space:

one liner for removing blank lines from a file in python?

(.*?)\s*$ will give you capture group 1 as the text stripped of all trailing whitespace. Note: You must use the s (single line) flag to include \n within .

https://regex101.com/r/cgZNHz/2

Community
  • 1
  • 1
TemporalWolf
  • 7,727
  • 1
  • 30
  • 50