Committed by
David PHAM-VAN
Set cutLength to be currentSize.height
If the currentSize is set, set the cutLengthFor to be the height of current size, else default to the paperHeight.
Showing
1 changed file
with
12 additions
and
1 deletions
@@ -31,7 +31,8 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | @@ -31,7 +31,8 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | ||
31 | private var orientation: UIPrintInfo.Orientation? | 31 | private var orientation: UIPrintInfo.Orientation? |
32 | private let semaphore = DispatchSemaphore(value: 0) | 32 | private let semaphore = DispatchSemaphore(value: 0) |
33 | private var dynamic = false | 33 | private var dynamic = false |
34 | - | 34 | + private var currentSize: CGSize? |
35 | + | ||
35 | public init(printing: PrintingPlugin, index: Int) { | 36 | public init(printing: PrintingPlugin, index: Int) { |
36 | self.printing = printing | 37 | self.printing = printing |
37 | self.index = index | 38 | self.index = index |
@@ -134,7 +135,17 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | @@ -134,7 +135,17 @@ public class PrintJob: UIPrintPageRenderer, UIPrintInteractionControllerDelegate | ||
134 | printing.onCompleted(printJob: self, completed: completed, error: error?.localizedDescription as NSString?) | 135 | printing.onCompleted(printJob: self, completed: completed, error: error?.localizedDescription as NSString?) |
135 | } | 136 | } |
136 | 137 | ||
138 | + public func printInteractionController(_ printInteractionController: UIPrintInteractionController, cutLengthFor paper: UIPrintPaper) -> CGFloat { | ||
139 | + if currentSize == nil{ | ||
140 | + return paper.paperSize.height | ||
141 | + } | ||
142 | + | ||
143 | + return currentSize!.height | ||
144 | + | ||
145 | + } | ||
146 | + | ||
137 | func printPdf(name: String, withPageSize size: CGSize, andMargin margin: CGRect, withPrinter printerID: String?, dynamically dyn: Bool) { | 147 | func printPdf(name: String, withPageSize size: CGSize, andMargin margin: CGRect, withPrinter printerID: String?, dynamically dyn: Bool) { |
148 | + currentSize = size | ||
138 | dynamic = dyn | 149 | dynamic = dyn |
139 | let printing = UIPrintInteractionController.isPrintingAvailable | 150 | let printing = UIPrintInteractionController.isPrintingAvailable |
140 | if !printing { | 151 | if !printing { |
-
Please register or login to post a comment