我正在使用git hub中的以下project进行PDF渲染,但是我需要为用户提供在PDF中加下划线并突出显示文本的功能
但是当我尝试使用Web视图进行PDF渲染时,我能够突出显示文本而不是在其下划线
我也尝试过使用CGPDFDocument进行PDF渲染,但是我无法使用该功能进行文本突出显示或下划线文本
我需要在PDF渲染中实现文本下划线和突出显示文本,也要提取文本
任何帮助将不胜感激
谢谢
let selections = pdfView.currentSelection?.selectionsByLine()
guard let page = selections?.first?.pages.first else { return }
selections?.forEach({ selection in
let highlight = PDFAnnotation(bounds: selection.bounds(for: page), forType: .underline, withProperties: nil)
highlight.endLineStyle = .square
highlight.color = UIColor.black.withAlphaComponent(1)
page.addAnnotation(highlight)
pdfView.document?.write(toFile: "PDF File Path")
})
您也可以将Type更改为所需的类型。例如,突出显示,下划线,墨水等。