提供 Mac 应用程序的打印选项
我有一个 Mac 应用程序。在我的 Mac 应用程序中,我的屏幕之一有一个包含文本字段的 scrollView
。在同一屏幕上,我有一个需要提供打印选项的按钮。可以打印文本字段的文本。打印按钮应调用 Mac OS X 打印对话框。我可以通过 xib 将按钮连接到第一响应者的打印选项来打开打印对话框,但是当我预览时,除了打印按钮之外,我看不到任何文本。请帮忙。
I have a Mac app. In my Mac app one of my screen has a scrollView
which contains a text field. On the same screen I have a button that needs to provide a print option. The text of the text field can be printed. Print button should call the Mac OS X print dialog box. I am able to open the print dialog box by connecting the button to the print option of the first responder through xib but when I preview I don't see any text except the print button. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 NSPrintOperation 类参考。
NSPrintOperation 类参考
你可能需要将文本编写到一个足够大的 NSView 中以适合你的滚动视图内容...我从来没有从滚动视图中打印过,所以我不知道。
看看
你可能必须覆盖 print: 操作,记住你将把它发送给第一响应者......并且应该落入你的 NSDocument 或 NSApplication 子类,但我可能会尝试在 NSDocument if document 中获取它基于 NSWindow(子类或委托)(如果不是)。
check out the NSPrintOperation Class Reference.
NSPrintOperation Class Reference
you will probably need to compose the text to a NSView that is large enough to fit your scroll view contents... I haven't ever had to print from a scrollView, so i don't know.
look at
you will probably have to override the print: action, remember that you will be sending that to the first responder... and should fall through to your NSDocument or NSApplication subclass, but I would probably try to grab it at NSDocument if document based, NSWindow (subclass or delegate) if not.
我得到了答案。我正在使用下面的代码,
I got the answer for this.I am using the below code,