secure-pdf-viewer
v1.0.5
Published
A secure PDF viewer component for React with zoom controls and right-click protection
Downloads
1
Maintainers
Readme
Secure PDF Viewer
A secure PDF viewer component for React with zoom controls and right-click protection.
Features
- View PDF files from File objects or URLs
- Zoom in/out controls
- Page navigation
- Right-click protection
- Responsive design
- TypeScript support
Installation
npm install secure-pdf-viewerUsage
import React, { useState } from 'react';
import PDFViewer from 'secure-pdf-viewer';
function App() {
const [file, setFile] = useState<File | null>(null);
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
if (e.target.files && e.target.files[0]) {
setFile(e.target.files[0]);
}
};
return (
<div>
<input type="file" accept=".pdf" onChange={handleFileChange} />
{file && <PDFViewer file={file} />}
</div>
);
}
export default App;Using with a URL
import React from 'react';
import PDFViewer from 'secure-pdf-viewer';
function App() {
return (
<PDFViewer file="https://example.com/document.pdf" />
);
}Props
| Prop | Type | Default | Description | |------|------|---------|-------------| | file | File | string | required | PDF file object or URL | | scale | number | 1.0 | Initial zoom level | | onError | (error: Error) => void | undefined | Error handler callback |
Security Features
- Right-click protection
- Disabled context menu
- No download capability
- No print capability
License
MIT
