Ejemplo n.º 1
0
        private static async Task <bool> PrintObjectAsync(NSObject nsObject, PrintJobConfiguration printJobConfiguration)
        {
            bool result = false;

            UIPrintInteractionController printer = await PopulateCommonPrinterDetailsAsync(printJobConfiguration);

            if (!(printer is null))
            {
                printer.PrintingItem = nsObject;
                printer.Present(true, PrintCompletion);
                printer.Dispose();
                result = true;
            }

            return(result);
        }
Ejemplo n.º 2
0
        private async Task <bool> PrintUIViewAsync(UIView uiView, PrintJobConfiguration printJobConfiguration)
        {
            bool result = false;

            UIPrintInteractionController printer = await PopulateCommonPrinterDetailsAsync(printJobConfiguration);

            if (!(printer is null))
            {
                printer.PrintPageRenderer = new UIPrintPageRenderer()
                {
                    HeaderHeight = 40,
                    FooterHeight = 40
                };
                printer.PrintPageRenderer.AddPrintFormatter(uiView.ViewPrintFormatter, 0);

                UIPrintInteractionResult interactionResult;

                if (Device.Idiom == TargetIdiom.Tablet) // TODO - move to ApplicationType
                {
                    interactionResult =
                        await printer.PresentFromRectInViewAsync(new CGRect(200, 200, 0, 0), uiView, true);
                }
                else
                {
                    interactionResult = await printer.PresentAsync(true);
                }

                PrintCompletion(
                    interactionResult.PrintInteractionController,
                    interactionResult.Completed,
                    null);
                result = interactionResult.Completed;
                printer.Dispose();
            }

            return(result);
        }