Быстрая прокрутка в pdf.document - PullRequest
       8

Быстрая прокрутка в pdf.document

0 голосов
/ 11 сентября 2018

У меня есть PDF-документ внутри pdfView с использованием PDFKit

    var urldocs = getDocumentsDirectoryURL()

    urldocs.appendPathComponent("test.pdf")


    let pdfDocument = PDFDocument(url: urldocs)

    pdfView.displayMode = .singlePageContinuous
    pdfView.autoScales = true

    pdfView.document = pdfDocument

Как настроить pdfView для отображения определенной области внедренного документа!? В ScrollView можно перейти ScrollView.contentOffset = CGPoint ... Я не могу понять, как это сделать в pdfView

Спасибо!

1 Ответ

0 голосов
/ 11 сентября 2018

Вы можете перейти к выбору, найденному с помощью текстового поиска в документе:

let selections = pdfView.document!.findString("have a pdf document", withOptions: [NSString.CompareOptions.literal])
guard let newSelection = selections.first else {
    fatalError("selection not found.")
}

update(pdfView) {
    $0.setCurrentSelection(newSelection, animate: true)
    $0.scrollSelectionToVisible(nil)
}

Или вы можете перейти к cgRect на странице:

let pdfPage = pdfView.document!.page(at: 0)!
pdfView.go(to: cgRect, on: pdfPage)
...