从 pdf 文件创建目录
我正在使用quartz 来显示pdf 内容,并且我需要创建一个目录来浏览pdf。通过阅读Apple的文档,我认为我应该使用CGPDFDocumentGetCatalog,但我找不到任何关于如何在任何地方使用它的示例。有什么想法吗?
更新:仍然没有找到解决方案。我厌倦了亚历克斯的解决方案,但我得到的输出看起来像这样:
2011-07-27 09:16:19.359 LDS Scriptures App-iPad[624:707] key: Pages
2011-07-27 09:16:19.361 LDS Scriptures App-iPad[624:707] key: Count
2011-07-27 09:16:19.362 LDS Scriptures App-iPad[624:707] pdf integer value: 238
2011-07-27 09:16:19.363 LDS Scriptures App-iPad[624:707] key: Kids
2011-07-27 09:16:19.366 LDS Scriptures App-iPad[624:707] key: Type
2011-07-27 09:16:19.368 LDS Scriptures App-iPad[624:707] key: Outlines
2011-07-27 09:16:19.370 LDS Scriptures App-iPad[624:707] key: Count
2011-07-27 09:16:19.371 LDS Scriptures App-iPad[624:707] pdf integer value: 7
2011-07-27 09:16:19.372 LDS Scriptures App-iPad[624:707] key: First
2011-07-27 09:16:19.374 LDS Scriptures App-iPad[624:707] key: Parent
2011-07-27 09:16:19.375 LDS Scriptures App-iPad[624:707] key: Count
2011-07-27 09:16:19.376 LDS Scriptures App-iPad[624:707] pdf integer value: 7
还不知道如何将其变成可用的目录。理想情况下,我希望获取具有标题和匹配页码的 NSDictionary
对象数组。
I'm using quartz to display pdf content, and I need to create a table of contents to navigate through the pdf. From reading Apple's documentation I think I am supposed to use CGPDFDocumentGetCatalog, but I can't find any examples on how to use this anywhere. Any ideas?
Update: Still haven't found a solution for this. I tired Alex' solution but the output I get looks like this:
2011-07-27 09:16:19.359 LDS Scriptures App-iPad[624:707] key: Pages
2011-07-27 09:16:19.361 LDS Scriptures App-iPad[624:707] key: Count
2011-07-27 09:16:19.362 LDS Scriptures App-iPad[624:707] pdf integer value: 238
2011-07-27 09:16:19.363 LDS Scriptures App-iPad[624:707] key: Kids
2011-07-27 09:16:19.366 LDS Scriptures App-iPad[624:707] key: Type
2011-07-27 09:16:19.368 LDS Scriptures App-iPad[624:707] key: Outlines
2011-07-27 09:16:19.370 LDS Scriptures App-iPad[624:707] key: Count
2011-07-27 09:16:19.371 LDS Scriptures App-iPad[624:707] pdf integer value: 7
2011-07-27 09:16:19.372 LDS Scriptures App-iPad[624:707] key: First
2011-07-27 09:16:19.374 LDS Scriptures App-iPad[624:707] key: Parent
2011-07-27 09:16:19.375 LDS Scriptures App-iPad[624:707] key: Count
2011-07-27 09:16:19.376 LDS Scriptures App-iPad[624:707] pdf integer value: 7
No idea yet how to turn that into a usable table of contents. Ideally I would like to get to an array of NSDictionary
objects with a title and matching page number.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是我的方法。
1.下载此框架
vfr reader
2。使用这行代码获取所有PDF章节
希望对您有所帮助。
Here is my approach.
1. Download this framework
vfr reader
2. Use this lines of code to get all PDF chapters
Hope it will help you.
您可以使用 PDFKit 的 PDFOutline 对象创建目录(又名大纲、书签)。您还可以阅读 PDF 中的现有大纲。
CGPDFDocumentGetCatalog
是一种获取文件中 PDF 数据目录的方法,它的级别比人类的“内容”概念要低得多。在没有现有大纲的情况下,我不确定是否有办法从 PDF 流本身获取有意义的数据,例如尝试仅从 PDF 数据中获取章节标题。
You create a Table of Contents (AKA Outlines, Bookmarks) using PDFKit's PDFOutline object. You can also read existing Outlines within a PDF.
CGPDFDocumentGetCatalog
is a method for getting the Catalog of PDF data in the file, which is at a much lower-level than human concepts of 'Contents'.In the absence of existing Outlines, I'm not sure there's a way to get meaningful data from the PDF stream itself, e.g. trying to grok Chapter headings just from the PDF data.
我使用 iOS 的免费软件库
FastPdfKit
I did it with a freeware library for iOS
FastPdfKit
像这样的事情可能会帮助您开始:
Something like this might help you get started: