【问题标题】:Problem with IOS parsing PDF and GOTOR linksIOS解析PDF和GOTOR链接的问题
【发布时间】:2011-09-13 19:57:11
【问题描述】:

我在使用 pdf 上的 GOTOR 链接获取外部文件的地址时遇到问题。使用石英。 我从苹果开发者区得到了一些例子,并且实际上能够得到直到数据字典上的GOTOR入口:这是我使用的代码:

 if (strcmp(actionType, "GoToR") == 0) // GoTo action type
            {
                NSLog(@"Annotation is of type GotoR");
                if (CGPDFDictionaryGetArray(actionDictionary, "D", &destArray) == false)
                {

                    const char *actionFile = NULL; // Annotation action type string
                    CGPDFDictionaryGetName(actionDictionary, "F", &actionFile);
                    CGPDFDictionaryGetString(actionDictionary, "D", &destName);


                    NSLog(@"link is  %@ filename is:%s",CGPDFStringCopyTextString(destName),actionFile);

                }
            }

单击链接,我从 NSLOG 获得以下输出:

链接是 REF-0000059 文件名是:(null)

在 PDF 格式参考中指出,GOTOR 注释应该有一个 F 字段,其中包含指向目标文件的链接...任何人有任何想法我做错了什么?

最好的问候。

【问题讨论】:

  • 如果您可以放置​​指向您的 PDF 文件的链接,我可以查看并告诉您更多详细信息。

标签: iphone objective-c ios ipad pdf


【解决方案1】:

致任何可能对该解决方案感兴趣的人: GOTOR F 字段既可以是字符串,也可以是数组,因此要使其在每种情况下都能正常工作,我们必须检查这两种可能性:

if (strcmp(actionType, "GoToR") == 0) // GoTo action type
            {
                NSLog(@"Annotation do tipo GotoR");
                if (CGPDFDictionaryGetArray(actionDictionary, "D", &destArray) == false)
                {
                    CGPDFStringRef actionFile = NULL;


                    CGPDFDictionaryRef linkDictionary = NULL;

                    if (CGPDFDictionaryGetDictionary(actionDictionary, "F", &linkDictionary) == true){
                        CGPDFDictionaryGetString(linkDictionary, "F", &actionFile);
                     }
                    else{
                        CGPDFDictionaryGetString(actionDictionary, "F", &actionFile);
                    }
                    *actionFile = NULL; // Annotation action type string

                    CGPDFDictionaryGetString(actionDictionary, "D", &destName);




                    NSLog(@"link is %@ filename is:%@",CGPDFStringCopyTextString(destName),CGPDFStringCopyTextString(actionFile));

                }
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-28
    相关资源
    最近更新 更多