Cough .... PDF document parsing... I haven't found it online for a long time ..... Translate by yourself .. Not horizontal... Let's just take a look at it. This is what my brother translated in the afternoon.
Cough .... PDF document parsing... I haven't found it online for a long time ..... Translate by yourself .. Not horizontal... Let's just take a look at it. This is what my brother translated in the afternoon.
Cough .... PDF document parsing... I haven't found it online for a long time ..... Translate by yourself .. Not horizontal... Let's just take a look at it. This is what I translated in the afternoon .. I am exhausted ..
PDF document Parsing
Quartz provides functions that let you check the structure of the PDF document and the content stream (contentstream). Checking the document structure allows you to read the entries in the document directory and the content related to each entry. By recursively traversing the directory, you can check the entire document.
A pdf content stream (contentstream), as its name implies-a continuous data stream such as 'bt 12/F71 Tf (draw thistext) Tj... 'Here, the PDF operator and their descriptors are mixed with the actual PDF content. Check the content stream. You need to access it in order.
This chapter shows how to view the structure of a PDF file and parse the content of a PDF file.
Check PDF document structure
A PDF file may contain images and text on multiple pages. You can use Quartz to access documents and page-level metadata as well as objects on PDF pages. This section provides a brief introduction to metadata that you can access.
A pdf document object contains all the information about a PDF document, including its contents and contents. The entries in the directory recursively describe the content of the PDF document. You can access the content of a PDF document by calling the cgw.documentgetcatalog function.
A PDF page object (CGPDFPage) represents a page in a PDF document that contains all information about this specific page, including the page dictionary and page content. You can obtain a page dictionary by calling this function CGPDFPageGetDictionary.
Figure 14-1Displays the metadata that describes the two images-a PDF file consisting of 3-2.
You can obtain more useful information by accessing the PDF metadata. 4-1 is just an example. For example, you can use the code in 4-1 to check whether a PDF has a thumbnail (see 4-2 ).
Listing 14-1Get the scaling view of the PDF
CGPDFDictionaryRef d; |
CGPDFStreamRef stream; // represents a sequence of bytes |
d = CGPDFPageGetDictionary(page); |
// check for thumbnail data |
if (CGPDFDictionaryGetStream (d, “Thumb”, &stream)){ |
// get the data if it exists |
data = CGPDFStreamCopyData (stream, &format); |
Quartz decrypts and decrypts all data streams for you.
Figure 14-2Thumbnail slices
Quartz provides many functions that you can use to obtain the specified values of corresponding items in the PDF metadata. For example, you can use the CGPDFObjectGetValue function to input a CGPDFObjectRef, a PDF object type (kCGPDFObjectTypeBoolean, kCGPDFObjectTypeInteger, and so on), and a storage space for the stored value. The bucket is filled with the returned value.
There are also many other functions that can be used to traverse the PDF File hierarchy to access each node and Their subnodes. For example, the CGPDFArray function (CGPDFArrayGetBoolean, CGPDFArrayGet Dictionary, CGPDFArrayGetInteger, and so on) allows you to access the value of an array to retrieve values of a specific type. You can find this by reading the PDF specification.