Found the solution to my problem.
In my code above, I had a pdfDocument object and then I created the PDFView and tried to send it to the printer using NSPrintOperation.
I think setting the PDFView document as the downloaded pdf was the issue. So What I came up with was using the PDFDocument.printOperation and changed my printDocumentFunction
private func printPDFDocumentt(_ document: PDFDocument) {
let printInfo = NSPrintInfo.shared
printInfo.horizontalPagination = .fit
printInfo.verticalPagination = .fit
printInfo.orientation = .portrait
printInfo.topMargin = 0
printInfo.bottomMargin = 0
printInfo.leftMargin = 0
printInfo.rightMargin = 0
printInfo.isHorizontallyCentered = true
printInfo.isVerticallyCentered = true
let scale: PDFPrintScalingMode = .pageScaleDownToFit
let printOp = document.printOperation(for: printInfo, scalingMode: scale, autoRotate: true)
DispatchQueue.main.async {
printOp?.run()
}
}
Post
Replies
Boosts
Views
Activity
Update to this. Ive decided to try downloading the pdf file to my mac desktop and view the results. When I do this, the PDF looks completely normal.
I think there is something wrong with how I am creating my printPDFDocumentt function. Almost as if I have a pdfDocument and I am pasting the document to a new created PDFView and thats whats causing the weird pasting affect. Not sure exactly.
NSPrintOperation(view: pdfView, printInfo: printInfo)
this functino accepts a view of type NSView, Is there a way to convert a PDFDocument to an NSView?