node-poppler 6.2.6 → 7.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 +31 -13
- package/package.json +4 -2
- package/src/index.js +343 -305
- package/types/index.d.ts +520 -276
package/README.md
CHANGED
|
@@ -81,7 +81,7 @@ Example of an `async` `await` call to `poppler.pdfToCairo()`, to convert only th
|
|
|
81
81
|
PDF file using stdout:
|
|
82
82
|
|
|
83
83
|
```js
|
|
84
|
-
const
|
|
84
|
+
const { writeFile } = require("node:fs/promises");
|
|
85
85
|
const { Poppler } = require("node-poppler");
|
|
86
86
|
|
|
87
87
|
const file = "test_document.pdf";
|
|
@@ -93,7 +93,7 @@ const options = {
|
|
|
93
93
|
|
|
94
94
|
const res = await poppler.pdfToCairo(file, undefined, options);
|
|
95
95
|
// pdfToCairo writes to stdout using binary encoding if pdfFile or singleFile options are used
|
|
96
|
-
await
|
|
96
|
+
await writeFile("new_file.pdf", res, { encoding: "binary" });
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
### poppler.pdfToHtml
|
|
@@ -110,27 +110,39 @@ const options = {
|
|
|
110
110
|
lastPageToConvert: 2,
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
-
poppler
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
poppler
|
|
114
|
+
.pdfToHtml(file, undefined, options)
|
|
115
|
+
.then((res) => {
|
|
116
|
+
console.log(res);
|
|
117
|
+
})
|
|
118
|
+
.catch((err) => {
|
|
119
|
+
console.error(err);
|
|
120
|
+
throw err;
|
|
121
|
+
});
|
|
116
122
|
```
|
|
117
123
|
|
|
118
124
|
Example of calling `poppler.pdfToHtml()` with a promise chain, providing a Buffer as an input:
|
|
119
125
|
|
|
120
126
|
```js
|
|
121
|
-
const
|
|
127
|
+
const { readFileSync } = require("node:fs");
|
|
122
128
|
const { Poppler } = require("node-poppler");
|
|
123
129
|
|
|
124
|
-
const file =
|
|
130
|
+
const file = readFileSync("test_document.pdf");
|
|
125
131
|
const poppler = new Poppler();
|
|
126
132
|
const options = {
|
|
127
133
|
firstPageToConvert: 1,
|
|
128
134
|
lastPageToConvert: 2,
|
|
129
135
|
};
|
|
130
136
|
|
|
131
|
-
poppler
|
|
132
|
-
|
|
133
|
-
|
|
137
|
+
poppler
|
|
138
|
+
.pdfToHtml(file, "tester.html", options)
|
|
139
|
+
.then((res) => {
|
|
140
|
+
console.log(res);
|
|
141
|
+
})
|
|
142
|
+
.catch((err) => {
|
|
143
|
+
console.error(err);
|
|
144
|
+
throw err;
|
|
145
|
+
});
|
|
134
146
|
```
|
|
135
147
|
|
|
136
148
|
### poppler.pdfToText
|
|
@@ -147,9 +159,15 @@ const options = {
|
|
|
147
159
|
lastPageToConvert: 2,
|
|
148
160
|
};
|
|
149
161
|
|
|
150
|
-
poppler
|
|
151
|
-
|
|
152
|
-
|
|
162
|
+
poppler
|
|
163
|
+
.pdfToText(file, options)
|
|
164
|
+
.then((res) => {
|
|
165
|
+
console.log(res);
|
|
166
|
+
})
|
|
167
|
+
.catch((err) => {
|
|
168
|
+
console.error(err);
|
|
169
|
+
throw err;
|
|
170
|
+
});
|
|
153
171
|
```
|
|
154
172
|
|
|
155
173
|
## Contributing
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-poppler",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Asynchronous node.js wrapper for the Poppler PDF rendering library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"async",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"unite"
|
|
34
34
|
],
|
|
35
35
|
"main": "src/index.js",
|
|
36
|
+
"type": "commonjs",
|
|
36
37
|
"types": "types/index.d.ts",
|
|
37
38
|
"repository": "git+https://github.com/Fdawgs/node-poppler.git",
|
|
38
39
|
"homepage": "https://github.com/Fdawgs/node-poppler",
|
|
@@ -43,10 +44,11 @@
|
|
|
43
44
|
"author": "Frazer Smith <frazer.dev@outlook.com>",
|
|
44
45
|
"funding": "https://github.com/sponsors/Fdawgs",
|
|
45
46
|
"engines": {
|
|
46
|
-
"node": ">=
|
|
47
|
+
"node": ">=18.0.0"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
50
|
"camelcase": "^6.3.0",
|
|
51
|
+
"semver": "^7.5.4",
|
|
50
52
|
"upath": "^2.0.1"
|
|
51
53
|
}
|
|
52
54
|
}
|