Bug: TOC redirects to page instead of the sections
Closed this issue · 4 comments
Progress note:
Currently, it cannot be solved simply by using the Outline component provided by react-pdf
. To scroll to a specific title location, a paper needs dest
information of the title, but the Outline component only passes pageNumber
and pageIndex
arguments to click handler functions. There is an ongoing PR for this issue, but it has been created for 5 months and the author hasn't merged it for some reason. I am gonna create our own Outline components to achieve this feature.
Reference note:
-
PDF coordinate systems: https://www.pdfscripting.com/public/PDF-Page-Coordinates.cfm
-
Scroll functions implemented by Mozilla:
https://github.com/mozilla/pdf.js/blob/d3e1d7090ac6f582d0c277e8768ac63bbbaa1134/web/pdf_link_service.js#L176
https://github.com/mozilla/pdf.js/blob/d3e1d7090ac6f582d0c277e8768ac63bbbaa1134/web/base_viewer.js#L1113
https://github.com/mozilla/pdf.js/blob/d3e1d7090ac6f582d0c277e8768ac63bbbaa1134/web/ui_utils.js#L103 -
Outline component in react-pdf: https://github.com/wojtekmaj/react-pdf/blame/main/src/Outline.jsx
adding unit tests