Coder Social home page Coder Social logo

vilhelm-ian / mupdf.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from artifexsoftware/mupdf.js

0.0 0.0 0.0 5.56 MB

JavaScript bindings for MuPDF

Home Page: https://mupdfjs.readthedocs.io

License: GNU Affero General Public License v3.0

Shell 0.71% JavaScript 1.72% C 34.17% TypeScript 63.29% Makefile 0.06% Vim Script 0.05%

mupdf.js's Introduction

MuPDF.js

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
  • Search PDF file text contents
  • Create and edit PDF annotations
  • Access and fill out PDF forms
  • Edit PDF documents
  • 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 mupdf from "mupdf"

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

const filename = process.argv[2];
const doc = mupdf.Document.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.

mupdf.js's People

Contributors

ccxvii avatar jamie-lemon avatar github-actions[bot] avatar sebras avatar chris avatar penxla avatar mipo1357 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.