Reading PDF files as string through iPhone application

走远了吗. 提交于 2019-11-27 10:28:26
zachron

i have a library that can do this exact thing linked over here : Extracting pdf text in Objective C

If you want to extract some content from a pdf file, then you may want to read the following:

Parsing PDF Content

from the Quartz 2D programming guide.

Basically, you will use a CGPDFScanner object to parse the contents, which works as follows. You register a few callbacks that will be automatically invoked by Quartz 2D upon encountering some pdf operators in the pdf stream. After this initial step, you then actually start parsing the pdf stream.

Taking a brief look at your code, it appears that you are not following the steps required to parse the pdf content of the page you get through CGPDFDocumentGetPage(). You need first to setup the callbacks using CGPDFOperatorTableCreate() and CGPDFOperatorTableSetCallback(), then you get the page, you need to create a content stream using that page (using CGPDFContentStreamCreateWithPage()) and then instantiate a CGPDFScanner through CGPDFScannerCreate() and actually start scanning through CGPDFScannerScan().

The "Parsing PDF Content" section of the document pointed out by the above URL gives you all of the information required to implement pdf parsing.

Hope this helps.

Look at how the QuartzDemo sample application does this, specifically the QuartzPDFView class in the QuartzImages.h and QuartzImages.m files. It shows an example of loading a PDF via Quartz.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!