How to remove copy and save to files option in UIPrintInteractionController

177 Views Asked by At

In the print preview screen, if no printer is connected, click on the print button, a popover is displayed in iOS 15 containing the Copy and Save to files option.

I want to remove this popover, As this file is confidential, and don't want to save this to the device.

enter image description here

Please help.

1

There are 1 best solutions below

0
R4N On

One option is to use a UIPrinterPickerController allowing the user to select the printer (instead of the entire UIPrinterInteractionController interface) and then using the printToPrinter:completionHandler: method to print directly to the printer. If you need to allow the user to print multiple copies or control any of the other print options, consider presenting your own custom UI to allow the user to select that.

Here's a quick example:

    UIPrinterPickerController *printerPicker = [[UIPrinterPickerController alloc] init];
    [printerPicker presentAnimated:YES completionHandler:^(UIPrinterPickerController * _Nonnull printerPickerController, BOOL userDidSelect, NSError * _Nullable error) {
        if (userDidSelect) {
            UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];
            // insert your print item here
            printController.printingItem = [UIImage systemImageNamed:@"square.and.arrow.up"];
            [printController printToPrinter:[printerPickerController selectedPrinter] completionHandler:^(UIPrintInteractionController * _Nonnull printInteractionController, BOOL completed, NSError * _Nullable error) {
                NSLog(@"Did the print complete? %@", completed ? @"YES" : @"NO");
            }];
        }
    }];