open plugin
This plugin allows user to open a local file.
import openPlugin from '@react-pdf-viewer/open';
import '@react-pdf-viewer/open/styles.css';
const openPluginInstance = openPlugin();
const { OpenButton } = openPluginInstance;
return (
<>
<OpenButton />
<Viewer
plugins={[
openPluginInstance,
]}
>
</>
);
Use a custom input
import openPlugin from '@react-pdf-viewer/open';
const openPluginInstance = openPlugin();
const { OpenButton } = openPluginInstance;
return (
<>
<OpenButton>
{
(props) => (
// Your custom input here
<input
multiple={false}
type='file'
title=''
onChange={props.onClick}
/>
)
}
</OpenButton>
<Viewer
plugins={[
openPluginInstance,
]}
>
</>
);