pdf parsing problem

此生再无相见时 提交于 2020-01-03 05:09:21

问题


hi im working on pdf viewer. i want to extract all the contents of the pdf. will cgpdgscanner get all the contents of pdf??

the apple documentation is very brief. its difficult to implement with the explanations given. and lots of googlin also leads to nowhere.

so can someone explain the use of the purpose and use of the following:

1.CGPDFOperatorTableRef

2.CGPDFOperatorTableSetCallback

3.CGPDFScannerRef

4.CGPDFContentStreamRef

once al this is done how to view the data that is got after parsing.

thanks in advance.


回答1:


The CGPDFScanner will parse a PDF graphic content stream (page content or form XObject content). This is very low level PDF, you have to know the PDF specification in order to interpret the results of the parsing. The CGPDFScanner will call a method of yours every time it encounters an operator that you are interested in. The CGPDFOperatorTable stores the list of operators you want to be notified about. If you want to extract all content you have to fill this table with all PDF graphic operators. Each operator is associated with a method (a callback) that is called when the scanner find the operator in the PDF content stream.
The CGPDFScannerRef is the PDF scanner and CGPDFContentStreamRef is a PDF content stream, a stream associated with a PDF object. The content of this stream depends on the PDF object this stream is associated with.




回答2:


Its not a big deal to parse pdf content but what makes it more difficult is to highlight searched text in PDF.

For parsing do as posted on the below url.

http://www.random-ideas.net/posts/42

For exact reader get the below code (but it shows the clumsy logo)

https://github.com/mobfarm/FastPdfKit

Thanks



来源:https://stackoverflow.com/questions/6897802/pdf-parsing-problem

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