我试图打印一个 pdf UIPrintInteractionController
,它加载到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];
}
输出: