iPhone 4.2 airprint打印作业失败

时间:2011-04-27 20:18:00

标签: xamarin.ios iphone-4 airprint

无论我选择哪台打印机,都会收到“打印作业失败:不支持的文档格式”application / pdf “。

我正在尝试仅在HP打印机上打印。

我在代码中看不到改变输出类型的地方。

我正在使用 UISimpleTextFormatter 格式化字符串。

不确定如何解决这个问题。

编辑:下面的代码是Miguel的例子。唯一不同的是,我尝试使用markupformatter来查看它是否以不同于 application / pdf 的格式输出。

打印对话框显示HP打印机列表,我选择打印机但没有打印任何内容,在调试模式下,顶部指定的错误会被记录。

除了 UIPrintInfoOutputType.General 之外,我还尝试了 UIPrintInfoOutputType.GrayScale ,但效果相同。

public partial class AppDelegate : UIApplicationDelegate
    {
        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            window.MakeKeyAndVisible ();
            var button = UIButton.FromType (UIButtonType.RoundedRect);
            button.Frame = new RectangleF (100, 100, 120, 60);
            button.SetTitle ("Print", UIControlState.Normal);
            button.TouchDown += delegate {
                Print ();
            };
            window.AddSubview (button);
            return true;
        }

        void Print ()
        {
            var printInfo = UIPrintInfo.PrintInfo;
            printInfo.JobName = "Test :";
            printInfo.OutputType = UIPrintInfoOutputType.General;
            printInfo.JobName = "Test: 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 htmlFormatter = new UIMarkupTextPrintFormatter("<html><body>Test : Hi There!!</body></html>");
            htmlFormatter.StartPage = 0;
            htmlFormatter.ContentInsets = new UIEdgeInsets (72, 72, 72, 72); // 1 inch margins
            htmlFormatter.MaximumContentWidth = 6 * 72;                 

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

        public override void OnActivated (UIApplication application)
        {
        }
    }

1 个答案:

答案 0 :(得分:1)

我原本期望打印对话框只能打印出支持空气打印的打印机。但它也提供了支持非气印的惠普打印机。我认为,它可以打印到那些打印机,并且它们可以启用空气打印。

但事实并非如此。