【问题标题】:Highlight and Ink Annotations in PDFKit iOS 11PDFKit iOS 11 中的高亮和墨迹注释
【发布时间】:2018-04-06 10:00:21
【问题描述】:

我正在开发 iOS 11 swift 中的 PDF 阅读器应用程序。我需要使用墨水注释突出显示文本和涂鸦。我一直在使用 iOS PDFKit 框架,但我找不到这些的示例实现。

【问题讨论】:

标签: ios swift pdf annotations ios11


【解决方案1】:

你可以使用PdfKit Annotation:(在执行这个方法之前你已经选择了一些文本)

PDFSelection *select = [[PDFSelection alloc] initWithDocument:_pdfView.document];
[select addSelection:_pdfView.currentSelection];
NSArray *arrayByLine = _pdfView.currentSelection.selectionsByLine;
for (PDFSelection *select in arrayByLine) {
    PDFAnnotation *annotation = [[PDFAnnotation alloc] initWithBounds:[select boundsForPage:_pdfView.currentPage] forType:PDFAnnotationSubtypeHighlight withProperties:nil];
    annotation.color =[UIColor yellowColor];
    [_pdfView.currentPage addAnnotation:annotation];
}

你可以使用很多注释:

PDFAnnotationSubtypeUnderline
PDFAnnotationSubtypeStrikeOut
PDFAnnotationSubtypeSquare
PDFAnnotationSubtypeCircle
PDFAnnotationSubtypeHighlight
.......

快速用户检查this

【讨论】:

    【解决方案2】:

    基本上你需要检查PDFKit Framework!

    在 PDFDocument 类中你会发现下面的方法

    open func findString(_ string: String, withOptions options: NSString.CompareOptions = []) -> [PDFSelection]
    

    此方法将返回您的 PDFSelection 数组,您可以使用以下 PDFView 类的方法将其直接分配给 PDFView

    @available(iOS 11.0, *)
    open var highlightedSelections: [PDFSelection]?
    

    【讨论】:

      猜你喜欢
      • 2018-04-18
      • 1970-01-01
      • 1970-01-01
      • 2018-08-06
      • 2020-02-25
      • 1970-01-01
      • 2018-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多