Я пытаюсь напечатать некоторый текст из UITextView вместе с одним изображением из UIImageView. Я искал какой-то учебник в Интернете, и мне удалось распечатать текст из UITextView, но я еще не нашел способ распечатать с ним изображение. UIImageView, который я хочу распечатать, называется qrImageView, а UITextView называется qrNoteTextView. Я использую следующий код для печати TextView:
- (IBAction)qrPrint:(id)sender {
NSLog(@"print action");
[self.qrNoteTextView resignFirstResponder];
NSMutableString *printBody = [NSMutableString stringWithFormat:@"%@ \n %@", self.qrNoteTextView.text, self.qrImageView.image];
[printBody appendFormat:@"\nCreated using ..."];
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.delegate = self;
UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = self.qrNoteTextView.text;
pic.printInfo = printInfo;
UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:printBody];
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;
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);
}
};
[pic presentFromBarButtonItem:self.qrNoteTextView animated:YES completionHandler:completionHandler];
}
Спасибо за ваше время!