1

どのプリンターを選択しても、「Print-job failed: Unsupported document format "application/pdf " というメッセージが表示されます。

HP プリンターでのみ印刷しようとしています。

コードに出力タイプを変更する場所がありません。

UISimpleTextFormatterを使用して文字列をフォーマットしています。

これを回避する方法がわかりません。

編集:以下のコードは、ミゲルの例からまっすぐです。唯一の違いは、マークアップフォーマッターを試して、 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)
        {
        }
    }
4

1 に答える 1

1

印刷ダイアログには、エアプリント対応のプリンターのみが表示されると思っていました。ただし、Airprint 対応ではない HP プリンターも同様です。それは私が思うに、それはそれらのプリンターに印刷でき、それらはエアプリントが有効になっていると思います.

しかし、そうではありませんでした。

于 2011-05-11T12:45:06.727 に答える