Xamarin.ios iPhone 4.2 airprint打印作业失败

Xamarin.ios iPhone 4.2 airprint打印作业失败,xamarin.ios,iphone-4,airprint,Xamarin.ios,Iphone 4,Airprint,无论选择哪种打印机,我都无法获得打印作业:不支持的文档格式应用程序/pdf 我正在尝试仅在HP打印机上打印 我在代码中看不到更改输出类型的地方 我正在使用UISimpleTextFormatter格式化字符串 我不知道怎么绕过这个 编辑:下面的代码直接来自Miguel的示例。唯一的区别是,我尝试了markupformatter,看看它是否以与application/pdf不同的格式输出 “打印”对话框会显示HP打印机列表,我选择了一台打印机,但没有打印任何内容,在调试模式下,会记录顶部指定的错误

无论选择哪种打印机,我都无法获得打印作业:不支持的文档格式应用程序/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)
        {
        }
    }

我希望打印对话框只显示支持空气打印的打印机。但它也提供了不支持airprint的HP打印机。我认为,它可以打印到那些打印机上,并且它们支持空气打印


但事实并非如此。

我希望打印对话框只显示支持空气打印的打印机。但它也提供了不支持airprint的HP打印机。我认为,它可以打印到那些打印机上,并且它们支持空气打印


但事实并非如此。

你能发布一些示例代码吗?你能发布一些示例代码吗?