pdf 作为 iOS 设备中的电子邮件附件

发布于 2024-12-26 19:38:02 字数 343 浏览 2 评论 0原文

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

下载的pdf可以在这个路径查看: /Users/“用户名”/库/应用程序支持/iPhone模拟器/“您的应用程序目录”。

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

教程链接是: http://www.ioslearner.com/generate-pdf-programmatically-iphoneipad/

任何建议。

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

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

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

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

Any suggestion.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

酷炫老祖宗 2025-01-02 19:38:02

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

在本教程中,您需要将 PDF 渲染为 NSMutableData 对象:

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

然后在将来的某个时刻,您需要将该 pdfData 传递给 MFMailComposeViewController 。

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

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:

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

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

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"];
拥有 2025-01-02 19:38:02

请参阅 文档 了解 MFMailComposeViewController。具体来说,您正在寻找 addAttachmentData:mimeType:fileName: 方法。这应该能让你继续前进。

See the docs for MFMailComposeViewController. Specifically, you're looking for the addAttachmentData:mimeType:fileName: method. That should get you going.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文