|
@@ -359,13 +359,13 @@ extension KMPrintWindowController {
|
|
|
}
|
|
|
|
|
|
static func openPrintView(document: PDFDocument?) {
|
|
|
- if (document != nil &&
|
|
|
- document!.allowsPrinting == true) {
|
|
|
+ guard let document = document else { return }
|
|
|
+ if (document.allowsPrinting == true) {
|
|
|
let printInfo = NSPrintInfo.shared
|
|
|
var printOperation: NSPrintOperation = NSPrintOperation()
|
|
|
let scalingMode: PDFPrintScalingMode = .pageScaleToFit
|
|
|
- if document!.responds(to: NSSelectorFromString("printOperationForPrintInfo:scalingMode:autoRotate:")) {
|
|
|
- printOperation = document!.printOperation(for: printInfo, scalingMode: scalingMode, autoRotate: false)!
|
|
|
+ if document.responds(to: NSSelectorFromString("printOperationForPrintInfo:scalingMode:autoRotate:")) {
|
|
|
+ printOperation = document.printOperation(for: printInfo, scalingMode: scalingMode, autoRotate: false) ?? NSPrintOperation()
|
|
|
}
|
|
|
|
|
|
printOperation.printPanel.options = [.showsPreview, .showsCopies, .showsOrientation, .showsPageRange, .showsPaperSize, .showsCopies, .showsPrintSelection, .showsScaling]
|