Gathering detailed insights and metrics for react-file-previewer
Gathering detailed insights and metrics for react-file-previewer
Gathering detailed insights and metrics for react-file-previewer
Gathering detailed insights and metrics for react-file-previewer
npm install react-file-previewer
Typescript
Module System
Node Version
NPM Version
JavaScript (89.48%)
CSS (10.52%)
Total Downloads
345,649
Last Day
5
Last Week
1,117
Last Month
4,523
Last Year
68,815
27 Stars
100 Commits
19 Forks
4 Watching
38 Branches
5 Contributors
Minified
Minified + Gzipped
Latest Version
0.6.3
Package Id
react-file-previewer@0.6.3
Unpacked Size
176.48 kB
Size
36.70 kB
File Count
34
NPM Version
6.14.4
Node Version
10.20.1
Cumulative downloads
Total Downloads
Last day
-75%
5
Compared to previous day
Last week
-5.2%
1,117
Compared to previous week
Last month
-14.8%
4,523
Compared to previous month
Last year
-33.1%
68,815
Compared to previous year
8
1
24
A browser/device-agnostic file previewer for PDF and image file types built on top of React-PDF.
npm i react-file-previewer
This component supports URLs and base64 encoded data.
1import FilePreviewer from 'react-file-previewer'; 2 3export const App = () => ( 4 <div> 5 <h1>My App</h1> 6 <FilePreviewer file={{ 7 url: "https://cors-anywhere.herokuapp.com/http://africau.edu/images/default/sample.pdf"}} 8 /> 9 </div> 10);
1import FilePreviewer from 'react-file-previewer'; 2 3export const App = () => ( 4 <div> 5 <h1>My App</h1> 6 <FilePreviewer 7 file={{ 8 data: "<base64 string>", 9 mimeType: 'application/pdf', 10 name: 'sample.pdf' // for download 11 }} 12 /> 13 </div> 14);
1import { useState } from 'react'; 2import FilePreviewer from 'react-file-previewer'; 3 4const PDF1_URL = 5 'https://cors-anywhere.herokuapp.com/http://africau.edu/images/default/sample.pdf'; 6 7export const App = () => { 8 const [file, setFile] = useState({ url: PDF1_URL }); 9 10 const onFileChange = event => { 11 const fileReader = new window.FileReader(); 12 const file = event.target.files[0]; 13 14 fileReader.onload = fileLoad => { 15 const { result } = fileLoad.target; 16 setFile({ url: result }); 17 }; 18 19 fileReader.readAsDataURL(file); 20 }; 21 22 return ( 23 <div> 24 <h1>My App</h1> 25 <input type="file" onChange={onFileChange} /> 26 <FilePreviewer 27 file={file} 28 /> 29 </div> 30 ) 31};
This will render the first page of the file as a thumbnail. It takes the exact same props as the default export
FilePreviewer
.
1import {FilePreviewerThumbnail} from 'react-file-previewer'; 2 3export const App = () => ( 4 <div> 5 <h1>My App</h1> 6 <FilePreviewerThumbnail 7 file={{ 8 data: "<base64 string>", 9 mimeType: 'application/pdf', 10 name: 'sample.pdf' // for download 11 }} 12 /> 13 -or- 14 <FilePreviewerThumbnail file={{ 15 url: "https://cors-anywhere.herokuapp.com/http://africau.edu/images/default/sample.pdf"}} 16 /> 17 </div> 18);
Prop name | Type | Description |
---|---|---|
file | object | Refer to file object |
onClick | function | Event handler for when viewer is clicked |
hideControls | bool | If 'true', viewer won't display the zoom, page up/down, and fit-to-screen controls |
Prop name | Type | Description |
---|---|---|
file | object | Refer to file object |
onClick | function | Event handler for when viewer is clicked |
hideControls | bool | If 'true', viewer won't display the zoom, page up/down, and fit-to-screen controls |
style | object | Any css style overrides |
Prop name | Type | Description |
---|---|---|
url | string | This can be used by itself with no other prop |
data | string | Base64 encoded string of file. If used, mimeType must also be provided |
mimeType | string | Type of the file |
name | string | Used to specify the filename when download button is clicked |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 9/14 approved changesets -- score normalized to 6
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
29 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More@react-league/react-file-previewer
A browser/device-agnostic file previewer for PDF and image file types built on top of React-PDF.
@dankom/react-file-previewer
A browser/device-agnostic file previewer for PDF and image file types built on top of React-PDF.
react-file-previewer-v2
A browser/device-agnostic file previewer for PDF and image file types built on top of React-PDF.
react-office-previewer
A React component to preview document of 'pdf,xls,xlsx,docx', which can automatically identify file types.