[英]How to have a NSTextView with a different font size just for printing?
I have a NSTextview that only shows good when the text is set to at least 16 in size, but that is too big for printing. 我有一个NSTextview,仅当文本设置为至少16个大小时才显示良好,但是对于打印来说太大了。 How to have a NSTextView with a different font size just for printing ?
如何仅打印具有不同字体大小的NSTextView? I have digged into NSPrintInfo but got no result so far.
我已经研究了NSPrintInfo,但到目前为止没有任何结果。 Thanks
谢谢
Here's an example: 这是一个例子:
// 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()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.