在 iPhone 上从 CSV 创建 PDF

发布于 2024-09-26 13:54:49 字数 461 浏览 4 评论 0原文

我正在创建的 iPhone 应用程序从核心数据数据库生成报告作为 CSV 文件,然后可以通过电子邮件发送该报告,以便用户可以在应用程序之外的其他地方使用该数据。我还想提供生成与 PDF 文件相同的报告的功能(当然,具有更好的格式),允许用户立即打印报告,而不必像 CSV 文件那样跳过几个步骤 - 即在另一个应用程序(例如 Excel、Numbers)然后重新格式化列(以便它们足够宽以进行打印)、加粗标题等。

本质上,我想提供 PDF 文件,以便用户立即获得格式良好的报告,并且如果他们希望进行数据操作并且需要可编辑的格式,则只需导出 CSV 文件。

我认为最简单的方法是获取 CSV 文件并将其转换为 PDF 文件,这与 CSV 相同,只是包含更好的格式(例如表格布局)而不是简单的逗号分隔格式CSV 文件的。我一直无法找到任何用于此目的的现成类(以避免重新发明轮子),并且我不确定如何解决这个问题,因为我在 SDK 这方面的经验有限。任何正确方向的建议或指示将不胜感激。

An iPhone app which I am creating generates reports from a Core Data database as a CSV file, which can then be emailed so that the user may use that data elsewhere outside of the app. I would also like to offer the ability to generate the same reports as a PDF file (of course, with nicer formatting) allowing the user to immediately print the report rather than having to jump through several hoops as with the CSV file - i.e. open in another application (e.g. Excel, Numbers) then reformat the columns (so they are wide enough for printing), bold the headings, etc.

Essentially, I want to provide the PDF file so that the user is immediately given a nicely formatted report, and they only need to export the CSV file if they wish to do data manipulation and need a format which is editable.

I was thinking that the easiest method would be taking the CSV file and the converting this into a PDF file, which would be the same as the CSV except would incorporate nicer formatting (such as a tabular layout) rather than the simple comma-separated format of the CSV file. I have been unable to find any ready-made classes for this purpose (to avoid reinventing the wheel) and I am unsure how to approach this since I have limited experience with this aspect of the SDK. Any suggestions or pointers in the right direction would be much appreciated.

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

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

发布评论

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

评论(1

相对绾红妆 2024-10-03 13:54:49

您有两个不同的问题:

  1. 将 CSV 数据读入内存中的某些结构
  2. 将内存中的某些结构转换为 PDF

Aaron Saunders 发布了步骤 2 的一些链接,因此这里是步骤 1 的链接:

http://github.com/davedelong/CHCSVParser

这是我编写的一个 CSV 解析器,它将把你的 CSV 文件转换成 NSArray NSArraysNSStrings

You have two different problems:

  1. Read CSV data into some structure in memory
  2. Turn some structure in memory into a PDF

Aaron Saunders has posted some links for step 2, so here's a link for step 1:

http://github.com/davedelong/CHCSVParser

That's a CSV parser I wrote that will turn your CSV file into an NSArray of NSArrays of NSStrings.

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