allenai / allenai/pdf-component-library
Unable to render PDF using DocumentWrapper component
- 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) => (
))}
);
}
```

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á.