ios – 使用AirPrint打印Pdf会导致输出很小

ios – 使用AirPrint打印Pdf会导致输出很小,第1张

概述我试图用UIPrintInteractionController打印一个pdf,它在UIWevView中加载.好消息是,我可以打印坏的是打印的输出是小的. any help would be appreciated :)- (IBACTION) printPDF { if ((!_webView)) return; UIPrintInteractionController 我试图用UIPrintInteractionController打印一个pdf,它在UIWevVIEw中加载.好消息是,我可以打印坏的是打印的输出是小的.

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会导致输出很小所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1055390.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存