1

I am printing my screen view which is currently being displayed on iPhone as below. But for some reason some part of the screen is trimming off, Can anyone please suggest what is wrong with below code

Note : I am using autolayout on my view. Screen shots are attached.

-(void)printItem {

    UIGraphicsBeginImageContext(self.view.bounds.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();


    UIPrintInteractionController *printController = [UIPrintInteractionController sharedPrintController];

    if(printController ) {

        printController.delegate = self;

        UIPrintInfo *printInfo = [UIPrintInfo printInfo];
        printInfo.outputType = UIPrintInfoOutputGeneral;
        printInfo.jobName = @"resultado";
        printInfo.duplex = UIPrintInfoDuplexLongEdge;
        printController.printInfo = printInfo;
        printController.showsPageRange = YES;
        printController.printingItem = newImage;

        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);
            }
        };

        [printController presentAnimated:YES completionHandler:completionHandler];

    }
}

Simulator View enter image description here

Print View ( content trimming off )

enter image description here

Ketan P
  • 4,259
  • 3
  • 30
  • 36
Max
  • 5,380
  • 6
  • 42
  • 66
  • Workaround :- Unchecked or Removed Size Classes from the storyboard works fine. Does any one know why does size clases is making this content to trim off ? – Max Jul 05 '16 at 14:07
  • When are you calling `printItem`? You might need a `[self.view layoutIfNeeded]` before you render it to get the image. – dan Jul 05 '16 at 15:49
  • This is not working. – Max Jul 06 '16 at 13:58

0 Answers0