有没有人知道如何实现打印(打印到打印机)的MonoMac示例?我还没能找到一个。
发布于 2012-03-09 11:01:46
我不知道有哪一个,但来自苹果的概念文档是相关的,它们的样本片段应该直接移植到C#:https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Printing/Printing.html
发布于 2012-12-19 21:36:53
我创建了一个类似如下的PrintDocument类:(你需要设置一个合适的大小并在drawrect中添加一些绘图)
public class PrintDocument:NSView {
NSPrintOperation MyPrinter = null;
static IntPtr selCurrentContext = Selector.GetHandle ("currentContext");
static IntPtr classNSGraphicsContext = Class.GetHandle ("NSGraphicsContext");
public PrintDocument ()
{
MyPrinter=NSPrintOperation.FromView(this);
this.SetFrameSize(new SizeF(600,800));
}
public void Print ()
{
MyPrinter.RunOperation()
}
public override void DrawRect (RectangleF dirtyRect)
{
var context = new NSGraphicsContext (Messaging.IntPtr_objc_msgSend (classNSGraphicsContext, selCurrentContext));
//NSPrintOperation.CurrentOperation
}
}https://stackoverflow.com/questions/9601416
复制相似问题