-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathuse-pdf-reader.tsx
More file actions
45 lines (40 loc) · 961 Bytes
/
use-pdf-reader.tsx
File metadata and controls
45 lines (40 loc) · 961 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import React from 'react';
import { usePdfReader } from '../src';
import { WebpubManifest } from '../src/types';
import Header from '../src/ui/Header';
type PDFReaderProps = {
webpubManifestUrl: string;
manifest: WebpubManifest;
proxyUrl: string | undefined;
pdfWorkerSrc: string;
};
/**
* This sample shows setting how to use the usePdfReader hook
* to render PDFs. Use it when you know you're _not_ going to be
* opening EPUBs.
*/
const UsePdfReader: React.FC<PDFReaderProps> = ({
webpubManifestUrl,
manifest,
proxyUrl,
pdfWorkerSrc,
}) => {
const reader = usePdfReader({
webpubManifestUrl,
manifest,
proxyUrl,
pdfWorkerSrc,
});
const containerRef = React.useRef<HTMLDivElement>(null);
if (!reader || !reader.type) {
return null;
}
const { content } = reader;
return (
<div>
<Header {...reader} containerRef={containerRef} />
{content}
</div>
);
};
export default UsePdfReader;