PDF多页时不附加到电子邮件

时间:2012-01-29 17:25:59

标签: iphone objective-c xcode ipad email-attachments

这让我发疯了。该应用程序创建一个PDF,当PDF只有一页时,它就可以很好地附加到电子邮件中。但是,如果PDF不止一页,则该文件将不会附加到电子邮件中。

更多信息:

  1. 我可以打开在PC上创建的文件,因此我知道该文件已创建好了。
  2. 我检查确保NSData调用中有数据,并且有。
  3. 我还测试过我可以附加图像,这也很好。
  4. 任何人都知道有任何错误或有人遇到此问题吗?

    以下是代码块:

    //Setup Email
    MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
    
    [composer setMailComposeDelegate:self];
    
    if ([MFMailComposeViewController canSendMail])
    {
        [composer setToRecipients:[NSArray arrayWithObjects:EmailTO.text, nil]];
        [composer setCcRecipients:[NSArray arrayWithObjects:EmailCompany.text, nil]];
        [composer setSubject:[NSString stringWithFormat:@"PDF From: %@", EmailCompanyName.text]];
        [composer setMessageBody:EmailBody.text isHTML:NO];
    
        //Attach PDF               
        NSString *myAttachment = [NSString stringWithFormat:@"%@", showReportName.text];
        NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
        NSString *myFile = [documentsPath stringByAppendingPathComponent:myAttachment];
        NSData *myData = [NSData dataWithContentsOfFile:myFile];
        [composer addAttachmentData:myData mimeType:@"application/pdf" fileName:myAttachment];
    
        [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
        [self presentModalViewController:composer animated:YES];
        [composer release];
    } else
        [composer release];
    

0 个答案:

没有答案