The error does to not happen when uploading the pdf to the example pdf viewer on the homepage https://react-pdf-viewer.dev/. We cannot find the source of the demo on the homepage, but perhaps one of the included plugins fixes the issue.
The error also goes away if I downgrade pdfjs-dist to 3.7.107, so it is something to do with compatibility with the pdfjs after 3.8.162
Steps to reproduce.
The following pdf was generated from a minimal docx file with a comment in (using gotenberg)
preview_doc with a comment.pdf
(original doc x file) doc with a comment.docx
We are attempting to preview this pdf within react-pdf-viewer
result
When trying to show it in react-pdf-viewer there is an error
Expected result
No error is thrown and the comment displays in the annotation layer
See code sandbox example here https://codesandbox.io/p/sandbox/react-pdf-viewer-error-dw38pg?file=%2Fsrc%2FApp.tsx%3A11%2C11
The error is being thrown here
https://github.com/react-pdf-viewer/react-pdf-viewer/blob/84804a8a27d481e6abcaeff4cc039b5f1d806e74/packages/core/src/annotations/Annotation.tsx#L48
Where
rect[0]
falls over becauserect
is null.The error does to not happen when uploading the pdf to the example pdf viewer on the homepage https://react-pdf-viewer.dev/. We cannot find the source of the demo on the homepage, but perhaps one of the included plugins fixes the issue.
The error also goes away if I downgrade
pdfjs-dist
to3.7.107
, so it is something to do with compatibility with the pdfjs after3.8.162
Any help appreciated.