Search code examples
iphoneipadpdfios4

pdf parsing problem


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.


Solution

  • 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.