如何使用不同字体大小的 NSTextView 仅用于打印?

How to have a NSTextView with a different font size just for printing?

我有一个 NSTextview,只有当文本的大小至少设置为 16 时,它才会显示良好,但这对于打印来说太大了。如何让 NSTextView 具有不同的字体大小仅用于打印?我已经深入研究了 NSPrintInfo 但到目前为止没有得到任何结果。谢谢

这是一个例子:

// Create another text view just for printing
var printTextView = NSTextView(frame: NSMakeRect(0, 0, 528, 688)) // A4
// Add a modified version of your attributed string to the view
printTextView.textStorage!.mutableString.appendString(myAttributedStringWithAdjustedSize)
// Get printing infos
let sharedInfo = NSPrintInfo.sharedPrintInfo()
let sharedDict = sharedInfo.dictionary()
let printInfoDict = NSMutableDictionary(dictionary: sharedDict)
printInfoDict.setObject(NSPrintSpoolJob, forKey: NSPrintJobDisposition)
let printInfo = NSPrintInfo(dictionary: printInfoDict)
// Set some preferences
printInfo.horizontallyCentered = true
printInfo.verticallyCentered = false
printInfo.scalingFactor = 0.8
// Print the custom text view
let op = NSPrintOperation(view: printTextView, printInfo: printInfo)
op.runOperation()