diff --git a/package.json b/package.json index 3fadd7d..00fa4b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@omarefg/react-file-preview", - "version": "0.1.15", + "version": "0.1.17", "description": "Component to render and preview some kind of documents", "main": "lib/index.js", "private": false, diff --git a/src/components/Pdf.jsx b/src/components/Pdf.jsx index f191162..b50fa76 100644 --- a/src/components/Pdf.jsx +++ b/src/components/Pdf.jsx @@ -6,7 +6,7 @@ import { ErrorBoundary } from './ErrorBoundary' import { PdfMenu } from './PdfMenu' import { INCREASE_PERCENTAGE } from '../utils' -export const Pdf = ({ path, ErrorComponent, onError, showPdfMenu, style, onPrint }) => { +export const Pdf = ({ path, ErrorComponent, onError, showPdfMenu, style, onPrint, allowPrint, allowDownload, onDownload }) => { const { state, container, @@ -39,6 +39,10 @@ export const Pdf = ({ path, ErrorComponent, onError, showPdfMenu, style, onPrint print={print} page={page} onPrint={onPrint} + pdf={pdf} + allowDownload={allowDownload} + allowPrint={allowPrint} + onDownload={onDownload} /> )} {!pdf && ( diff --git a/src/components/PdfMenu.jsx b/src/components/PdfMenu.jsx index da292fd..abef52d 100644 --- a/src/components/PdfMenu.jsx +++ b/src/components/PdfMenu.jsx @@ -7,6 +7,7 @@ import { faChevronLeft, faChevronRight, faPrint, + faDownload, } from '@fortawesome/free-solid-svg-icons' import styles from '../styles/PdfMenu.module.scss' @@ -21,8 +22,14 @@ export const PdfMenu = props => { print, page, onPrint, + pdf, + allowPrint, + allowDownload, + onDownload, } = props + const printHandler = () => (onPrint ? onPrint(pdf) : print()) + return (
- + {allowPrint && ( + + )} + {allowDownload && ( + + )}
) } diff --git a/src/components/Viewer.jsx b/src/components/Viewer.jsx index 46486dd..0842c9d 100644 --- a/src/components/Viewer.jsx +++ b/src/components/Viewer.jsx @@ -26,6 +26,9 @@ export const Viewer = props => { onPrint, isLoading, supportXlsx, + allowDownload, + allowPrint, + onDownload, } = props if (isLoading) { @@ -101,6 +104,9 @@ export const Viewer = props => { showPdfMenu={showPdfMenu} style={style} onPrint={onPrint} + allowDownload={allowDownload} + allowPrint={allowPrint} + onDownload={onDownload} /> ) } @@ -167,6 +173,9 @@ Viewer.propTypes = { className: string, isLoading: bool, supportXlsx: bool, + allowPrint: bool, + allowDownload: bool, + onDownload: func, } Viewer.defaultProps = { @@ -182,4 +191,7 @@ Viewer.defaultProps = { className: null, isLoading: false, supportXlsx: false, + allowPrint: false, + allowDownload: false, + onDownload: null, }