Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Air print for UIwebview

Tags:

ios

airprint

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

like image 600
siva Avatar asked Jul 01 '11 07:07

siva


People also ask

Can I use WebView in iOS?

WebView can be defined as an object which can display the interactive web content and load HTML strings within the iOS application for an in-app browser. It is an instance of the WKWebView class, which inherits the UIView class.

What is UIWebView on Apple iPhone?

A view that embeds web content in your app.


1 Answers

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.

like image 136
Hafthor Avatar answered Oct 20 '22 21:10

Hafthor