2

我正在使用此代码来获取 PDF 的内容:

var oDoc = new CGPDFDocument.FromFile("./test.pdf");
var oCat = oDoc.GetCatalog();

但是我怎么知道迭代目录呢?所有方法都需要一个“密钥”,但我不知道如何获取根密钥或密钥数组。

我发现在 ObjC 中会使用类似的东西:

CGPDFDictionaryApplyFunction(pdfDocDictionary, ListDictionaryObjects, NULL);

void ListDictionaryObjects (const char *key, CGPDFObjectRef object, void *info) {
    NSLog("key: %s", key);
    CGPDFObjectType type = CGPDFObjectGetType(object);
    switch (type) { 
        case kCGPDFObjectTypeDictionary: {
            CGPDFDictionaryRef objectDictionary;
            if (CGPDFObjectGetValue(object, kCGPDFObjectTypeDictionary, &objectDictionary)) {
                CGPDFDictionaryApplyFunction(objectDictionary, ListDictionaryObjects, NULL);
            }
        }
        case kCGPDFObjectTypeInteger: {
            CGPDFInteger objectInteger;
            if (CGPDFObjectGetValue(object, kCGPDFObjectTypeInteger, &objectInteger)) {
                NSLog("pdf integer value: %ld", (long int)objectInteger); 
            }
        }
        // test other object type cases here
        // cf. http://developer.apple.com/mac/library/documentation/GraphicsImaging/Reference/CGPDFObject/Reference/reference.html#//apple_ref/doc/uid/TP30001117-CH3g-SW1
    }    
}

另请参阅: Monotouch 中 CGPDFDocumentGetCatalog 的等价物是什么?

4

1 回答 1

0

看起来 MonoTouch(和 MonoMac,因为这是共享代码)也缺少CGPDFDictionaryApplyFunction的绑定。没有它,您需要知道字典中的键值。

如果您正在寻找特定的东西(即众所周知的键值),但如果您想检查/显示字典实例中存在的所有内容,则效果很好。

I'll look to add this binding into 'maccore' (consumed by both MonoMac and MonoTouch) and will update this entry with the binding so it can be used inside application (until fixed versions are available).

于 2011-08-31T18:31:04.657 回答