How to get an indirect link to a page object with CGPDF?

According to Adobe's "Document Management - Portable Document Format - Part 1: PDF 1.7" ( Pdf32000_2008.pdf ), section 12.3.2.1 sets the states

The purpose determines the specific presentation of the document, consisting of the following items:

  • Page of the document to be displayed

  • Location of the document window on this page

  • The coefficient of increase (increase)

Example:

[page /XYZ left top zoom]

But in my code

 CGPDFArrayGetObject(dArray, 0, &dObj) 

is CGPDFDictionaryRef .

 93 0 obj << /Type /Annot /Subtype /Link /Rect [71 717 190 734] /Border [16 16 1] /A << /Type /Action /S /GoTo /D [3 0 R /FitR –4 399 199 533] >> >> endobj 

How can I get 3 0 R from /D [3 0 R /FitR –4 399 199 533] ?

How can I get an indirect link to a page object, such as a [page /XYZ left top zoom] page object?

Here is my code:

 CGPDFPageRef pdfPage = CGPDFDocumentGetPage(pdfRef, pageNum); CGPDFDictionaryRef pageDictionary = CGPDFPageGetDictionary(pdfPage); CGPDFArrayRef outputArray; if(CGPDFDictionaryGetArray(pageDictionary, "Annots", &outputArray)) { int arrayCount = 0; arrayCount = CGPDFArrayGetCount(outputArray ); if(arrayCount>0) { for( int j = 0; j < arrayCount; ++j ) { CGPDFObjectRef aDictObj; if(CGPDFArrayGetObject(outputArray, j, &aDictObj)) { CGPDFDictionaryRef annotDict; if(CGPDFObjectGetValue(aDictObj, kCGPDFObjectTypeDictionary, &annotDict)) { CGPDFDictionaryRef aDict; if(CGPDFDictionaryGetDictionary(annotDict, "A", &aDict))//page 1 returns here { CGPDFArrayRef dArray; if(CGPDFDictionaryGetArray(aDict, "D", &dArray)) { CGPDFObjectRef dObj; if(CGPDFArrayGetObject(dArray, 0, &dObj)){ CGPDFDictionaryRef annotDict; if(CGPDFObjectGetValue(dObj, kCGPDFObjectTypeDictionary, &annotDict)) { } } } } } } } } } 

Thank you so much for re-playing, but I have a question where can I know that this object number is 3?

 CGPDFArrayGetObject(dArray, 0, &dObj) 

get CGPDFDictionaryRef, but I did not find the field is "3 0 R"

and one more question: if I know, this is "3 0 R"

where can I find by doing a PDF search for 3 0 obj

Thank you, thank you, very very ... I hope your answer will be Hagian!

+4
source share
3 answers

First , you quote the wrong example from table 151, page 366 of the PDF Reference because it does not fit your case:

 [page /XYZ left top zoom] 

A real example that fits your case:

 [page /FitR left bottom right top] 

value:

Display the page indicated by the page, its contents are enlarged enough to correspond to the rectangle indicated by the coordinates on the left, bottom, right and top entirely within the window both horizontally and vertically. If the required horizontal and vertical zoom ratios are different, use the smaller one, centering the rectangle inside the window in another dimension.

because your case is listed as:

 [3 0 R /FitR –4 399 199 533] 

Now, that example is called page , in your case it becomes 3 0 R The latter is a reference to object number 3 (generation 0), which you can find by doing a PDF search for 3 0 obj . This is the place that identifies the object number 3, which should be called what your look-for page for your destination.


Update: If your real document does contain a fragment [3 0 R /FitR –4 399 199 533] , then the same document should also contain another part that defines the page object (indirectly called) as 3 0 obj . This part defines the page object and may look like this:

  3 0 obj << /Type /Page /Parent 11 0 R /MediaBox [ 0 0 597.6 842.4 ] /Contents 31 0 R /Group << /Type /Group /S /Transparency /CS /DeviceRGB >> /Resources 23 0 R >> endobj 

Notice how this object refers again to three other objects: 11 0 R , 31 0 R and 23 0 R The last two indicate objects 31 and 23, which contain the contents of the page (31) and resources (23), i.e. fonts used by him. The first points to the parent (11) of this page.

Note 2: The numbering of objects does not have to be sequential, since the objects are displayed in a PDF file. The condition (almost) is only that the numbering is uniq.

+4
source

Alas, while the answers are being conducted, it is not yet clear what we need. A code snippet that shows the page number or the name we need to jump will do the trick.

-1
source

Check the code on github in vfr / reader. They seem to have figured out all of these links. From the PDF, it’s not clear what is happening.

-1
source

All Articles