I am trying to AirPrint a UIImage using UIPrintInteractionController this code works successfully except a margin is added to the print preview which is not desirable for me. how can I customize the left, right , top & bottom margins to zero or other values? i am aware of printablerect but how to modify it? Thanks for helps in advance:)
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];