Skip to content

Commit db7a1eb

Browse files
committed
Add thumbnail width option examples
1 parent 1fd7e4a commit db7a1eb

File tree

3 files changed

+66
-1
lines changed

3 files changed

+66
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ This repository contains the sources of all React PDF Viewer [examples](https://
66

77
These examples work with
88

9-
* `@react-pdf-viewer` 3.3.0
9+
* `@react-pdf-viewer` 3.3.1
1010
* `pdfjs-dist` 2.13.216
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from 'react';
2+
import { Viewer } from '@react-pdf-viewer/core';
3+
import { defaultLayoutPlugin } from '@react-pdf-viewer/default-layout';
4+
5+
import '@react-pdf-viewer/core/lib/styles/index.css';
6+
import '@react-pdf-viewer/default-layout/lib/styles/index.css';
7+
8+
interface CustomWidthDefaultLayoutExampleProps {
9+
fileUrl: string;
10+
}
11+
12+
const CustomWidthDefaultLayoutExample: React.FC<CustomWidthDefaultLayoutExampleProps> = ({ fileUrl }) => {
13+
const defaultLayoutPluginInstance = defaultLayoutPlugin({
14+
thumbnailPlugin: {
15+
thumbnailWidth: 150,
16+
},
17+
});
18+
19+
return <Viewer fileUrl={fileUrl} plugins={[defaultLayoutPluginInstance]} />;
20+
};
21+
22+
export default CustomWidthDefaultLayoutExample;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as React from 'react';
2+
import { Viewer } from '@react-pdf-viewer/core';
3+
import { thumbnailPlugin } from '@react-pdf-viewer/thumbnail';
4+
5+
import '@react-pdf-viewer/core/lib/styles/index.css';
6+
import '@react-pdf-viewer/thumbnail/lib/styles/index.css';
7+
8+
interface CustomWidthExampleProps {
9+
fileUrl: string;
10+
}
11+
12+
const CustomWidthExample: React.FC<CustomWidthExampleProps> = ({ fileUrl }) => {
13+
const thumbnailPluginInstance = thumbnailPlugin({
14+
thumbnailWidth: 150,
15+
});
16+
const { Thumbnails } = thumbnailPluginInstance;
17+
18+
return (
19+
<div
20+
className="rpv-core__viewer"
21+
style={{
22+
border: '1px solid rgba(0, 0, 0, 0.3)',
23+
display: 'flex',
24+
height: '100%',
25+
}}
26+
>
27+
<div
28+
style={{
29+
borderRight: '1px solid rgba(0, 0, 0, 0.3)',
30+
overflow: 'auto',
31+
width: '30%',
32+
}}
33+
>
34+
<Thumbnails />
35+
</div>
36+
<div style={{ flex: 1 }}>
37+
<Viewer fileUrl={fileUrl} plugins={[thumbnailPluginInstance]} />
38+
</div>
39+
</div>
40+
);
41+
};
42+
43+
export default CustomWidthExample;

0 commit comments

Comments
 (0)