Iphone PDF查看器中的目录
我已经创建了一个pdf查看器,现在我想像索引一样显示目录,我想从该表中获取所有页面,有什么方法可以做到这一点吗Iphone PDF查看器中的目录,iphone,objective-c,Iphone,Objective C,我已经创建了一个pdf查看器,现在我想像索引一样显示目录,我想从该表中获取所有页面,有什么方法可以做到这一点吗 -Thanx任何进展虽然这是一篇非常古老的帖子,我认为你可能已经解决了它,但我发布了这个答案,以便其他人能够找到解决方案 此功能不完整,但可以有一个良好的开端。:) CGPDFDocumentGetCatalog函数帮助您获取目录 CGPDFDictionaryRef oldDict = CGPDFDocumentGetCatalog(pdf); CGPDFDictionaryAppl
-Thanx任何进展虽然这是一篇非常古老的帖子,我认为你可能已经解决了它,但我发布了这个答案,以便其他人能够找到解决方案 此功能不完整,但可以有一个良好的开端。:)
CGPDFDocumentGetCatalog
函数帮助您获取目录
CGPDFDictionaryRef oldDict = CGPDFDocumentGetCatalog(pdf);
CGPDFDictionaryApplyFunction(oldDict, copyDictionaryValues, NULL);
void copyDictionaryValues (const char *key, CGPDFObjectRef object, void *info) {
// NSLog(@"key: %s", key);
CGPDFObjectType typeObj = CGPDFObjectGetType(object);
switch (typeObj) {
case kCGPDFObjectTypeDictionary: {
CGPDFDictionaryRef objectDictionary;
if (CGPDFObjectGetValue(object, kCGPDFObjectTypeDictionary, &objectDictionary)) {
CGPDFDictionaryApplyFunction(objectDictionary, copyDictionaryValues, NULL);
}
}
break;
case kCGPDFObjectTypeString: {
CGPDFStringRef objectString;
if (CGPDFObjectGetValue(object, kCGPDFObjectTypeString, &objectString)) {
NSString *tempStr = (NSString *)CGPDFStringCopyTextString(objectString);
[auxInfo setObject:tempStr
forKey:[NSString stringWithCString:key encoding:NSUTF8StringEncoding]];
[tempStr release];
// NSLog(@"set string value");
}
}
break;
case kCGPDFObjectTypeInteger: {
CGPDFInteger objectInteger;
if (CGPDFObjectGetValue(object, kCGPDFObjectTypeInteger, &objectInteger)) {
[auxInfo setObject:[NSNumber numberWithInt:objectInteger]
forKey:[NSString stringWithCString:key encoding:NSUTF8StringEncoding]];
// NSLog(@"set int value");
}
}
break;
case kCGPDFObjectTypeBoolean: {
CGPDFBoolean objectBool;
if (CGPDFObjectGetValue(object, kCGPDFObjectTypeBoolean, &objectBool)) {
[auxInfo setObject:[NSNumber numberWithBool:objectBool]
forKey:[NSString stringWithCString:key encoding:NSUTF8StringEncoding]];
// NSLog(@"set boolean value");
}
}
break;
case kCGPDFObjectTypeArray : {
CGPDFArrayRef objectArray;
if (CGPDFObjectGetValue(object, kCGPDFObjectTypeArray, &objectArray)) {
// copyPDFArray(objectArray);
NSLog(@"set array value");
}
}
}
}