1

我正在创建一个 ipad 应用程序,我想在其中以编程方式将数据发送到 wifi 打印机。是否有任何 API 或示例代码可用于实现这一目标?

谢谢。

4

2 回答 2

1

我认为普通的打印 API 会使用 AirPrint 来实现这一点。 http://developer.apple.com/library/IOs/documentation/2DDrawing/Conceptual/DrawingPrintingiOS/Printing/Printing.html

此外,还有一个很棒的应用程序叫做 Printopia,它可以让你的 Mac 充当 AirPrint 主机: http: //www.ecamm.com/mac/printopia/

于 2012-01-06T06:32:28.317 回答
0

UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];

if (pic && [UIPrintInteractionController canPrintData: self.myPDFData] ) {

pic.delegate = self;

UIPrintInfo *printInfo = [UIPrintInfo printInfo];

printInfo.outputType = UIPrintInfoOutputGeneral;

printInfo.jobName = @"PrintPdf";

printInfo.duplex = UIPrintInfoDuplexLongEdge;

pic.printInfo = printInfo;

pic.showsPageRange = YES;

pic.printingItem = self.myPDFData;

void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =

^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {

    if (!completed && error)

        NSLog(@"FAILED! due to error in domain %@ with error code %ld",

              error.domain, (long)error.code);
};
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

    [pic presentFromRect:self.printButton.frame inView:self.view animated:YES completionHandler:^(UIPrintInteractionController *printInteractionController, BOOL completed, NSError *error) {
    }];

} else {
    [pic presentAnimated:YES completionHandler:completionHandler];
}

}

于 2015-08-26T14:44:55.250 回答