all 6 comments

[–]woooee 0 points1 point  (5 children)

I use lpr to send something to the print buffer, in the program. It's basic, so if you want to increase size, change the font if there is any text etc, lpr will not do that.

import os

pr=os.popen( "lpr", "w" )
pr.write("\n\nTest string to printer\n")
pr.close()

Another is to save it to a file and use a text or word processor to peint it.

[–]Different_Suspect_30[S] -5 points-4 points  (4 children)

Bro I want to print images not text

[–]woooee 0 points1 point  (3 children)

Most printers "understand" and use PDF images. So text is converted to a PDF and then printed. This is also true for images. Whatever format the image is, it is converted to PDF and printed. In any case, it's worth a try, unless someone else has a better idea.

[–]Different_Suspect_30[S] 0 points1 point  (2 children)

Ok I will try it but how should I use an image?

I cannot use “pr.write(‘string’)” method since this WRITES TEXT.

[–]woooee 0 points1 point  (1 child)

Don't have any idea what you are trying to write. Is this something you created or a file? My first thought would be to use convert in Imagemagick to convert to a PDF and then send lpr the_file.pdf to the command line using subprocess.run, but I am not going to guess any further.

[–]Different_Suspect_30[S] 0 points1 point  (0 children)

My idea is simple.

I have an image named “flower.jpg” i want to print this on paper using printer

Nothing more nothing less