[Tutor] Printing from python

Lee Harr missive at hotmail.com
Sat Mar 22 03:07:08 CET 2014


> is there another way to print a PDF form python?
>
> My problem is a PDF which is printed well by evince, but not with lp, 
> even not out of python using
>
> os.system("lp some_options file.pdf")
>
> Later on I have to build the PDF in a python program (using reportlab) 
> and then print it, even from the python program.


I have done this several times before -- generating a pdf with python
using reportlab and then printing the result by handing it to lpr.

(Not sure what exactly is the difference between lp and lpr, but from
   a bit of research, it looks like either one should do the job.)


The first thing you need to do is make sure that you can print
the file from your regular shell (not python) using your chosen
print command.

If that does not work, python is not going to do anything magical.

If you are having trouble with that, it is more of a question for the
mailing list supporting your chosen operating system.


Once you get that working, shelling out from python will be able
to accomplish the same task.

(The one possible gotcha is finding the correct path to the file.
   I think I tended to use full paths to everything to make sure
   that the correct things would be found.) 		 	   		  


More information about the Tutor mailing list