首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在objective C中使用PSPDFKIT (iOS)突出显示文本

如何在objective C中使用PSPDFKIT (iOS)突出显示文本
EN

Stack Overflow用户
提问于 2018-08-13 22:15:11
回答 1查看 128关注 0票数 0

我正在使用PSPDFKit进行pdf编辑,我无法在PDF中突出显示文本,请帮助了解如何在Objective C中使用PSPDFkit突出显示文本。

EN

回答 1

Stack Overflow用户

发布于 2018-08-14 01:05:52

您可以在iOS的PSPDFKit中以编程方式突出显示文本,如下所示:

代码语言:javascript
复制
PSPDFDocument *document = [PSCAssetLoader documentWithName:PSCAssetNameAnnualReport];
document.annotationSaveMode = PSPDFAnnotationSaveModeDisabled; // don't confuse other examples.

// Let's create a highlight for all occurrences of "bow" on the first 10 pages, in Orange.
NSUInteger annotationCounter = 0;
for (NSUInteger pageIndex = 0; pageIndex < 10; pageIndex++) {
    PSPDFTextParser *textParser = [document textParserForPageAtIndex:pageIndex];
    for (PSPDFWord *word in textParser.words) {
        if ([word.stringValue isEqualToString:@"bow"]) {
            PSPDFHighlightAnnotation *annotation = [PSPDFHighlightAnnotation textOverlayAnnotationWithGlyphs:[textParser glyphsInRange:word.range] pageRotation:[document pageInfoForPageAtIndex:pageIndex].rotation];
            annotation.color = UIColor.orangeColor;
            annotation.contents = [NSString stringWithFormat:@"This is an automatically created highlight #%tu", annotationCounter];
            annotation.pageIndex = pageIndex;
            [document addAnnotations:@[annotation] options:nil];
            annotationCounter++;
        }
    }
}

有关更多详细信息,请查看我们的catalog sample project中的PSCAddHighlightAnnotationProgrammaticallyExample

将来,请联系pspdfkit.com/ support /request,我们的支持团队将在那里为您提供帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51824442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档