0

我正在尝试打印 NSImage,但无法使其尺寸合适。我希望 NSImage 在任何足够大的纸张上打印为 4"x6" 照片。这是我现在拥有的代码。

var printView = NSImageView(frame: NSRect(x: 0, y: 0, width: 72*4, height: 72*6))
var printInfo = NSPrintInfo()

printInfo.paperSize = NSSize(width: 72*4, height: 72*6)
printInfo.bottomMargin = 10
printInfo.topMargin = 10
printInfo.leftMargin = 10
printInfo.rightMargin = 10

printView.image = generateImage()
let printOp = NSPrintOperation(view: printView, printInfo: printInfo)
printOp.run()
4

1 回答 1

3

这似乎解决了我的问题

var printView = NSImageView(frame: NSRect(x: 0, y: 0, width: 72*4, height: 72*6))
var printInfo = NSPrintInfo()

printInfo.bottomMargin = 0
printInfo.topMargin = 0
printInfo.leftMargin = 0
printInfo.rightMargin = 0

printView.image = generateImage()
let printOp = NSPrintOperation(view: printView, printInfo: printInfo)
printOp.run()
于 2018-06-22T13:18:55.850 回答