AirPrint Connection Error

In my iOS application, I have the following code that is used for AirPrinting a simple NSString.

#pragma mark - Print -(IBAction)print:(id)sender { UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; pic.delegate = self; UIPrintInfo *printInfo = [UIPrintInfo printInfo]; printInfo.outputType = UIPrintInfoOutputGeneral; printInfo.jobName = @"Message"; pic.printInfo = printInfo; UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc]initWithText:self.Message.text]; textFormatter.startPage = 0; textFormatter.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins textFormatter.maximumContentWidth = 6 * 72.0; pic.printFormatter = textFormatter; pic.showsPageRange = YES; void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error) { if (!completed && error) { NSLog(@"Printing could not complete because of error: %@", error); } }; if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { [pic presentFromBarButtonItem:sender animated:YES completionHandler:completionHandler]; } else { [pic presentAnimated:YES completionHandler:completionHandler]; } } 

When I start my project (to check it), this is the error I get in the Output Debugger window when I click "Print" in the UIPrintInteractionController:

 Simulated\032InkJet\ 032@ \032USER\032NAME\032iMac._ipp._tcp.local.: startJob: Unable to connect to printd: Connection refused 

I get this error in iOS 5.1 simulator using print simulator. Why am I getting this error? I have a feeling that this is due to the way I use the print simulator. A.

Any help is appreciated, and as a wonderful side, does anyone know how to display a UIPrintInteraction controller from a regular UIButton on an iPad instead of a BarButtonItem?

EDIT: It should be noted that AirPrint is automatically configured when using Share Sheets in iOS 6.0 +.

+6
source share
3 answers

I had the same problem, and basically the answer to the stuffing fixed the problem. However, I first had to slip through a few hoops. In the end, it was some kind of issue with file permissions.

I did the following (note administrator access is required):

  • Open a terminal and go to the / private / var / tmp / folder

  • enter "whoami" to see the exact username.

  • Say your username is 'dogtest'. type 'sudo chown dogtest: admin printd'. You will receive a warning that basically asks you to make sure that you know what you are doing.

  • Enter the administrator password and press Enter.

  • Now you have ownership of the printd file and you can do whatever you want with it. Rename the file to another by typing 'mv printd printd-ren'.

  • Open the iOS simulator and printer simulator.

  • Open Safari in iOS Simulator and go to any web page.

  • Click the "Share" button in the lower center and select "Print."

  • Follow the instructions to complete printing. You should see much more activity in the printer printer log window. At this point, the printd file is recreated with the permissions of your account (this is good).

  • Close both the iOS simulator and the printer simulator.

  • Restart the iOS application in the simulator, and then run Printer Simulator again.

  • Now you can simulate Air Print from your application, and the print will open in Preview as a PDF.

I hope this solves the problem for you, or at least points you in the right direction. Good luck.

+11
source

Try to remove

/ private / var / tmp / printd

+3
source

I had a printer simulator that stops working for me and generally does not give me any errors. I tried different simulators, rebooted them, rebooted the computer, killed printd, as mentioned above, and other things too.

In the end, for me it changed my network connections: at that time I had wifi plus an ethernet cable (via thunderbolt) attached to my macbook - like wifi + ethernet connected to the same network. I pulled out the Ethernet cable and immediately started working again.

Thanks to Apple, where can I get my 20 minutes ago :)

+2
source

Source: https://habr.com/ru/post/913248/


All Articles