我正在为 Ipad 做一个应用程序,我正在尝试附加一个 pdf 文件以通过电子邮件发送,为此我创建了一个这样的 pdf。
pageSize= CGSizeMake(612, 792);
NSString *fileName=@"prueba.pdf";
NSArray *paths= NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *pdfFileName= [documentsDirectory stringByAppendingPathComponent:fileName];
NSString *url=[fileName stringByAppendingPathComponent:fileName];
[self generatePdfWithFilePath:pdfFileName];
NSData *pdfData = [NSData dataWithContentsOfFile:url];
下一步是创建一封电子邮件以发送 pdf 我 dis this, like this..
if ([MFMailComposeViewController canSendMail]){
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:@"esto es para probar"];
NSArray *toRecipients = [NSArray arrayWithObjects:currentuser.email, nil];
[mailer setToRecipients:toRecipients];
[mailer addAttachmentData:pdfData mimeType:@"application/pdf" fileName:fileName];
NSString *emailBody = @"correo prueba";
[mailer setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:mailer animated:YES];
mailer.modalPresentationStyle = UIModalPresentationPageSheet;
}else{
...
我生成我创建了 pdf 并且一切正常,当我看到电子邮件时,我看到 de pdf 像图像(图片)一样附加,但问题是当我收到电子邮件时没有附加任何内容。
任何想法