Do not present printer picker when printer is specified
This commit is contained in:
parent
1c5b0314e7
commit
2fb312e34b
@ -71,11 +71,19 @@
|
||||
|
||||
UIPrintInteractionController* controller = [self printController];
|
||||
|
||||
CGRect rect = [self convertIntoRect:[settings objectForKey:@"bounds"]];
|
||||
NSString* printerId = [settings objectForKey:@"printerId"];
|
||||
|
||||
[self adjustPrintController:controller withSettings:settings];
|
||||
[self loadContent:content intoPrintController:controller];
|
||||
[self presentPrintController:controller fromRect:rect];
|
||||
|
||||
if (printerId) {
|
||||
[self sendToPrinter:controller printer:printerId];
|
||||
}
|
||||
else {
|
||||
CGRect rect = [self convertIntoRect:[settings objectForKey:@"bounds"]];
|
||||
|
||||
[self presentPrintController:controller fromRect:rect];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +124,6 @@
|
||||
printInfo.orientation = orientation;
|
||||
printInfo.jobName = [settings objectForKey:@"name"];
|
||||
printInfo.duplex = [[settings objectForKey:@"duplex"] boolValue];
|
||||
printInfo.printerID = [settings objectForKey:@"printerId"];
|
||||
|
||||
controller.printInfo = printInfo;
|
||||
controller.showsPageRange = NO;
|
||||
@ -128,7 +135,7 @@
|
||||
* Adjusts the web view and page renderer.
|
||||
*/
|
||||
- (void) adjustWebView:(UIWebView*)page
|
||||
andPrintPageRenderer:(UIPrintPageRenderer*)renderer
|
||||
andPrintPageRenderer:(UIPrintPageRenderer*)renderer
|
||||
{
|
||||
UIViewPrintFormatter* formatter = [page viewPrintFormatter];
|
||||
// margin not required - done in web page
|
||||
@ -210,6 +217,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the content directly to the specified printer.
|
||||
*
|
||||
* @param controller
|
||||
* The prepared print controller with the content
|
||||
* @param printer
|
||||
* The printer specified by its URL
|
||||
*/
|
||||
- (void) sendToPrinter:(UIPrintInteractionController*)controller
|
||||
printer:(NSString*)printerId
|
||||
{
|
||||
NSURL* url = [NSURL URLWithString:printerId];
|
||||
UIPrinter* printer = [UIPrinter printerWithURL:url];
|
||||
|
||||
[controller printToPrinter:printer completionHandler:
|
||||
^(UIPrintInteractionController *ctrl, BOOL ok, NSError *e) {
|
||||
CDVPluginResult* pluginResult =
|
||||
[CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
|
||||
|
||||
[self.commandDelegate sendPluginResult:pluginResult
|
||||
callbackId:_callbackId];
|
||||
}];
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Array into Rect object.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user