Package Exports
- @sandeepmvn/react-pdf-annotator-v2
- @sandeepmvn/react-pdf-annotator-v2/dist/style.css
Readme
React PDF Annotator v2
A feature-rich, fully customizable PDF viewer and annotator component for React applications. Built with TypeScript, this package provides comprehensive annotation tools including drawing, highlighting, text, shapes, stamps, and digital signatures.
⨠Features
- đ PDF Viewing: Smooth PDF rendering with zoom controls and page navigation
- đ¨ Drawing Tools: Pen and highlighter with customizable colors and stroke widths
- âī¸ Text Annotation: Add text boxes with custom colors and font sizes
- đ Shapes: Rectangle and circle annotations
- đī¸ Text Markup: Underline, strikethrough, and squiggly line tools
- đ Stamps: Pre-defined stamps (Approved, Confidential, etc.)
- âī¸ Digital Signatures: Draw and add signatures and initials
- âŠī¸ Undo/Redo: Full history management for all annotations
- đž Export: Download annotated PDFs with all annotations embedded
- đ¯ TypeScript: Fully typed for better development experience
đĻ Installation
npm install react-pdf-annotator-v2or
yarn add react-pdf-annotator-v2or
pnpm add react-pdf-annotator-v2đ Quick Start
import React from 'react';
import { PdfViewer } from 'react-pdf-annotator-v2';
import 'react-pdf-annotator-v2/dist/style.css';
function App() {
return (
<div style={{ height: '100vh' }}>
<PdfViewer
fileUrl="https://example.com/sample.pdf"
fileName="sample.pdf"
/>
</div>
);
}
export default App;đ API Reference
PdfViewer Props
| Prop | Type | Required | Description |
|---|---|---|---|
fileUrl |
string |
Yes | URL of the PDF file to display |
fileName |
string |
Yes | Name of the PDF file (used for downloads) |
Available Exports
// Main Component
import { PdfViewer } from 'react-pdf-annotator-v2';
// Sub-components (for custom layouts)
import {
PdfPage,
Toolbar,
AnnotationLayer,
SignatureModal
} from 'react-pdf-annotator-v2';
// Hooks
import { useAnnotationHistory } from 'react-pdf-annotator-v2';
// Types
import type {
AnnotationTool,
Annotation,
PenAnnotation,
TextAnnotation,
// ... other types
} from 'react-pdf-annotator-v2';
// Constants
import {
DEFAULT_COLOR,
DEFAULT_STROKE_WIDTH,
COLORS
} from 'react-pdf-annotator-v2';đ¨ Customization
The package includes pre-built styles that use Tailwind CSS. The CSS is already bundled, so you don't need Tailwind CSS in your project.
Simply import the CSS file:
import 'react-pdf-annotator-v2/dist/style.css';The styles will work out of the box without any additional configuration.
đ ī¸ Advanced Usage
Using the Annotation Hook
import { useAnnotationHistory } from 'react-pdf-annotator-v2';
function CustomAnnotator() {
const {
annotations,
addAnnotation,
undo,
redo,
canUndo,
canRedo
} = useAnnotationHistory();
// Your custom implementation
}TypeScript Support
The package is fully typed. Import types as needed:
import type {
AnnotationTool,
Annotation,
PenAnnotation
} from 'react-pdf-annotator-v2';
const tool: AnnotationTool = 'PEN';
const annotation: Annotation = {
// ...
};đ Requirements
- React 18.0.0 or higher
- React DOM 18.0.0 or higher
đ§ Peer Dependencies
This package requires the following peer dependencies:
{
"react": "^18.0.0",
"react-dom": "^18.0.0"
}Make sure these are installed in your project.
đ License
MIT
đ¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
đŽ Issues
If you encounter any issues or have suggestions, please file an issue on the GitHub repository.
đ Acknowledgments
Built with:
đ Documentation
For more detailed documentation and examples, visit the documentation site.
Made with â¤ī¸ for the React community