node-poppler 9.1.2 → 10.0.0
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/README.md +24 -18
- package/package.json +1 -1
- package/src/index.js +26 -860
- package/src/options/pdfattach.js +13 -0
- package/src/options/pdfdetach.js +41 -0
- package/src/options/pdffonts.js +22 -0
- package/src/options/pdfimages.js +48 -0
- package/src/options/pdfinfo.js +65 -0
- package/src/options/pdfseparate.js +17 -0
- package/src/options/pdftocairo.js +169 -0
- package/src/options/pdftohtml.js +71 -0
- package/src/options/pdftoppm.js +171 -0
- package/src/options/pdftops.js +196 -0
- package/src/options/pdftotext.js +105 -0
- package/src/options/pdfunite.js +11 -0
- package/types/index.d.ts +12 -1096
- package/types/options/pdfattach.d.ts +15 -0
- package/types/options/pdfdetach.d.ts +53 -0
- package/types/options/pdffonts.d.ts +32 -0
- package/types/options/pdfimages.d.ts +74 -0
- package/types/options/pdfinfo.d.ts +88 -0
- package/types/options/pdfseparate.d.ts +21 -0
- package/types/options/pdftocairo.d.ts +241 -0
- package/types/options/pdftohtml.d.ts +104 -0
- package/types/options/pdftoppm.d.ts +210 -0
- package/types/options/pdftops.d.ts +237 -0
- package/types/options/pdftotext.d.ts +137 -0
- package/types/options/pdfunite.d.ts +11 -0
package/README.md
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
# node-poppler
|
|
2
2
|
|
|
3
|
-
[](https://npmjs.com/package/node-poppler)
|
|
3
|
+
[](https://github.com/Fdawgs/node-poppler/releases/latest)
|
|
4
|
+
[](https://www.npmjs.com/package/node-poppler)
|
|
5
5
|
[](https://github.com/Fdawgs/node-poppler/actions/workflows/ci.yml)
|
|
6
6
|
[](https://coveralls.io/github/Fdawgs/node-poppler?branch=main)
|
|
7
|
-
[](https://github.com/prettier/prettier)
|
|
8
|
+
[](https://scorecard.dev/viewer/?uri=github.com/Fdawgs/node-poppler)
|
|
8
9
|
|
|
9
10
|
> Asynchronous Node.js wrapper for the Poppler PDF rendering utilities
|
|
10
11
|
|
|
11
12
|
## Overview
|
|
12
13
|
|
|
13
|
-
[Poppler](https://poppler.freedesktop.org
|
|
14
|
+
[Poppler](https://poppler.freedesktop.org) is a PDF rendering library that also includes a collection of utilities, which provide functionality for manipulating PDF documents and extracting data from them, including converting PDF files to HTML, TXT, or PostScript.
|
|
14
15
|
|
|
15
|
-
The `node-poppler` module provides an asynchronous Node.js wrapper around
|
|
16
|
+
The `node-poppler` module provides an asynchronous Node.js wrapper around these utilities for easier use.
|
|
16
17
|
|
|
17
18
|
## Installation
|
|
18
19
|
|
|
@@ -25,7 +26,7 @@ npm i node-poppler
|
|
|
25
26
|
### Linux and macOS/Darwin support
|
|
26
27
|
|
|
27
28
|
64-bit Windows binaries are provided via an optional dependency on the [`node-poppler-win32`](https://www.npmjs.com/package/node-poppler-win32) package.
|
|
28
|
-
For Linux and
|
|
29
|
+
For Linux and macOS users, the `poppler-data` package and `poppler-utils` binaries will need to be installed separately.
|
|
29
30
|
|
|
30
31
|
An example of downloading the binaries on a Debian system:
|
|
31
32
|
|
|
@@ -33,7 +34,7 @@ An example of downloading the binaries on a Debian system:
|
|
|
33
34
|
sudo apt-get install poppler-data poppler-utils
|
|
34
35
|
```
|
|
35
36
|
|
|
36
|
-
For macOS users, the binaries can be installed with [Homebrew](https://brew.sh
|
|
37
|
+
For macOS users, the binaries can be installed with [Homebrew](https://brew.sh):
|
|
37
38
|
|
|
38
39
|
```sh
|
|
39
40
|
brew install poppler
|
|
@@ -45,10 +46,10 @@ Please refer to the [JSDoc comments in the source code](./src/index.js) or the [
|
|
|
45
46
|
|
|
46
47
|
### poppler.pdfToCairo
|
|
47
48
|
|
|
48
|
-
Example of an `async
|
|
49
|
+
Example of an `async`/`await` call to `poppler.pdfToCairo()` to convert the first two pages of a PDF file to PNG using ESM syntax:
|
|
49
50
|
|
|
50
51
|
```js
|
|
51
|
-
|
|
52
|
+
import { Poppler } from "node-poppler";
|
|
52
53
|
|
|
53
54
|
const file = "test_document.pdf";
|
|
54
55
|
const poppler = new Poppler();
|
|
@@ -57,18 +58,17 @@ const options = {
|
|
|
57
58
|
lastPageToConvert: 2,
|
|
58
59
|
pngFile: true,
|
|
59
60
|
};
|
|
60
|
-
const outputFile =
|
|
61
|
+
const outputFile = "test_document";
|
|
61
62
|
|
|
62
63
|
const res = await poppler.pdfToCairo(file, outputFile, options);
|
|
63
64
|
console.log(res);
|
|
64
65
|
```
|
|
65
66
|
|
|
66
|
-
Example of an `async
|
|
67
|
-
PDF file using stdout:
|
|
67
|
+
Example of an `async`/`await` call to `poppler.pdfToCairo()` to convert the first page of a PDF file to a new PDF file via stdout using ESM syntax:
|
|
68
68
|
|
|
69
69
|
```js
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
import { writeFile } from "node:fs/promises";
|
|
71
|
+
import { Poppler } from "node-poppler";
|
|
72
72
|
|
|
73
73
|
const file = "test_document.pdf";
|
|
74
74
|
const poppler = new Poppler();
|
|
@@ -84,9 +84,11 @@ await writeFile("new_file.pdf", res, { encoding: "binary", flush: true });
|
|
|
84
84
|
|
|
85
85
|
### poppler.pdfToHtml
|
|
86
86
|
|
|
87
|
-
Example of calling `poppler.pdfToHtml()` with a promise chain:
|
|
87
|
+
Example of calling `poppler.pdfToHtml()` with a promise chain using CJS syntax:
|
|
88
88
|
|
|
89
89
|
```js
|
|
90
|
+
"use strict";
|
|
91
|
+
|
|
90
92
|
const { Poppler } = require("node-poppler");
|
|
91
93
|
|
|
92
94
|
const file = "test_document.pdf";
|
|
@@ -107,9 +109,11 @@ poppler
|
|
|
107
109
|
});
|
|
108
110
|
```
|
|
109
111
|
|
|
110
|
-
Example of calling `poppler.pdfToHtml()` with a promise chain
|
|
112
|
+
Example of calling `poppler.pdfToHtml()` with a promise chain using CJS syntax and a `Buffer` as input:
|
|
111
113
|
|
|
112
114
|
```js
|
|
115
|
+
"use strict";
|
|
116
|
+
|
|
113
117
|
const { readFileSync } = require("node:fs");
|
|
114
118
|
const { Poppler } = require("node-poppler");
|
|
115
119
|
|
|
@@ -133,9 +137,11 @@ poppler
|
|
|
133
137
|
|
|
134
138
|
### poppler.pdfToText
|
|
135
139
|
|
|
136
|
-
Example of calling `poppler.pdfToText()` with a promise chain:
|
|
140
|
+
Example of calling `poppler.pdfToText()` with a promise chain using CJS syntax:
|
|
137
141
|
|
|
138
142
|
```js
|
|
143
|
+
"use strict";
|
|
144
|
+
|
|
139
145
|
const { Poppler } = require("node-poppler");
|
|
140
146
|
|
|
141
147
|
const file = "test_document.pdf";
|
|
@@ -166,7 +172,7 @@ Please adhere to this project's [Code of Conduct](https://github.com/Fdawgs/.git
|
|
|
166
172
|
|
|
167
173
|
## Acknowledgements
|
|
168
174
|
|
|
169
|
-
- [**Albert Astals Cid**](https://github.com/albert-astals-cid-kdab) - [Poppler](https://poppler.freedesktop.org
|
|
175
|
+
- [**Albert Astals Cid**](https://github.com/albert-astals-cid-kdab) - [Poppler](https://poppler.freedesktop.org) developer
|
|
170
176
|
|
|
171
177
|
## License
|
|
172
178
|
|