npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-smart-pdf-viewer

v1.5.1

Published

A lightweight, versatile React component to render PDF files into high-quality HTML5 Canvases, with an extensible plugin system for **Word (.doc/.docx)** and **Excel (.xls/.xlsx)** support.

Readme

📄 react-smart-pdf-viewer

A lightweight, versatile React component to render PDF files into high-quality HTML5 Canvases, with an extensible plugin system for Word (.doc/.docx) and Excel (.xls/.xlsx) support.


📦 Installation

npm install react-smart-pdf-viewer

⚙️ Usage

Basic Example (PDF)

import ReactSmartPdfViewer from 'react-smart-pdf-viewer';

function App() {
  return (
    <ReactSmartPdfViewer
      fileUrl="https://example.com/sample.pdf"
      viewMode="viewer"
    />
  );
}

Advanced Example (Excel & Doc Support)

To support spreadsheet and document, import and pass the corresponding plugins.

import ReactSmartPdfViewer from 'react-smart-pdf-viewer';
import { excelRenderer, docRenderer } from 'react-smart-pdf-viewer/plugins';

function App() {
  return (
    <ReactSmartPdfViewer
      fileUrl="https://example.com/data.xlsx"
      renderPlugins={[excelRenderer, docRenderer]}
    />
  );
}

🛠 Props API

| Property | Type | Default | Description | | --- | --- | --- | --- | | fileUrl | string | Required | The URL, Blob, or Base64 string of the file. | | renderPlugins | Array | [] | List of plugins to handle non-PDF formats (e.g., excelRenderer). | | nativeView | boolean | false | If false, the component uses plugins to render files. If true, it defaults to the browser's native PDF viewer. | | noRecordMessage | string | 'No Record Found' | Message to display when no file is available. | | viewMode | 'canvas' | 'viewer' | 'canvas' | 'canvas' for a vertical list; 'viewer' for a UI with a toolbar. | | scale | number | 1.5 | The zoom level/scale. (it works when nativeView is false) | | maxPages | number | 20 | Maximum pages or sheets to render. (it works when nativeView is false) | | onClose | Function | undefined | Callback triggered when the 'X' (cross) icon is clicked. (it works when nativeView is false) | | showDownload | boolean | false | Whether to display the download button. (it works when nativeView is false) | | trimSpace | boolean | false | Whether to trim whitespace from the PDF. (it works when nativeView is false) |

🧠 Behavior Overview

📊 Excel Support (.xls, .xlsx)

The component intercepts Excel files and transforms them into interactive, accessible HTML tables. Each sheet in the workbook is rendered as a separate section.

🎨 Rendering Modes

  • Canvas Mode (viewMode="canvas"): Best for embedding documents directly into a page layout.
  • Viewer Mode (viewMode="viewer"): Best for full-screen or modal previews. Includes a UI overlay with actions.

⚡ Performance

  • Lazy Loading: Plugins are only invoked when the file extension matches the plugin's capability.
  • Memory Safety: Use maxPages to ensure large spreadsheets or documents don't exceed browser memory limits.

🧩 Plugin Configuration

<ReactSmartPdfViewer
  fileUrl={myExcelBlob}
  renderPlugins={[excelRenderer]}
  downloadFileName="Monthly_Report.xlsx"
/>

📜 License

MIT