any help would be appreciated :)- (IBACTION) printpdf { if ((!_webVIEw)) return; UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController]; voID (^completionHandler)(UIPrintInteractionController *,BOol,NSError *) = ^(UIPrintInteractionController *printController,BOol completed,NSError *error) { if(!completed && error){ NSLog(@"Failed! due to error in domain %@ with error code %ld",error.domain,(long)error.code); } }; uiprintinfo *printInfo = [uiprintinfo printInfo]; printInfo.outputType = uiprintinfoOutputGeneral; printInfo.duplex = uiprintinfoDuplexLongEdge; controller.printInfo = printInfo; controller.showsPageRange = YES; _webVIEw.scalesPagetoFit = NO; UIVIEwPrintFormatter *vIEwFormatter = [_webVIEw vIEwPrintFormatter]; vIEwFormatter.startPage = 0; controller.printFormatter = vIEwFormatter; if (UI_USER_INTERFACE_IdioM() == UIUserInterfaceIdiomPad) { /* [controller presentFrombarbuttonItem:printbutton animated:YES completionHandler:completionHandler]; */ }else [controller presentAnimated:YES completionHandler:completionHandler];}
输出:
解决方法 继@crescendolls响应之后,这里有一整段代码可以将您的webvIEw中的pdf转换为数据,并相应地进行打印.-(voID)printReport { uiprintinfo *pi = [uiprintinfo printInfo]; pi.outputType = uiprintinfoOutputGeneral; pi.jobname = webVIEw.request.URL.absoluteString; pi.orIEntation = uiprintinfoOrIEntationPortrait; pi.duplex = uiprintinfoDuplexLongEdge; UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; pic.printInfo = pi; pic.showsPageRange = YES; //does not display pdf appropriately //pic.printFormatter = webVIEw.vIEwPrintFormatter; //does display pdf appropriately NSCachedURLResponse* webResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:[webVIEw request]]; NSData* webData = [webResponse data]; pic.printingItem = webData; [pic presentFrombarbuttonItem:self.printbarbutton animated:YES completionHandler:^(UIPrintInteractionController *pic2,NSError *error) { // indicate done or error }];}总结
以上是内存溢出为你收集整理的ios – 使用AirPrint打印Pdf会导致输出很小全部内容,希望文章能够帮你解决ios – 使用AirPrint打印Pdf会导致输出很小所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)