我必须将 html 文本作为带有 pdf 扩展名的附件发送到邮件。
代码 :
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
NSArray *toReceipents =[NSArray arrayWithObjects:@"", nil];
[mailViewController setToRecipients:toReceipents];
[mailViewController setSubject:strMailMessage];
NSLog(@"Mail Message:%@ %@",strMailMessage,appDelegate.strShareText);
NSData* data = [appDelegate.strShareText dataUsingEncoding:NSUTF8StringEncoding];
[mailViewController setMessageBody:appDelegate.strShareText isHTML:YES];
[mailViewController addAttachmentData:data mimeType:@"application/pdf" fileName:@"Medication file.pdf"];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];
注意:当我下载 pdf 文件时,我得到相同的文本。但我想在 pdf 文档中以表格格式显示文本