开发者

print an image and a text under it and print it from right to left

开发者 https://www.devze.com 2023-03-26 19:02 出处:网络
I know how to print an image only by using nsdata and I also know to print a text only by using UISimpleTextPrintFormatter

I know how to print an image only by using nsdata

and I also know to print a text only by using UISimpleTextPrintFormatter

the thin开发者_开发问答g is that I want to print an image and the text under it

How can I achieve that?

and how can I start printing from right coordinate instead of left?

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];

thank you


I'm not exactly sure what you mean, but does this help?

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

Where initWithFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>) tells theTitle where to be placed and its size?

0

精彩评论

暂无评论...
验证码 换一张
取 消