2

我正在尝试使用 UIPrintInteractionController AirPrint a UIImage 此代码成功运行,但在打印预览中添加了一个边距,这对我来说并不理想。如何自定义左侧、右侧、顶部和底部边距为零或其他值?我知道 printablerect 但如何修改它?提前感谢您的帮助:)

 UIPrintInteractionController *pic = [UIPrintInteractionController    sharedPrintController];
 NSData *imageData=UIImageJPEGRepresentation(imageforPrint, 1.0);
 if (pic && [UIPrintInteractionController canPrintData: imageData] ) {
     pic.delegate = self;

     UIPrintInfo *printInfo = [UIPrintInfo printInfo];
     printInfo.outputType = UIPrintInfoOutputGeneral;
     printInfo.jobName = @"Job 1";
     printInfo.duplex = UIPrintInfoDuplexLongEdge;
     pic.printInfo = printInfo;

     UIPrintPageRenderer *renderer = [[UIPrintPageRenderer alloc] init];

     UIPrintFormatter *Formatter = [[UIPrintFormatter alloc] init];
     Formatter=pic.printFormatter;
     Formatter.startPage=0;
     Formatter.perPageContentInsets = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0);

     Formatter.startPage=0;

     [renderer Formatter startingAtPageAtIndex: 0];

     pic.showsPaperSelectionForLoadedPapers=YES;
     pic.printPageRenderer=renderer;

     pic.printFormatter=Formatter;
     pic.printingItem = imageData;
     pic.showsPageRange = YES;

     void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
                                ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
           //self.content = nil;
           if (!completed && error)
               NSLog(@"FAILED! due to error in domain %@ with error code %ld", error.domain, (long)error.code);

     };

     [pic presentAnimated:YES completionHandler:completionHandler];
4

0 回答 0