With some help I have been able to figure out how to extract links from a PDF:
Code:
if (CGPDFDictionaryGetDictionary(annotationDictionary, "A", &actionDictionary)) {
const char* actionType;
if (CGPDFDictionaryGetName(actionDictionary, "S", &actionType)) {
if (strcmp(actionType, "GoTo") == 0) {
CGPDFDictionaryGetArray(actionDictionary, "D", &destArray);
}
CGPDFStringRef destName;
if (CGPDFDictionaryGetString(actionDictionary, "D", &destName)) {
// Traverse the Dests tree to locate the destination array.
CGPDFDictionaryRef catalogDictionary = CGPDFDocumentGetCatalog(document);
CGPDFDictionaryRef namesDictionary = NULL;
if (CGPDFDictionaryGetDictionary(catalogDictionary, "Names", &namesDictionary)) {
CGPDFDictionaryRef destsDictionary = NULL;
if (CGPDFDictionaryGetDictionary(namesDictionary, "Dests", &destsDictionary)) {
const char *destinationName = (const char *)CGPDFStringGetBytePtr(destName);
destArray = [self findDestinationByName: destinationName inDestsTree: destsDictionary];
}
}
}
if (strcmp(actionType, "URI") == 0) {
CGPDFStringRef uriRef = NULL;
if (CGPDFDictionaryGetString(actionDictionary, "URI", &uriRef)) {
const char *uri = (const char *)CGPDFStringGetBytePtr(uriRef);
linkTarget = [[NSString alloc] initWithCString: uri encoding: NSASCIIStringEncoding];
}
}
}
}
My question is now I need to extract embedded videos and handle them in my PDF Viewer. Does anyone know how to do this? I have poured over the official PDF Spec Document. It was a great help in creating the links but seems very confusing when dealing with media. Any help would be great! Thanks!