gpt4 book ai didi

ios - 从 Url 创建工作 UIPrinter 对象以进行无对话打印

转载 作者:可可西里 更新时间:2023-11-01 03:58:59 28 4
gpt4 key购买 nike

场景:引导模式锁定应用程序接受一些用户输入(姓名等)并打印出一张票。用户无法选择打印机。

我计划的解决方案是保存我拥有的打印机 URL,其形式为:

ipp://<hostname>.local.:5001/<printername>

从这个存储的字符串构建 UIPrinter 对象:

var printerURL = NSUrl.FromString(SettingsService.OptPrinterUrl);
var printer = UIPrinter.FromUrl(printerURL);

然后我调用:

printer.ContactPrinter((available) => {
if (available) {
//
}
});

var printInterface = UIPrintInteractionController.SharedPrintController;
printInterface.PrintToPrinter(printer, (handler, completed, error) =>
{
if (!completed && error != null) {
UIAlertView alert = new UIAlertView("Guest Check-In App", "Print Error", null, "Ok", null);
alert.Show();
}
});

没有阳性结果。

但是,当使用从 UIPrinterPickerController 返回的 UIPrinter 对象(如下所示)时,一切正常。

var printerPicker = UIPrinterPickerController.FromPrinter(null);
printerPicker.PresentFromRect(new CGRect(0,0,100,100),this.View,true, delegate(UIPrinterPickerController handler, bool completed, NSError error) {
printer = printerPicker.SelectedPrinter;
});

我只能创建一个有效的 UIPrinter 对象,而不能像这样直接使用 UIPrinterPickerController 中的对象:

var printerPicker = UIPrinterPickerController.FromPrinter(null);
printerPicker.PresentFromRect(new CGRect(0,0,100,100),this.View,true, delegate(UIPrinterPickerController handler, bool completed, NSError error) {
printerPickerPrinter = printerPicker.SelectedPrinter;
});
var printer = (UIPrinter)UIPrinter.FromObject(printerPickerPrinter);

总结我需要的是一种“记住”打印机并使用该打印机在 xamarin 构建的 iOS 应用程序中自动打印的方法。

最佳答案

这是一个 iOS 错误。我向 Apple Bug Reporter (47180997) 报告,他们给了我一个蹩脚的回应:

Shared printers on Linux will not work with this contactPrinter method. It requires that the printer attributes are returned successfully. We often still send a print job even if the other parts fail.

For these methods to work properly, the server has to be a licensed and correctly implemented AirPrint server. CUPS running somewhere isn’t enough.

关于ios - 从 Url 创建工作 UIPrinter 对象以进行无对话打印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34602302/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com