如何使用打印图像文件的预览打印对话框 [英] How to make a print dialog with preview for printing an image file

查看:398
本文介绍了如何使用打印图像文件的预览打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个mac可可图像编辑应用程序。我想为我的应用程序添加打印图像功能。我基本上总是有一个jpg / png文件与我。每当用户转到文件 - >打印菜单,我想给用户一个打印选项/设置打印此jpg / png文件的对话框。我想打印对话框是自定义的图像打印,如我们从预览应用程序打印图像时得到的。

I have a mac cocoa image editing application. I would like to add print image functionality to my application. I basically always have a jpg/png file with me. Whenever the user goes to File -> Print menu I would like to give user a dialog with print options/settings to print this jpg/png file. I would like the print dialog to be customized for image printing such as one we get when printing an image from Preview application.

我不想使用像因为这将给出一个简单的不太可定制的打印对话框:

I don't want to use something like the following because this will give a plain not very customizable print dialog:

[NSPrintOperation printOperationWithView:viewToPrint printInfo:[self.document printInfo]]


推荐答案

然后使用 print 方法。此方法将打印视图内的所有内容(包括子视图)。现在,对于可定制的打印,您可以做类似:用户点击标记为打印的按钮,它使您的自定义对话框出现在用户可以选择选项,如显示exemple日期(在子视图中的视图要打印),您存储这些选项,当用户单击对话框中的打印时,您可以删除他不想显示的子视图。并打印后,再次显示。此处还有其他打印视图的方法: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html

Well, you can put everything inside a NSView and then use the print method. This method will print everything that's inside the view (including subviews). Now for the customizable printing you can make something like: User clicks a button labeled "print", it makes your custom made dialog appear where the user can choose options such as, show exemple date (which is in a subview, of the view that's going to be printed), you store those options and them when the user clicks the print at your dialog, you can remove the subview he didn't wanted to show. And after its printed, show it again. There's also other methods for printing views here: http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html

这篇关于如何使用打印图像文件的预览打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆