Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

HarryWorksInc

macrumors regular
Original poster
Feb 21, 2010
179
0
I have been reading through apples printing documentation today to implement it into my app, which is basically a form contained within a scroll view, everything is going just fine however the margins aren't working. Here's my code:
Code:
    UIGraphicsBeginImageContext(Frame.frame.size);
    [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    UIMarkupTextPrintFormatter *formatter = [[UIMarkupTextPrintFormatter alloc]
                                                 initWithMarkupText:[NSString stringWithFormat:@"%@'s Patient Report", Name.text]];
    formatter.startPage = 0;
    formatter.contentInsets = UIEdgeInsetsMake(142.0, 36.0, 36.0, 36.0);
    
    UIPrintInteractionController *controller = [UIPrintInteractionController sharedPrintController];
    controller.delegate = self;
    
    UIPrintInfo *printInfo = [UIPrintInfo printInfo];
    printInfo.outputType = UIPrintInfoOutputGeneral;
    printInfo.jobName = [NSString stringWithFormat:@"%@'s Patient Report", Name.text];
    controller.printInfo = printInfo;
    controller.showsPageRange = YES;
    printInfo.duplex = UIPrintInfoDuplexLongEdge;
    controller.printingItem = viewImage;controller.printFormatter = formatter;
    [formatter release];
    
    void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
    ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) {
        if (!completed && error)
            NSLog(@"Print failed due to error in domain %@ with error code %u",
                  error.domain, error.code);
    };
    
    [controller presentFromBarButtonItem:printButton animated:YES completionHandler:completionHandler];

All I need really is the picture to be printed below about 2 inches below the top of the paper however when I print it the screen shot fits the page.

Any help is welcomed!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.