开发者

MonoTouch : Print to Network printer

I am really new to iPhone dev.

I am evaluating whether to use Monotouch or objC for a potential app.

The app needs to be able to print pictures to a network printer.

I have seen couple of po开发者_JS百科sts about how to do it using cocoa touch/objc.

Could not find any examples of doing this using monotouch.

Is this doable/supported using MonoTouch?

This is a must have feature.

Thanks


This should do it, I have checked this into:

http://github.com/migueldeicaza/monotouch-samples in the "print" directory:

void Print ()
{
    var printInfo = UIPrintInfo.PrintInfo;
    printInfo.OutputType = UIPrintInfoOutputType.General;
    printInfo.JobName = "My first Print Job";

    var textFormatter = new UISimpleTextPrintFormatter ("Once upon a time...") {
        StartPage = 0,
        ContentInsets = new UIEdgeInsets (72, 72, 72, 72),
        MaximumContentWidth = 6 * 72,
    };

    var printer = UIPrintInteractionController.SharedPrintController;
    printer.PrintInfo = printInfo;
    printer.PrintFormatter = textFormatter;
    printer.ShowsPageRange = true;
    printer.Present (true, (handler, completed, err) => {
        if (!completed && err != null){
            Console.WriteLine ("error");
        }
    });
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜