1

您好我正在寻找使用 PSPDFKit 框架及其全文搜索功能来查找文档。我在 Cordova/Phonegap 应用程序中执行此操作,因此我想将搜索结果数据返回到我的 Javascript 应用程序。

我遇到了返回文档名称/路径而不是文档 UID 的问题。是否可以将 documentUID 转换为 PSPDFDocument

[library documentUIDsMatchingString:searchString options:nil completionHandler:
 ^(NSString* searchString, NSDictionary<NSString *,NSIndexSet *> * resultSet) {
              for (NSString *UID in resultSet) {
                  NSIndexSet *indexSet = resultSet[UID];
                  NSLog(@"Found the following matches in document %@: %@", UID, indexSet);
              }
 }

上面的 UID 看起来像这样:

样本pdf_ffa29462f17ca27908ab82bdd3d575a7

这并不意味着太多,有一个名为 -metadataForUID 的方法,但在使用上述字符串调用时总是返回 null 。

4

1 回答 1

1

我查看了 PSPDFKit 文档,当您查看 PSPDFDocument ( https://pspdfkit.com/guides/ios/current/getting-started/using-pspdfdocument/ ) 时,他们提到构建自己的方式来存储 documentUID 和 PSPDFDocument。

在索引过程中,您将获得文档的路径和 documentUID。所以我正在创建自己的数据结构(即 NSDictionary )并将其存储在 NSCache 中,就像文档中推荐的那样。

在我的情况下它工作得很好。每次启动应用程序或添加新文档时,都会执行索引过程。好消息是,PSPDFKit 不会两次索引文档,所以我没有性能问题。

我用 PSPDFKit 6.3 测试过

于 2017-01-09T14:12:58.230 回答