在 iPhone 上从 CSV 创建 PDF
我正在创建的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有两个不同的问题:
Aaron Saunders 发布了步骤 2 的一些链接,因此这里是步骤 1 的链接:
http://github.com/davedelong/CHCSVParser
这是我编写的一个 CSV 解析器,它将把你的 CSV 文件转换成
NSArray
NSArrays
的NSStrings
。You have two different problems:
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
ofNSArrays
ofNSStrings
.