I've been using UIPrintInteractionController to print images in my app and it's worked out fine, since I can customise the page so that it prints with the appropriate margins.
I'm attempting to make use of the UIActivityViewController to do the same, however I've come across a bit of a block - whenever I pass in a UIImage in the activityItems, the print activity becomes available, however when it prints there are no margins and I'm not sure how to customise it. I've attempted to use UIMarkupTextPrintFormatter, however it then prints the image out over two pages and it's oversized, so part of the image is cut off the page. UIPrintInteractionController seemed to resize it appropriately when I passed in the image in the form of an NSData object.
This is what I've attempted to pass in the activityItems:
NSString *markupText = [NSString stringWithFormat:@"<html><body><img src='%@'></body></html>",self.imgURL]; //imgURL is the url of the image on the internet
UIMarkupTextPrintFormatter *htmlPrintF = [[UIMarkupTextPrintFormatter alloc] initWithMarkupText:markupText];
htmlPrintF.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins
htmlPrintF.maximumContentWidth = 6 * 72.0;
Ideally I don't want to be passing in the image URL since it takes up time downloading an image when it's already been downloaded and displayed once, and is retained in a UIImage object. The code above gives me the appropriate margins but the image is not sized appropriately to fit on the page.
It would be easier to just go back to using UIPrintInteractionController and ditch the UIActivityViewController, however I would like to have everything in one place, in UIActivityViewController.
Any ideas on how to control margins / image size when using UIActivityViewController?