在其下打印图像和文本并从右向左打印

时间:2011-08-08 01:46:53

标签: iphone objective-c ipad printing airprint

我知道如何仅使用nsdata打印图像

我也知道只使用UISimpleTextPrintFormatter打印文本

问题是我想打印图像及其下的文字

我怎样才能做到这一点?

如何从右坐标而不是左边开始打印?

NSMutableString *printBody = [NSMutableString stringWithFormat:@"some text"];
UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController];
pic.delegate = self;

UIPrintInfo *printInfo = [UIPrintInfo printInfo];
printInfo.outputType = UIPrintInfoOutputGeneral;
printInfo.jobName = @"print";
pic.printInfo = printInfo;

UISimpleTextPrintFormatter *textFormatter = [[UISimpleTextPrintFormatter alloc] initWithText:printBody];
textFormatter.startPage = 0;
textFormatter.font=[UIFont fontWithName:@"Arail Bold" size:40];
textFormatter.contentInsets = UIEdgeInsetsMake(216.0, 288.0, 72.0, 72.0);
textFormatter.maximumContentWidth = 6 * 72.0;
textFormatter.textAlignment=UITextAlignmentRight;
textFormatter.font=[UIFont fontWithName:@"Arail Bold" size:40];
pic.printFormatter = textFormatter;
pic.showsPageRange = YES;
[pic presentAnimated:YES completionHandler:NULL];
[textFormatter release];

谢谢

1 个答案:

答案 0 :(得分:0)

我不确定你的意思,但这有帮助吗?

// Setup Title
    theTitle = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 20)];
    [self.view addSubview:theTitle];

initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)告诉标题放置在哪里及其大小?