Download in React Pdfviewer component

16 May 20232 minutes to read

The PDF Viewer supports downloading the loaded PDF file. You can enable/disable the download using the following code snippet.

Alt text

You can invoke download action using following code snippet.,

import * as ReactDOM from 'react-dom';
import * as React from 'react';
import { PdfViewerComponent, Toolbar, Magnification, Navigation, LinkAnnotation, BookmarkView,
         ThumbnailView, Print, TextSelection, Annotation, TextSearch, Inject } from '@syncfusion/ej2-react-pdfviewer';
let pdfviewer;

function App() {
  function downloadClicked() {
    var viewer = document.getElementById('container').ej2_instances[0];;
  return (<div>
    <div className='control-section'>
     {/* Render the PDF Viewer */}
     <button onClick={downloadClicked}>Download</button>
        ref={(scope) => { pdfviewer = scope; }}
        style={{ 'height': '640px' }}>
              <Inject services={[ Toolbar, Magnification, Navigation, LinkAnnotation, Annotation, 
                                  BookmarkView, ThumbnailView, Print, TextSelection, TextSearch]} />
const root = ReactDOM.createRoot(document.getElementById('sample'));
root.render(<App />);

See also