关于如何使用pdfkit注释(突出显示,注释等)并将结果快速保存,是否有任何有用的演练。
我找不到有用的人。
谢谢
答案 0 :(得分:0)
对于Highlight,您可以使用以下代码:
let selections = self.pdfview.currentSelection?.selectionsByLine()
// Simple scenario, assuming your pdf is single-page.
guard let page = selections?.first?.pages.first else { return }
if selections == nil {
}else {
selections?.forEach({ selection in
let highlight = PDFAnnotation(bounds: selection.bounds(for: page), forType: .highlight, withProperties: nil)
// highlight.endLineStyle = .square
highlight.color = UIColor(red:0.49, green:0.99, blue:0.00, alpha:1.0).withAlphaComponent(0.5)
page.addAnnotation(highlight)
})
}
保存:
self.pdfdocument?.write(to: urlPath!)