Skip to content

Make PDF anchoring robust to minor differences between extracted text and text layer #4331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
robertknight opened this issue Mar 18, 2022 · 0 comments · Fixed by #4355
Closed

Comments

@robertknight
Copy link
Member

Anchoring in PDFs currently relies on text extracted from the PDF via PDF.js's PDFPage.getTextContent API to exactly match the textContent property of the hidden text layer element that PDF.js creates. This complicates PDF.js upgrades because we have seen several times minor differences in output (eg. in which whitespace is included). See hypothesis/browser-extension#799 (comment) for example.

I think it will probably make sense to instead make the client's anchoring robust to such differences, even though it will make anchoring a bit more expensive.

To do this we will need to rework the anchorByPosition function in src/annotator/anchoring/pdf.js to remove the assumption that text positions in extracted text exactly match the text layer, or at least the whitespace elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant