Feature request :
37516 - iOS printing to airprint should be supported
Status: Needs Review Rank: Not Ranked Product: Xojo Category: Compiler
Printing is a basic feature necessary for most business applications. Please add that.
feedback://showreport?report_id=37516
I have been trying to understand how to print with declares from Xojo iOS, since printing is not yet supported.
Thanks to the brilliant work of Jason King, I can use the UIPrintInteractionController class.
I found this example at http://stackoverflow.com/questions/4373420/how-to-print-in-ios-4-2 that seems short enough to be translated to Xojo. But am far too ignorant in Objective-C :
[code]- (IBAction)printContent:(id)sender {
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = self.documentName;
pic.printInfo = printInfo;
UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc]
initWithText:yourNSStringWithContextOfTextFileHere];
textFormatter.startPage = 0;
textFormatter.contentInsets = UIEdgeInsetsMake(72.0, 72.0, 72.0, 72.0); // 1 inch margins
textFormatter.maximumContentWidth = 6 * 72.0;
pic.printFormatter = textFormatter;
[textFormatter release];
pic.showsPageRange = YES;
void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) =
^(UIPrintInteractionController *printController, BOOL completed, NSError *error) {
if (!completed && error) {
NSLog(@"Printing could not complete because of error: %@", error);
}
};
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[pic presentFromBarButtonItem:sender animated:YES completionHandler:completionHandler];
} else {
[pic presentAnimated:YES completionHandler:completionHandler];
}
}[/code]
I need insight from Objective-C specialists here. Do you think it is possible to adapt this code to Xojo ?