PDFKit高亮注释:quadrilateralPoints [英] PDFKit Highlight Annotation: quadrilateralPoints

查看:90
本文介绍了PDFKit高亮注释:quadrilateralPoints的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过使用PDFKit将突出显示注释添加到pdf文件中.我使用下面的代码将其添加.

I want to add highlight annotation into pdf file by using PDFKit. And I use this below code to add it.

PDFPage* page = [self.pdfView.document pageAtIndex:0];
PDFAnnotation* annotation = [[PDFAnnotation alloc] initWithBounds:CGRectMake(206, 600, 60, 59) forType:PDFAnnotationSubtypeHighlight withProperties:nil];
annotation.color = UIColor.blueColor;
[page addAnnotation:annotation];

但是它只是突出显示一个矩形,我想突出显示多行文本.我发现了一个问题/答案苹果PDFKit上的错误突出显示注释

But it just highlight one rectangle, I want to highlight multiple lines text. I have found one question/answer Wrong highlight annotation on apple PDFKit

但这不是我想要的,它将添加许多突出显示注释,我只想添加一个注释.而且我知道键值QuadPoints可以做到这一点.但是,当我添加以下代码时,它甚至无法渲染注释.

But it is not what I want, it will add many highlight annotations, I just want to add one annotation. And I learn that the key-value QuadPoints can do this. But it doesn't work when I add the below code, even can't render the annotation.

NSArray<NSValue *> *quadrilateralPoints = [[NSArray alloc] initWithObjects:
                                           [NSValue valueWithCGPoint:CGPointMake(206.0f, 659.0f)],
                                           [NSValue valueWithCGPoint:CGPointMake(266.0f, 659.0f)],
                                           [NSValue valueWithCGPoint:CGPointMake(206.0f, 600.0f)],
                                           [NSValue valueWithCGPoint:CGPointMake(266.0f, 600.0f)],
                                           nil];

annotation.quadrilateralPoints = quadrilateralPoints;

所以现在我想知道如何实现它?或如何使用quadrilateralPoints?

So now I want to know how to implement it? or how to use quadrilateralPoints ?

推荐答案

我找到了答案: 下面的代码有效

I have found the answer: below code works

NSArray<NSValue *> *quadrilateralPoints = [[NSArray alloc] initWithObjects:
                                       [NSValue valueWithCGPoint:CGPointMake(206.0 - 206, 659.0 - 600)],
                                       [NSValue valueWithCGPoint:CGPointMake(266.0 - 206, 659.0 - 600)],
                                       [NSValue valueWithCGPoint:CGPointMake(206.0 - 206, 600.0 - 600)],
                                       [NSValue valueWithCGPoint:CGPointMake(266.0 - 206, 600.0 - 600)],
                                       nil];

annotation.quadrilateralPoints = quadrilateralPoints;

因为它基于原点边界

这篇关于PDFKit高亮注释:quadrilateralPoints的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆