0

In NSDocument subclass, have this function:

override func printOperationWithSettings(printSettings: [String : AnyObject]) throws -> NSPrintOperation {
    let printInfo: NSPrintInfo = self.printInfo
    var pageSize = printInfo.paperSize
    pageSize.width -= printInfo.leftMargin + printInfo.rightMargin
    pageSize.height -= printInfo.topMargin + printInfo.bottomMargin
    pageSize.width = pageSize.width * 2
    pageSize.height = pageSize.height * 2
    let myPage = MyPage(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: pageSize))
    let printOperation = NSPrintOperation(view: myPage, printInfo: printInfo)
    return printOperation
}

MyPage is, for this test, an NSView subclass that just draws an oval.

class MyPage: NSView {

override var flipped: Bool {
    return true
}

override func drawRect(dirtyRect: NSRect) {
    super.drawRect(dirtyRect)

    NSColor.greenColor().set() // choose color
    let figure = NSBezierPath() // container for line(s)
    figure.appendBezierPathWithOvalInRect(self.frame)
    figure.stroke()  // draw line(s)
}    
}

I'd expect this to show four pages in the print panel, but it only shows two, equating to the top left and bottom left of the oval. No matter how wide I make myPage's frame, only the leftmost pages are shown. Any ideas why? Thank you!

JKaz
  • 765
  • 6
  • 18
  • What are `horizontalPagination` and `verticalPagination` of `printInfo`? – Willeke Jun 20 '16 at 22:16
  • Well, geez, ya can stare at code and documentation for a day and still miss key properties. `horizontalPagination` apparently defaults to `ClipPagination`. Thank you for pointing out the now-obvious. `printInfo.horizontalPagination = .AutoPagination` fixes all. – JKaz Jun 20 '16 at 22:42

0 Answers0