I am using PSPDFKit for pdf edit,I am unable to highlight text in PDF please help to know how to highlight text using PSPDFkit in Objective C.
Asked
Active
Viewed 192 times
0
-
write mail to PSPDFKit support team they will help you in this issue – Vinodh Aug 13 '18 at 14:53
1 Answers
1
You can highlight text programmatically in PSPDFKit for iOS, like so:
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++;
}
}
}
For more details, take a look at PSCAddHighlightAnnotationProgrammaticallyExample
from our catalog sample project.
In the future, please reach out to pspdfkit.com/support/request and our support team will help you in there.

Rad Azzouz
- 59
- 5