I am writing a dotnet core 3.1 app that is intended to be run on MacOS. I am attempting to print a document using Print.StartPrintJob, but I am getting the following error:
Message: Printing not supported on this platform
Conditional expression: false
Version : 188.8.131.52134
Platform : OSX
Architecture : AMD64
Filename : TRN_Print.cpp
Function : TRN_PrintStartPrintJob
Linenumber : 45
Is printing truly not supported on Mac? Or could I be passing the wrong arguments somehow? As far as I can tell I have correctly integrated the PDFtron library as indicated here: https://www.pdftron.com/documentation/mac/get-started/dotnet-core/#integrate-into-your-application
These docs seem to suggest that printing should be supported on Mac:
That is correct, there is no direct support for Mac printing on our SDK. Thank you for pointing out that guide, we will update it.
Note that unlike Windows, the macOS print system is based on PDF, so you should be able to pass the PDF direct to the macOS for printing.
Is there a particular reason you were hoping to use our SDK for printing?
How are you printing now? What are the current issue(s)?
Thank you for the clarification Ryan.
I am not typically a Mac programmer, so there may indeed be a simpler solution for my challenge. But from a high level, my app deals with password protected PDFs that in general the user can only interact with from within the app (that is, the PDF file and its password that is rendered is effectively transient and opaque to the user). Additionally, when the user prints, we need to run some authorization regarding the printer selected and the number of pages the user will print before issuing a print job. And an additional constraint is that we don’t want the user to ‘print to PDF’, as opposed to a real printer, and thereby removing the password and gaining unlimited access to the document.
We have this process working well with a hybrid Windows UWP/WPF version of the app, which (after showing a print dialog and running our auth checks), ultimately prints the document using Print.startPrintJob. For the Mac version I was hoping to use a similar design, which was going smoothly up until I found that startPrintJob does not work on mac.
I am assuming I will need to use Core Printing and rasterize the pages of the document individually using PDFRasterizer, but if there is a way to ‘pass the PDF direct to the macOS for printing’ that you could point me in the right direction to that would be most helpful.
Ideally you would want to pass the PDF file directly to the OS ,though you can use our SDK to remove the password, and perhaps flatten annotations if you like.
I believe this a useful link: http://www.danandcheryl.com/2010/05/how-to-print-a-pdf-file-using-cocoa
Otherwise, taking a closer look at CorePrinting in the Apple documentation.
Otherwise, yes you could use PDFRasterizer, or the much easier to use PDFDraw class, to pass in image data, though at the very least you would want to query the target printer to find out the DPI you want to raster at.