🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more

@react-pdf-viewer/core

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
r

@react-pdf-viewer/core

A React component to view a PDF document

3.12.0
latest
100

Supply Chain Security

100

Vulnerability

71

Quality

77

Maintenance

100

License

Version published
Weekly downloads
252K
9.12%
Maintainers
1
Weekly downloads
 
Created
Issues
360

What is @react-pdf-viewer/core?

@react-pdf-viewer/core is a React library that provides a set of components and hooks to easily integrate PDF viewing capabilities into your React applications. It offers a customizable and extensible way to display PDF documents, navigate through pages, zoom in and out, and more.

What are @react-pdf-viewer/core's main functionalities?

Basic PDF Viewer

This code demonstrates how to set up a basic PDF viewer using the @react-pdf-viewer/core package. It includes the necessary imports and sets up the Worker and Viewer components to display a PDF file.

import { Worker, Viewer } from '@react-pdf-viewer/core';
import '@react-pdf-viewer/core/lib/styles/index.css';

const App = () => (
  <div>
    <Worker workerUrl={`https://unpkg.com/pdfjs-dist@2.6.347/build/pdf.worker.min.js`}>
      <Viewer fileUrl='/path/to/your/pdf-file.pdf' />
    </Worker>
  </div>
);

Custom Toolbar

This code demonstrates how to create a custom toolbar for the PDF viewer. It uses the Toolbar component and slots to include buttons for toggling the sidebar, navigating pages, and zooming in and out.

import { Worker, Viewer, ToolbarSlot, Toolbar } from '@react-pdf-viewer/core';
import '@react-pdf-viewer/core/lib/styles/index.css';

const App = () => (
  <div>
    <Worker workerUrl={`https://unpkg.com/pdfjs-dist@2.6.347/build/pdf.worker.min.js`}>
      <Toolbar>
        {(slots: ToolbarSlot) => (
          <>
            {slots.toggleSidebarButton}
            {slots.previousPageButton}
            {slots.nextPageButton}
            {slots.zoomOutButton}
            {slots.zoomInButton}
          </>
        )}
      </Toolbar>
      <Viewer fileUrl='/path/to/your/pdf-file.pdf' />
    </Worker>
  </div>
);

Thumbnail View

This code demonstrates how to add a thumbnail view to the PDF viewer using the ThumbnailPlugin. It initializes the plugin and includes it in the Viewer component's plugins array.

import { Worker, Viewer, ThumbnailPlugin } from '@react-pdf-viewer/core';
import '@react-pdf-viewer/core/lib/styles/index.css';

const thumbnailPluginInstance = ThumbnailPlugin();

const App = () => (
  <div>
    <Worker workerUrl={`https://unpkg.com/pdfjs-dist@2.6.347/build/pdf.worker.min.js`}>
      <Viewer fileUrl='/path/to/your/pdf-file.pdf' plugins={[thumbnailPluginInstance]} />
    </Worker>
  </div>
);

Other packages similar to @react-pdf-viewer/core

FAQs

Package last updated on 21 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts