iOS printing formatting

Posts: 18
Joined: 2011.06
Post: #1
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:

view plaincopy to clipboardprint?
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];  
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();  
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!
Quote this message in a reply
Post Reply