4

I am currently developing an application in Python that will run on Macs and will need to print PDF files. In the past I have managed to send PDF files to printer automatically by using some commands in a Bash script. However, I never found a way to specify one printer, it would always send it right into the currently selected printer (usually the last used one).

Does anyone know if there any way to launch the Preview application from command line, or any other way to preview and choose printers before actually printing?

  • How (with which commands) did you send files directly to the printer? – nohillside Mar 14 '17 at 9:34
  • 1
    In my Bash script, I use for instance pdfsplit $FILENAME 3 |lpr to print page 3 of a PDF file coming from the previous action. I can also specify more pages, adding their numbers with a space between each of them. – Victor Domingos Mar 14 '17 at 10:58
  • 1
    Please don't cross-post (stackoverflow.com/questions/42781944/…), it just leads to duplicated effort – nohillside Mar 15 '17 at 8:59
  • I understand the point and I surely respect it, but isn't it the fact that it can be more likely to find a solution if the question is posed to two potentially different groups of people? Which in turn ends up with benefit for all. In this case, there is a Python side, which may be answered by Python focused people, and there is a Mac specific issue that may be better understood by those who know well macOS X, but may or may not be knowledgeable in Python, after all. – Victor Domingos Mar 15 '17 at 9:32
  • 1
    It's usually better to post in one place only and, if you don't get answers, have it migrated to other matching sites. The python answer you got basically wraps the standard Unix commands for printer interaction into a user-friendly UI. – nohillside Mar 15 '17 at 9:53
3
  • lpstat shows all printers known to the system
  • lpr -P NAME prints to printer NAME
  • Ok, that is a progress. I could try to get the available printers and then let the user choose among them, or set it once when installing the application. – Victor Domingos Mar 14 '17 at 12:12
  • 1
    Just want to add that another user has come up with a full working Python code for this: stackoverflow.com/a/42786187/6167478 – Victor Domingos Mar 15 '17 at 8:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .