在这里,我正在打印大小为“pageSize = CGSizeMake(640, 832);”的 pdf。这个尺寸比 A4 尺寸的页面大。所以我会截掉一些文本(意味着它不会打印整个页面)。
在使用 MAC 打印相同的 pdf 时,它将在选项的帮助下打印整个页面(缩放以适应)。所以任何人都可以帮助我摆脱这个问题.. IOS sdk中是否有任何选项可以适应规模。
这是我的代码..
-(void)printItem
{
NSArray *aArrPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) ;
NSString *aStr = [[aArrPaths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"PropertyReport_%d.pdf",self.propertyId]];
// NSString *aStr = [[NSBundle mainBundle] pathForResource:@"TRADUZIONE HELP SECTIONS REV2" ofType:@"pdf"];
NSURL *url=[[NSURL alloc] initFileURLWithPath:aStr];
NSData *data=[[NSData alloc] initWithContentsOfURL:url];
printController = [UIPrintInteractionController sharedPrintController];
if(printController && [UIPrintInteractionController canPrintData:data])
{
printController.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
//printInfo.jobName = [NSString stringWithFormat:@"New Image"];
printInfo.duplex = UIPrintInfoDuplexLongEdge;
printController.printInfo = printInfo;
printController.showsPageRange = YES;
printController.printingItem = data;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = ^(UIPrintInteractionController *printController, BOOL completed, NSError *error)
{
if (!completed && error)
{
//NSLog(@"FAILED! due to error in domain %@ with error code %u", error.domain, error.code);
}
};
// aWebViewPDF.hidden=FALSE;
[printController presentAnimated:YES completionHandler:completionHandler];
}
}
谢谢!