Reputation: 51
i´m new to apple´s core graphic for PDF. I developing an app to display a PDF with links/actions which will go to the page x/y. The first code/help i found was here. But that code is for external URLs to websites. In the pdf ref doc from Adobe.com i found out, that i have to use the "GoTo" action. I´ve tried all 3 types (object, name and byte string) but it doesn´t work. Can anyone get me a hint, what i´m doing wrong?
for (unsigned i = 0; i < arrayCount; ++i) {
CGPDFObjectRef aDictObj;
if (!CGPDFArrayGetObject(outputArray, i, &aDictObj)) {
return;
} // END if
CGPDFDictionaryRef annotDict;
if(!CGPDFObjectGetValue(aDictObj, kCGPDFObjectTypeDictionary, &annotDict)) {
return;
} // END if
CGPDFDictionaryRef aDict;
if(!CGPDFDictionaryGetDictionary(annotDict, "A", &aDict)) {
return;
} // END if
const char *gotoNameRef;
CGPDFArrayRef gotoArray;
if (CGPDFDictionaryGetArray(aDict, "D", &gotoArray)) {
if (!CGPDFArrayGetName(gotoArray, 0, &gotoNameRef)) {
return;
}
} else {
return;
} // END if
int gotoCounter = CGPDFArrayGetCount(gotoArray);
CGPDFArrayRef rectArray;
if(!CGPDFDictionaryGetArray(annotDict, "Rect", &rectArray)) {
return;
} // END if
int arrayCount = CGPDFArrayGetCount( rectArray );
CGPDFReal coords[4];
for( int k = 0; k < arrayCount; ++k ) {
CGPDFObjectRef rectObj;
if(!CGPDFArrayGetObject(rectArray, k, &rectObj)) {
return;
} // END if
CGPDFReal coord;
if(!CGPDFObjectGetValue(rectObj, kCGPDFObjectTypeReal, &coord)) {
return;
} // END if
coords[k] = coord;
} // END for
Thanks for any help.
Upvotes: 1
Views: 597
Reputation: 33058
There is a PDF reader in source available here:
It is on ObjectiveC and contains everything you need.
Upvotes: 1