Objective C - Printing full view is trimming off content from right while using Autolayout

173 Views Asked by At

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

0

There are 0 best solutions below