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 🙏

© 2024 – Pkg Stats / Ryan Hefner

mupdf

v1.1.0

Published

MuPDF.js

Downloads

10,006

Readme

MuPDF.js

Welcome to official MuPDF.js library from Artifex - the maintainers of MuPDF.

This is a build of MuPDF for JavaScript and TypeScript, using the speed and performance of WebAssembly.

The MuPDF.js library can be used both in browsers and in Node.js.

Features

  • Render PDF pages to images
  • Extract text and images from PDF
  • Edit PDF documents
  • Search PDF file text contents
  • Create and edit PDF annotations
  • Access and fill out PDF forms
  • Supports basic CJK (Chinese, Japanese, Korean) fonts

Installing

From the command line, go to the folder you want to work from and run:

npm install mupdf

The mupdf module is only available as an ESM module. Either use the .mjs file extension or change the project type:

npm pkg set type=module

Running

The following example script demonstrates how to load a document and then print out the page count.

Create a file count-pages.mjs:

import * as process from "node:process"
import * as fs from "node:fs"
import * as mupdfjs from "mupdf/mupdfjs"

if (process.argv.length < 3) {
    console.error("usage: node count-pages.mjs file.pdf");
    process.exit(1);
}

const filename = process.argv[2];
const doc = mupdfjs.PDFDocument.openDocument(fs.readFileSync(filename), "application/pdf");
const count = doc.countPages();

console.log(`${filename} has ${count} pages.`);

Run the script:

node count-pages.mjs file.pdf

Using Typescript

To use TypeScript you need to create a tsconfig.json project file to tell the compiler and Visual Studio Code to use the "nodenext" module resolution:

{
    "compilerOptions": {
        "module": "nodenext"
    }
}

License and Copyright

MuPDF.js is available under Open Source AGPL and commercial license agreements. If you determine you cannot meet the requirements of the AGPL, please contact Artifex for more information regarding a commercial license.

Documentation

For documentation please refer to mupdfjs.readthedocs.io.

Code Examples

Check out the example projects to help you get started. The examples include a simple PDF Viewer that runs MuPDF in the browser, several command line scripts, and more!

Getting Started with Local Development

You can build the MuPDF.js library from source by referring to BUILDING.md.

Contributing

To contribute please open up (or help answer!) an Issue on our Github board and create a Pull Request (PR) for review. Find us on Discord at #mupdf-js to chat with us directly.