Commit 80404d4f authored by Randall Leeds's avatar Randall Leeds

PDF page offset caching

parent 043e656a
...@@ -27,12 +27,18 @@ getPage = (pageIndex) -> ...@@ -27,12 +27,18 @@ getPage = (pageIndex) ->
getPageTextContent = (pageIndex) -> getPageTextContent = (pageIndex) ->
return PDFViewerApplication.pdfViewer.getPageTextContent(pageIndex) return PDFViewerApplication.pdfViewer.getPageTextContent(pageIndex)
# XXX: This will break if the viewer changes documents
_pageOffsetCache = {}
getPageOffset = (pageIndex) -> getPageOffset = (pageIndex) ->
index = -1 index = -1
if _pageOffsetCache[pageIndex]?
return Promise.resolve(_pageOffsetCache[pageIndex])
next = (offset) -> next = (offset) ->
if ++index is pageIndex if ++index is pageIndex
_pageOffsetCache[pageIndex] = offset
return Promise.resolve(offset) return Promise.resolve(offset)
return getPageTextContent(index) return getPageTextContent(index)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment