我想打印UIWebView。用户可以选择纵向或横向打印。但是我不知道如何进行界面预览,因为我无法计算打印面积。请帮忙!

最佳答案

你可以这样

-(void)printWebView{
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
pic.printInfo = printInfo;
pic.printFormatter = [webView viewPrintFormatter];
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);
    }
};
[pic presentAnimated:YES completionHandler:completionHandler];

}

关于iphone - 如何预览UIWebview打印?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9428993/

10-13 04:00