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:
pdftron.Common.PDFNetException: Exception:
Message: Printing not supported on this platform
Conditional expression: false
Version : 8.0.0.76134
Platform : OSX
Architecture : AMD64
Filename : TRN_Print.cpp
Function : TRN_PrintStartPrintJob
Linenumber : 45
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.
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.