Преглед изворни кода

【裁剪】- 裁剪区域打印

liaoxiaoyue пре 1 година
родитељ
комит
f7dd7ebbf4

+ 5 - 3
PDF Office/PDF Office/Class/PDFWindowController/ViewController/KMMainViewController+Action.swift

@@ -473,9 +473,11 @@ extension KMMainViewController {
         let page = listView.currentPage()
         let copyPage : CPDFPage = page!.copy() as! CPDFPage
         copyPage.setBounds(rect, for: .cropBox)
-        let pdfDocument : CPDFDocument = CPDFDocument()
-        pdfDocument.insertPageObject(copyPage, at: 0)
-        
+        let image : NSImage = copyPage.thumbnail(of:(copyPage.bounds(for: .cropBox)).size)
+        let pdfDocument : PDFDocument = PDFDocument()
+        let newpage : PDFPage = PDFPage(image: image)!
+        pdfDocument.insert(newpage, at: 0)
+        KMPrintWindowController.openPrintView(document: pdfDocument)
         KMPrintWindowController.openDocument(inputDocument: self.listView?.document, inputPageRange: KMPrintPageRange(type: .allPage, selectPages: []))
     }