macoscore-graphicsquartz-graphicscgpdfcontextapple-pdfkit

How to send PDF data to a printer programmatically?


In MacOS, I'm using python to write PDF Service Workflows, and after processing the incoming PDF (manipulating it with PyObjC Quartz APIs), I want to send it back to the print queue and get it printed without any user effort.

Is it possible to send a Graphics Context or PDFKit data directly to the printer?


Solution

  • You can use the Core Printing APIs. You can use PMPrinterPrintWithProvider() for the all-in-one approach, or the functions under Print Loop Functions to drive the print loop manually.

    I don't know off-hand if those functions are available via the PyObjC bridge.