allenai / allenai/pdf-component-library

Unable to render PDF using DocumentWrapper component

Đang mở
#207 1 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
TypeScript
Star
93
Fork
15
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

Installed AllenAI pdf-component-library using `npm install @allenai/pdf-components` . Used the code from [Reader](https://github.com/allenai/pdf-component-library/blob/main/ui/demo/components/Reader.tsx) component. Unable to render Pdf documents. Errors : `Unable to call method(). The context Provider may not be setup correctly.`. Screenshot of console log below.

Relevant code snippets below :

package.json:
```
"dependencies": {
"@allenai/pdf-components": "^1.0.1",
```

src/components/Pdf.js:
```
import React, { useEffect, useRef, useState } from "react";
import {
DocumentContext,
DocumentWrapper,
Overlay,
PageWrapper,
RENDER_TYPE,
ScrollContext,
} from '@allenai/pdf-components';

export default function Pdf(props) {
const { pageDimensions, numPages } = React.useContext(DocumentContext);
const { setScrollRoot } = React.useContext(ScrollContext);

React.useEffect(() => {
setScrollRoot(null);
}, []);

// ref for the div in which the Document component renders
const pdfContentRef = React.createRef();

// ref for the scrollable region where the pages are rendered
const pdfScrollableRef = React.createRef();

const samplePdfUrl = 'https://arxiv.org/pdf/2112.07873.pdf';

return (





{Array.from({ length: numPages }).map((_, i) => (



))}




);
}
```

![Screenshot 2023-11-27 at 10 46 05 AM](https://github.com/allenai/pdf-component-library/assets/22112888/11ed82d9-7dc4-48d8-986e-44026d9de381)

Any help is appreciated.

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.