A basic out of the box PDF annotator component
npm install react-pdf-annotator-componentreact-pdf-annotator-component is a React library that provides a more flexible implementation of the sample app in react-pdf-highlighter-extended.
git clone https://github.com/NicholasGingrich/react-pdf-highlighter-extended/tree/main
npm install
npm run dev
`
Installation
npm install react-pdf-annotator-component --save
Usage
Here is the basic usage of the PDF annotator component. The component itself takes in three parameters:
1. The URL of the PDF you want to display
2. A reference to a function which will be called whenever the highlight data changes
3. Any exisitng highlight data to be rendered when the component is mounted
`
const SAMPLE_URL = "https://arxiv.org/pdf/2203.11115";
const TEST_HIGHLIGHTS = _testHighlights;
const updateHighlights: UpdateHighlights = (highlights, modfication) => {
console.log(Highlights for ${SAMPLE_URL} have been modfied.);
console.log(Modification type: ${modfication?.type});
console.log("Modfied highlight:", modfication?.highlight);
console.log("The latest version of highlights from the annotator", highlights)
};
const App = () => {
return (
url={SAMPLE_URL}
updateHighlights={updateHighlights}
savedHighlights={TEST_HIGHLIGHTS}
>
);
};
``