comparison mupdf-source/platform/wasm/BUILDING.md @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 # Building MuPDF.js from source
2
3 The WebAssembly build has only been tested on Linux at the moment.
4 If you use any other platform then you are on your own!
5
6 ## Dependencies
7
8 This project has two dependencies that MUST be installed FIRST!
9
10 ### Emscripten
11
12 You need to install the Emscripten SDK in `/opt/emsdk`. If you install it
13 elsewhere, you will need to edit `tools/build.sh` to point to the appropriate
14 location.
15
16 > https://emscripten.org/docs/getting_started/downloads.html
17
18 We have only tested against EMSDK version 4.0.8. Use another version at your own peril!
19
20 /opt/emsdk/emsdk install 4.0.8
21 /opt/emsdk/emsdk activate 4.0.8
22
23 ### Node.js
24
25 Install Node.js and NPM. We use the current LTS version, which at the moment is v22.
26 The version that ships with Debian is probably too old to use.
27
28 > https://nodejs.org/en
29
30 If you don't want to install Node separately, you can piggy-back on the Node version
31 that ships with Emscripten:
32
33 export PATH="/opt/emdsk/node/20.18.0_64bit/bin:$PATH"
34
35 ## Building
36
37 You need to be in the `platform/wasm` directory for these build steps.
38
39 cd platform/wasm
40
41 The following command will download and install all the NPM project dependencies.
42
43 npm install
44
45 To compile the WebAssembly and Typescript files:
46
47 npm run prepack
48
49 The results of the build are put into the `dist` directory:
50
51 - `dist/mupdf-wasm.wasm`
52 - `dist/mupdf-wasm.js`
53 - `dist/mupdf.js`
54
55 The `mupdf-wasm.wasm` file is quite large, because it contains not only the
56 MuPDF library code, but also the 14 core PDF fonts, various CJK mapping
57 resources, and ICC profiles.
58
59 In order to keep it as small as possible, it is built with a minimal feature set
60 that excludes the more refined CJK fonts, AcroForm scripting, and XPS input format.
61
62 ## Installing and Running
63
64 The main module is the `mupdf.js` file.
65
66 ### Use the MuPDF.js module in a browser
67
68 To use MuPDF.js directly in the browser, put the `dist/mupdf-wasm.wasm`,
69 `dist/mupdf-wasm.js`, and `dist/mupdf.js` somewhere on your site, and import
70 the `mupdf.js` module.
71
72 There's an example of using MuPDF.js in the browser with a WebWorker in `examples/simple-viewer`.
73
74 npm run simple-viewer
75
76 ### Use the MuPDF.js module in Node
77
78 You can `npm pack` and `npm install` the project in another directory.
79
80 You can also run the examples directly from here.
81
82 ## Customizing
83
84 The build can be customized to enable a different feature set, by calling
85 the tools/build.sh script with the appropriate environment variables.
86
87 See the Makefile for some examples.
88
89 The most noteworthy of these is the "memento" configuration, which enables a
90 memory debugger.
91
92 make memento
93
94 If you're seeing weird memory corruption issues, Memento is the best way to
95 track them down!
96
97 ## Editing
98
99 The source files are:
100
101 - `lib/mupdf.c`
102 - `lib/mupdf.ts`