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

@meshesha/officetohtml

v2.0.0

Published

View Office documents (docx, pptx, xlsx/ods/csv), PDF files and images in the browser with one Office-like viewer. Framework-agnostic, no jQuery.

Readme

OfficeToHtml

MIT License npm

View Word, PowerPoint, Excel, PDF, image and text files in the browser – with one Office-like viewer, no server and no jQuery.

import { OfficeViewer } from "@meshesha/officetohtml";

const viewer = new OfficeViewer("#viewer", { theme: "auto" });
await viewer.load("report.docx"); // URL, File, Blob, ArrayBuffer or Uint8Array

Live demo · Documentation · Changelog · Migrating from v1

| | | |---|---| | Word .docx | paper-like pages, real image sizes, footnotes, RTL paragraphs, zoom, search, print – mammoth.js | | PowerPoint .pptx | slide list or slideshow, autoplay, keyboard, full screen, charts – PPTXjs v2 | | Spreadsheets .xlsx .xls .xlsb .ods .csv .tsv .numbers … | Excel-like grid, sheet tabs, formula bar, merged cells, widths, hidden rows, search – SheetJS + Handsontable (or a built-in table) | | PDF | selectable text, search, thumbnails, outline, rotation, hand tool, presentation mode with swipe & pinch zoom, password dialog – PDF.js | | Images .png .jpg .gif .webp .avif .svg .bmp .ico | zoom to cursor, pinch, pan, rotate, flip, fit / 100%, transparency grid | | Text .txt .md .json .xml and source code | line numbers, wrapping, JSON pretty-print, search | | Everywhere | toolbar, status bar, light/dark theme, full screen, print only the document, download, drag & drop, keyboard shortcuts, 8 UI languages with RTL, events, TypeScript types | | Frameworks | vanilla JS · React · Vue 3 · Angular · jQuery (v1-compatible) · <office-viewer> Web Component | | Security | sanitised HTML (DOMPurify), no PDF scripts, safe URLs, size limits, CSP-friendly – see security audit |

Format libraries are loaded only when a file of that type is opened, so the core stays small (≈ 30 KB gzip).

Installation

npm install @meshesha/officetohtml

Or without a build step:

<div id="viewer" style="height:600px"></div>
<script src="https://cdn.jsdelivr.net/npm/@meshesha/officetohtml@2/dist/officetohtml.umd.js"></script>
<script>
  const viewer = new OfficeToHtml.OfficeViewer("#viewer");
  viewer.load("files/demo.pptx");
</script>

Usage

Vanilla JavaScript

import { OfficeViewer } from "@meshesha/officetohtml";

const viewer = new OfficeViewer(document.getElementById("viewer")!, {
  theme: "auto",                       // "light" | "dark" | "auto"
  locale: "en",                        // en he ar es fr de ru zh
  toolbar: { download: false },        // hide single buttons
  fetchOptions: { headers: { Authorization: "Bearer …" } },
  pdf: { sidebar: true },
  sheet: { engine: "handsontable" },   // or "table"
});

viewer.on("load", ({ file }) => console.log(file.kind, file.name));
viewer.on("error", ({ error }) => console.error(error.code, error.message));

await viewer.load("/files/budget.xlsx");
viewer.bindInput("#file-input");      // load files chosen in an <input type="file">

React

import { OfficeViewer } from "@meshesha/officetohtml/react";

<OfficeViewer src={file} options={{ theme: "dark" }} style={{ height: 600 }} onLoad={({ file }) => {}} />

Vue 3

<script setup>
import { OfficeViewer } from "@meshesha/officetohtml/vue";
</script>
<template>
  <OfficeViewer src="/files/report.docx" style="height:600px" @load="onLoad" />
</template>

Angular

// main.ts
import { defineOfficeViewerElement } from "@meshesha/officetohtml/angular";
defineOfficeViewerElement();
// template (component with schemas: [CUSTOM_ELEMENTS_SCHEMA]):
// <office-viewer [attr.src]="url" theme="auto" style="height:600px"></office-viewer>

A standalone Angular component is in examples/angular.

jQuery (v1 API still works)

$("#resolte-contaniner").officeToHtml({ url: "files/demo.docx" });
$("#viewer").officeViewer({ src: "files/demo.pdf", theme: "dark" }); // v2 options

Web Component

<office-viewer src="files/demo.pdf" theme="auto" style="height:600px"></office-viewer>

See the documentation (or docs/api.md) for all options, methods, events, theming, self-hosting the libraries and custom renderers.

Browser support

Current Chrome, Edge, Firefox and Safari (ES2020, fetch, ResizeObserver, CSS container queries). TIFF images display only where the browser can decode them (Safari).

Limitations

  • .doc, .ppt, .odt, .odp (legacy/binary formats) are not supported – the viewer asks the user to save the file as .docx / .pptx.
  • Word documents are converted by structure (mammoth.js): headings, lists, tables, images and links are kept, but exact fonts, spacing and page layout are not reproduced.
  • Handsontable is free for non-commercial use only. Commercial users need a Handsontable license (sheet.licenseKey) or the built-in table engine (sheet.engine: "table").

Documentation

Credits

OfficeToHtml is built on these projects – thank you to their authors and contributors:

| Library | Used for | License | |---|---|---| | PPTXjs | PowerPoint | MIT | | mammoth.js | Word | BSD-2-Clause | | SheetJS Community Edition | spreadsheet parsing | Apache-2.0 | | Handsontable | spreadsheet grid | Handsontable license (free for non-commercial use) | | PDF.js | PDF | Apache-2.0 | | DOMPurify | HTML sanitising | Apache-2.0 / MPL-2.0 | | fflate | ZIP inspection | MIT |

Full notices: THIRD_PARTY_NOTICES.md.

This project replaces my older project OfficeJs, so the version numbering does not start at 1.0.0. The v1 jQuery plugin is kept in legacy/v1 for reference.

License

MIT © meshesha