marqius-wkhtmltopdf 0.0.0-stage → 0.12.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +27 -0
- package/README.md +101 -2
- package/bin/marqius-wkhtmltopdf.js +22 -0
- package/index.d.ts +8 -0
- package/index.js +91 -0
- package/index.mjs +5 -0
- package/package.json +51 -4
package/LICENSE.md
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Licence
|
|
2
|
+
|
|
3
|
+
**The program.** marqius-wkhtmltopdf, which this package installs, is commercial
|
|
4
|
+
software from Simple AI LLC. Its use is governed by the marqius-wkhtmltopdf Licence Agreement:
|
|
5
|
+
https://marqius.com/wkhtmltopdf/licence-agreement/. It has a 30-day free trial counted from its first
|
|
6
|
+
run; after the trial, without a licence, each page it makes carries one line, "Prepared by Marqius,
|
|
7
|
+
Purchase Licence". Personal, teaching and open-source use is free with a Community licence. Plans and licences: https://marqius.com/licence/marqius-wkhtmltopdf
|
|
8
|
+
|
|
9
|
+
**This package's own files** (the JavaScript that finds the program for your platform and gives its path
|
|
10
|
+
to your library) are released under the MIT licence:
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2026 Simple AI LLC
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
|
15
|
+
associated documentation files (the "Software"), to deal in the Software without restriction,
|
|
16
|
+
including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
|
17
|
+
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
|
18
|
+
furnished to do so, subject to the following conditions:
|
|
19
|
+
|
|
20
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
21
|
+
substantial portions of the Software.
|
|
22
|
+
|
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
|
24
|
+
NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
25
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES
|
|
26
|
+
OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
27
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
#
|
|
1
|
+
# marqius-wkhtmltopdf: wkhtmltopdf for Node.js
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**marqius-wkhtmltopdf is the maintained drop-in replacement for wkhtmltopdf, as an npm package.** `npm install` it, give your library its path in one line, and the `wkhtmltopdf` and `wkhtmltoimage` packages keep making PDFs and pictures from your HTML. It runs on Linux (x64 and arm64, glibc and musl, including Debian 13, Ubuntu 24.04 and Alpine), Apple silicon Macs and Windows (x64).
|
|
4
|
+
|
|
5
|
+
## How do I install wkhtmltopdf with npm?
|
|
6
|
+
|
|
7
|
+
<!-- install -->
|
|
8
|
+
```bash
|
|
9
|
+
npm install marqius-wkhtmltopdf
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
npm installs the program for your platform from a matching optional dependency, as it does for esbuild. No install script downloads anything, so it works with `--ignore-scripts`, private registries and offline caches. It installs nothing under the name `wkhtmltopdf` on your system: your library gets the program's path from `require("marqius-wkhtmltopdf").path`, as below.
|
|
13
|
+
|
|
14
|
+
## How do I use it with the wkhtmltopdf package?
|
|
15
|
+
|
|
16
|
+
Give the package the path. Where your code has `const wkhtmltopdf = require("wkhtmltopdf");`:
|
|
17
|
+
|
|
18
|
+
<!-- example: wkhtmltopdf -->
|
|
19
|
+
```js
|
|
20
|
+
wkhtmltopdf.command = require("marqius-wkhtmltopdf").path;
|
|
21
|
+
wkhtmltopdf("<h1>Invoice 42</h1>", { output: "invoice.pdf" });
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
On Linux and macOS the `wkhtmltopdf` package starts the program through a shell. If your project's folder has a space in its path, put the path in single quotes:
|
|
25
|
+
|
|
26
|
+
<!-- example: wkhtmltopdf quoted -->
|
|
27
|
+
```js
|
|
28
|
+
wkhtmltopdf.command = "'" + require("marqius-wkhtmltopdf").path + "'";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## How do I make pictures with wkhtmltoimage?
|
|
32
|
+
|
|
33
|
+
Give it the path for pictures, `.imagePath`. Where your code has `const wkhtmltoimage = require("wkhtmltoimage");`:
|
|
34
|
+
|
|
35
|
+
<!-- example: wkhtmltoimage -->
|
|
36
|
+
```js
|
|
37
|
+
wkhtmltoimage.setCommand(require("marqius-wkhtmltopdf").imagePath);
|
|
38
|
+
wkhtmltoimage.generate("<h1>Invoice 42</h1>", { output: "invoice.jpg" });
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Can I use it from an ES module?
|
|
42
|
+
|
|
43
|
+
Yes. `marqius.path` is the same path:
|
|
44
|
+
|
|
45
|
+
<!-- example: import -->
|
|
46
|
+
```js
|
|
47
|
+
import marqius from "marqius-wkhtmltopdf";
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Why do I get "wkhtmltopdf: command not found"?
|
|
51
|
+
|
|
52
|
+
The `wkhtmltopdf` package runs a program called `wkhtmltopdf` through bash, and your machine has none. Install this package and set `wkhtmltopdf.command` to its path, as shown above.
|
|
53
|
+
|
|
54
|
+
## Why does wkhtmltopdf fail with "libssl.so.1.1: cannot open shared object file"?
|
|
55
|
+
|
|
56
|
+
Your wkhtmltopdf was built for an older system. It needs OpenSSL 1.1, which Debian 13 and Ubuntu 24.04 no longer include. marqius-wkhtmltopdf needs no system libraries, so it runs there as it is.
|
|
57
|
+
|
|
58
|
+
## Which systems does marqius-wkhtmltopdf run on?
|
|
59
|
+
|
|
60
|
+
It runs on:
|
|
61
|
+
|
|
62
|
+
- Linux on x64 and arm64, with glibc or musl (so Alpine too);
|
|
63
|
+
- Macs with Apple silicon;
|
|
64
|
+
- Windows on x64.
|
|
65
|
+
|
|
66
|
+
npm installs the right package for each. It needs no X server, Qt or system libraries. In a slim or Alpine image without fonts, the program says so and prints the one line that installs them.
|
|
67
|
+
|
|
68
|
+
## Is marqius-wkhtmltopdf free?
|
|
69
|
+
|
|
70
|
+
You can try it free for 30 days. Personal, teaching and open-source use is free with a [Community licence](https://marqius.com/wkhtmltopdf-buy/#community): sign in with Google and your free key is waiting in your account.
|
|
71
|
+
|
|
72
|
+
Anything done by or for a business, including internal tools and client work, needs Starter or above once the trial ends. Starter is $290 USD a year for organisations of up to 10 people, and Business $990 USD a year, plus applicable taxes.
|
|
73
|
+
|
|
74
|
+
Your PDFs never stop. Without a licence after the trial, each page carries one line, "Prepared by Marqius, Purchase Licence". [Plans and licences](https://marqius.com/licence/marqius-wkhtmltopdf) · [Licence terms](https://marqius.com/wkhtmltopdf/licence-agreement/)
|
|
75
|
+
|
|
76
|
+
## How do I add my licence key?
|
|
77
|
+
|
|
78
|
+
Set the `MARQIUS_LICENCE` environment variable to your licence; that is the way for containers and CI. Or save it as `licence.txt` and run `npx marqius-wkhtmltopdf licence add licence.txt`. `npx marqius-wkhtmltopdf licence` shows the trial's days left, or the licence in force.
|
|
79
|
+
|
|
80
|
+
## Does the wkhtmltopdf package pass its own tests?
|
|
81
|
+
|
|
82
|
+
Yes. The `wkhtmltopdf` package passes its own test suite with marqius-wkhtmltopdf, all 5 of its tests. The results are public: [wkhtmltopdf library tests](https://github.com/marqiushq/wkhtmltopdf-library-tests).
|
|
83
|
+
|
|
84
|
+
Before each version of this package is published, [its workflow](https://github.com/marqiushq/marqius-wkhtmltopdf-node/blob/main/.github/workflows/release.yml) installs it with npm and runs the examples on this page on Linux (x64 and arm64), macOS and Windows.
|
|
85
|
+
|
|
86
|
+
## How do I update it?
|
|
87
|
+
|
|
88
|
+
Each version of this package carries the marqius-wkhtmltopdf release with the same number. To move to the newest:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install marqius-wkhtmltopdf@latest
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## What else does the program do?
|
|
95
|
+
|
|
96
|
+
`npx marqius-wkhtmltopdf` runs it under its own name:
|
|
97
|
+
|
|
98
|
+
- `npx marqius-wkhtmltopdf help node` shows each library's setting;
|
|
99
|
+
- `npx marqius-wkhtmltopdf compare old.pdf new.pdf` lists every difference between a PDF made by wkhtmltopdf and one made by marqius-wkhtmltopdf;
|
|
100
|
+
- `npx marqius-wkhtmltopdf install` gives it the names `wkhtmltopdf` and `wkhtmltoimage` for everything on a server, with the rights to write to `/usr/local/bin`.
|
|
101
|
+
|
|
102
|
+
This package's own JavaScript files are under the MIT licence: [LICENSE.md](LICENSE.md).
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// marqius-wkhtmltopdf under its own name (npx marqius-wkhtmltopdf): help, licence, compare,
|
|
4
|
+
// install and wkhtmltopdf's command line. Commercial software with a 30-day free trial.
|
|
5
|
+
const { spawnSync } = require("child_process");
|
|
6
|
+
|
|
7
|
+
let program;
|
|
8
|
+
try {
|
|
9
|
+
program = require("..").program;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
console.error(`marqius-wkhtmltopdf: ${e.message}`);
|
|
12
|
+
process.exit(1);
|
|
13
|
+
}
|
|
14
|
+
const run = spawnSync(program, process.argv.slice(2), { stdio: "inherit" });
|
|
15
|
+
if (run.error) {
|
|
16
|
+
console.error(`marqius-wkhtmltopdf: ${run.error.message}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
if (run.signal) {
|
|
20
|
+
process.kill(process.pid, run.signal);
|
|
21
|
+
}
|
|
22
|
+
process.exit(run.status === null ? 1 : run.status);
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The release of marqius-wkhtmltopdf this package carries, such as "0.12.10". */
|
|
2
|
+
export declare const version: string;
|
|
3
|
+
/** The installed program's path, as wkhtmltopdf: give it where a library asks for wkhtmltopdf. */
|
|
4
|
+
export declare const path: string;
|
|
5
|
+
/** Its path as wkhtmltoimage, for pictures. */
|
|
6
|
+
export declare const imagePath: string;
|
|
7
|
+
/** The program under its own name, marqius-wkhtmltopdf: help, licence, compare and install. */
|
|
8
|
+
export declare const program: string;
|
package/index.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// marqius-wkhtmltopdf for Node: require("marqius-wkhtmltopdf").path is the installed program's
|
|
3
|
+
// path, to give the wkhtmltopdf package (or another library that runs wkhtmltopdf). npm installs
|
|
4
|
+
// the program for this machine with this package, from the optional dependency that matches it;
|
|
5
|
+
// nothing is downloaded at install.
|
|
6
|
+
// marqius-wkhtmltopdf is commercial software from Simple AI LLC, with a 30-day free trial:
|
|
7
|
+
// https://marqius.com/licence/marqius-wkhtmltopdf
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const os = require("os");
|
|
10
|
+
const path = require("path");
|
|
11
|
+
const { version } = require("./package.json");
|
|
12
|
+
|
|
13
|
+
const BUILDS = {
|
|
14
|
+
"linux x64": "marqius-wkhtmltopdf-linux-x64",
|
|
15
|
+
"linux arm64": "marqius-wkhtmltopdf-linux-arm64",
|
|
16
|
+
"darwin arm64": "marqius-wkhtmltopdf-darwin-arm64",
|
|
17
|
+
"win32 x64": "marqius-wkhtmltopdf-win32-x64",
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const windows = process.platform === "win32";
|
|
21
|
+
|
|
22
|
+
// the folder holding the program, in the package npm installed for this platform
|
|
23
|
+
function folder() {
|
|
24
|
+
const here = `${process.platform} ${process.arch}`;
|
|
25
|
+
const pkg = BUILDS[here];
|
|
26
|
+
if (!pkg) {
|
|
27
|
+
let why = `marqius-wkhtmltopdf has no build for ${here}: it runs on Linux (x64 and arm64), Apple silicon Macs and Windows (x64).`;
|
|
28
|
+
if (here === "darwin x64") {
|
|
29
|
+
why += " On a Mac with Apple silicon, use Node for Apple silicon rather than Node for Intel; for Intel Macs, write to hello@marqius.com.";
|
|
30
|
+
}
|
|
31
|
+
throw new Error(why);
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
return path.join(path.dirname(require.resolve(`${pkg}/package.json`)), "bin");
|
|
35
|
+
} catch (e) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`marqius-wkhtmltopdf cannot find ${pkg}, which holds the program for ${here}. npm installs it with ` +
|
|
38
|
+
`marqius-wkhtmltopdf unless optional dependencies are left out (--omit=optional, --no-optional) or the ` +
|
|
39
|
+
`lockfile was made on another platform without it. Run "npm install marqius-wkhtmltopdf" again on this machine.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// On Windows, the program answers to wkhtmltopdf.exe and wkhtmltoimage.exe by their file names:
|
|
45
|
+
// hard links beside it (copies where links cannot be made). Elsewhere a few lines of sh in the
|
|
46
|
+
// package start it under each name.
|
|
47
|
+
function named(dir, name) {
|
|
48
|
+
if (!windows) {
|
|
49
|
+
return path.join(dir, name);
|
|
50
|
+
}
|
|
51
|
+
const program = path.join(dir, "marqius-wkhtmltopdf.exe");
|
|
52
|
+
const size = fs.statSync(program).size;
|
|
53
|
+
for (const place of [dir, path.join(os.tmpdir(), `marqius-wkhtmltopdf-${version}`)]) {
|
|
54
|
+
const to = path.join(place, `${name}.exe`);
|
|
55
|
+
try {
|
|
56
|
+
if (fs.statSync(to).size === size) {
|
|
57
|
+
return to;
|
|
58
|
+
}
|
|
59
|
+
} catch (e) {
|
|
60
|
+
// not made yet
|
|
61
|
+
}
|
|
62
|
+
try {
|
|
63
|
+
fs.mkdirSync(place, { recursive: true });
|
|
64
|
+
try {
|
|
65
|
+
fs.unlinkSync(to);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
// nothing to replace
|
|
68
|
+
}
|
|
69
|
+
try {
|
|
70
|
+
fs.linkSync(program, to);
|
|
71
|
+
} catch (e) {
|
|
72
|
+
fs.copyFileSync(program, to);
|
|
73
|
+
}
|
|
74
|
+
return to;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
// this folder cannot be written: try the next
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
throw new Error(`marqius-wkhtmltopdf cannot be given the name ${name}.exe: neither ${dir} nor ${os.tmpdir()} can be written`);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const dir = folder();
|
|
83
|
+
|
|
84
|
+
/** The release of marqius-wkhtmltopdf this package carries, such as "0.12.10". */
|
|
85
|
+
exports.version = version;
|
|
86
|
+
/** The installed program's path, as wkhtmltopdf: give it where a library asks for wkhtmltopdf. */
|
|
87
|
+
exports.path = named(dir, "wkhtmltopdf");
|
|
88
|
+
/** Its path as wkhtmltoimage, for pictures. */
|
|
89
|
+
exports.imagePath = named(dir, "wkhtmltoimage");
|
|
90
|
+
/** The program under its own name, marqius-wkhtmltopdf: help, licence, compare and install. */
|
|
91
|
+
exports.program = path.join(dir, windows ? "marqius-wkhtmltopdf.exe" : "marqius-wkhtmltopdf");
|
package/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marqius-wkhtmltopdf",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.12.13",
|
|
4
|
+
"description": "marqius-wkhtmltopdf, the maintained drop-in replacement for wkhtmltopdf, for Node's wkhtmltopdf package (commercial, 30-day trial)",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"wkhtmltopdf",
|
|
7
|
+
"wkhtmltoimage",
|
|
8
|
+
"pdf",
|
|
9
|
+
"html-to-pdf",
|
|
10
|
+
"html2pdf"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://marqius.com/wkhtmltopdf/",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/marqiushq/marqius-wkhtmltopdf-node/issues",
|
|
15
|
+
"email": "hello@marqius.com"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/marqiushq/marqius-wkhtmltopdf-node.git",
|
|
20
|
+
"directory": "marqius-wkhtmltopdf"
|
|
21
|
+
},
|
|
22
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
23
|
+
"author": "Simple AI LLC <hello@marqius.com> (https://marqius.com)",
|
|
24
|
+
"main": "index.js",
|
|
25
|
+
"types": "index.d.ts",
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./index.d.ts",
|
|
29
|
+
"import": "./index.mjs",
|
|
30
|
+
"require": "./index.js"
|
|
31
|
+
},
|
|
32
|
+
"./package.json": "./package.json"
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"marqius-wkhtmltopdf": "bin/marqius-wkhtmltopdf.js"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"index.js",
|
|
39
|
+
"index.mjs",
|
|
40
|
+
"index.d.ts",
|
|
41
|
+
"bin/marqius-wkhtmltopdf.js",
|
|
42
|
+
"LICENSE.md"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=14"
|
|
46
|
+
},
|
|
47
|
+
"optionalDependencies": {
|
|
48
|
+
"marqius-wkhtmltopdf-darwin-arm64": "0.12.13",
|
|
49
|
+
"marqius-wkhtmltopdf-linux-arm64": "0.12.13",
|
|
50
|
+
"marqius-wkhtmltopdf-linux-x64": "0.12.13",
|
|
51
|
+
"marqius-wkhtmltopdf-win32-x64": "0.12.13"
|
|
52
|
+
}
|
|
53
|
+
}
|