pdf作为iOS设备中的电子邮件附件 [英] pdf as an email attachment in iOS device

查看:331
本文介绍了pdf作为iOS设备中的电子邮件附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想附上作为电子邮件附件创建的pdf。我使用以下教程在iOS设备上创建pdf。

I would like to attach pdf created as an email attachment. I used following tutorial to create pdf on iOS device.

可以在此路径查看下载的pdf:
/ Users /Username/ Library / Application Support / iPhone Simulator /Your App Directory。

The downloaded pdf can be viewed at this path: /Users/"Username"/Library/Application Support/iPhone Simulator/"Your App Directory".

我还没有尝试在ios设备上运行此功能,但我需要将其作为电子邮件附加。

I have not tried running this on ios device but I need to attach it as an email.

Link对于教程是:
http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad /

Link for tutorial is : http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/

任何建议。

推荐答案

创建 MFMailComposeViewController 并调用 addAttachmentData :mime类型:文件名:。数据将是您创建的PDF。 mimeType将是 application / pdf 。 fileName将是电子邮件附件中文件的名称。代码可能如下所示:

Create a MFMailComposeViewController and call addAttachmentData:mimeType:fileName:. The data will be the PDF you created. The mimeType will be application/pdf. And the fileName will be the name of the file in the email attachment. The code might look like something below:

从教程中,您需要将PDF呈现为NSMutableData对象:

From the tutorial you'll need to render your PDF into a NSMutableData object:

NSMutableData *pdfData = [NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, bounds, nil);

然后在将来的某个时候你需要将pdfData传递给 MFMailComposeViewController

Then at some point in the future you'll need to pass that pdfData to the MFMailComposeViewController.

MFMailComposeViewController *vc = [[[MFMailComposeViewController alloc] init] autorelease];
[vc setSubject:@"my pdf"];
[vc addAttachmentData:pdfData mimeType:@"application/pdf" fileName:@"SomeFile.pdf"];

这篇关于pdf作为iOS设备中的电子邮件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆