-
Notifications
You must be signed in to change notification settings - Fork 6
/
use-pdf-reader.tsx
50 lines (45 loc) · 1.04 KB
/
use-pdf-reader.tsx
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
46
47
48
49
50
import React from 'react';
import { usePdfReader } from '../src';
import { WebpubManifest } from '../src/types';
import Footer from '../src/ui/Footer';
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;
}
return (
<div>
<Header
{...reader}
headerLeft={<a href="/">Back</a>}
containerRef={containerRef}
/>
{reader.content}
<Footer {...reader} />
</div>
);
};
export default UsePdfReader;