【问题标题】:CGPDFDictionary keysCGPDF字典键
【发布时间】:2011-05-19 15:45:39
【问题描述】:

我快疯了,因为我找不到 PDF 文档中的“默认”键。

例如,如果我想从 CGPDFDocument 中检索超链接,我会这样做:

CGPDFStringRef uriStringRef;
if(!CGPDFDictionaryGetString(aDict, "URI", &uriStringRef)) {
    break;
}

在这种情况下,键是“URI”。是否有文档解释 CGPDFDictionary 的键是什么?

【问题讨论】:

    标签: pdf ios4 quartz-graphics


    【解决方案1】:

    您必须阅读 1300 页长的规范才能找到字典包含的键是荒谬的,字典可以包含任何内容,具体取决于它的注释类型。

    要获取CGPDFDictionaryRef 中的键列表,请执行以下操作:

    // temporary C function to print out keys
    void printPDFKeys(const char *key, CGPDFObjectRef ob, void *info) { 
        NSLog(@"key = %s", key);
    }
    

    在您尝试查看内容的地方:

    CGPDFDictionaryRef mysteriousDictionary; // this is your dictionary with keys
    CGPDFDictionaryApplyFunction(mysteriousDictionary, printPDFKeys, NULL);
    // break on or right after above, and you will have the list of keys NSLogged
    

    【讨论】:

    • 嗨,Kalle,您能更新一下您对 Swift 的回答吗?
    【解决方案2】:

    Adobe PDF Reference 描述了所有的键。

    【讨论】:

      【解决方案3】:

      字典中的键取决于字典所代表的实际对象(页面字典有其他键而不是注释字典)。 Adobe PDF 参考描述了所有这些对象及其键。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2022-01-25
        • 2018-12-07
        • 2015-10-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多