iOS Air print for UIwebview

12,092
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;
pic.printFormatter = webView.viewPrintFormatter;
[pic presentAnimated:YES completionHandler:^(UIPrintInteractionController *pic2, BOOL completed, NSError *error) {
    // indicate done or error
}];

A more extensive sample on Apple's dev site.

Share:
12,092
siva
Author by

siva

Just a iphone developer

Updated on July 03, 2022

Comments

  • siva
    siva about 2 years

    Can any one guide me how to print the contents of my UIWebview,

    FOR EX : - i would like to print my doc,xls,ppt file from UIWebview to print the contents.

    Please get some links or sample code to solve this problem

    Thanks in advance