muhammara 3.0.0 → 3.1.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/CHANGELOG.md +57 -45
- package/PDFRStreamForBuffer.js +33 -31
- package/PDFRStreamForFile.js +32 -41
- package/PDFStreamForResponse.js +12 -19
- package/PDFWStreamForBuffer.js +16 -23
- package/PDFWStreamForFile.js +24 -37
- package/README.md +1 -1
- package/binding.gyp +14 -1
- package/muhammara.d.ts +169 -72
- package/muhammara.js +24 -21
- package/node_modules/@mapbox/node-pre-gyp/CHANGELOG.md +3 -0
- package/node_modules/@mapbox/node-pre-gyp/README.md +1 -1
- package/node_modules/@mapbox/node-pre-gyp/package.json +5 -5
- package/package.json +8 -6
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [3.1.0] - 2022-09-30
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Update TypeScript declaration for `PDFStreamForResponse` to accept any writable stream as an argument, not just `PDFRStreamForFile`
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Node 18
|
|
19
|
+
- Electron 20.0, 20.1, 20.2
|
|
20
|
+
- Prettier as dev dependency and basics
|
|
21
|
+
- Electron 19.1
|
|
22
|
+
|
|
10
23
|
## [3.0.0] - 2022-07-19
|
|
11
24
|
|
|
12
25
|
### Fixed
|
|
@@ -16,9 +29,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
16
29
|
### Added
|
|
17
30
|
|
|
18
31
|
- drawPath can now be used differently and this new way can be described with ts.
|
|
19
|
-
The old style is `drawPath(x1, y1, x2, y2..., options)` we now allow `drawPath([[x1, y1], [x2, y2]...], options)` too
|
|
32
|
+
The old style is `drawPath(x1, y1, x2, y2..., options)` we now allow `drawPath([[x1, y1], [x2, y2]...], options)` too
|
|
20
33
|
- scn and SCN can now be used differently and this new way can be described with ts.
|
|
21
|
-
The old style is `scn(c1, c2, c3, c4, ..., 'patternName')` we now allow `scn([[c1, c2, c3, c4, ...],
|
|
34
|
+
The old style is `scn(c1, c2, c3, c4, ..., 'patternName')` we now allow `scn([[c1, c2, c3, c4, ...], 'patternName')` too
|
|
22
35
|
|
|
23
36
|
### Changed
|
|
24
37
|
|
|
@@ -91,7 +104,7 @@ The old style is `drawPath(x1, y1, x2, y2..., options)` we now allow `drawPath([
|
|
|
91
104
|
### Added
|
|
92
105
|
|
|
93
106
|
- Add Electron 13.3.0
|
|
94
|
-
- Documentation (copy of
|
|
107
|
+
- Documentation (copy of the wiki)
|
|
95
108
|
- Add Electron 13.2.3
|
|
96
109
|
- Add Electron 13.5.0
|
|
97
110
|
- Add Electron 14.0.1
|
|
@@ -115,8 +128,8 @@ The old style is `drawPath(x1, y1, x2, y2..., options)` we now allow `drawPath([
|
|
|
115
128
|
|
|
116
129
|
### Fixed
|
|
117
130
|
|
|
118
|
-
|
|
119
|
-
|
|
131
|
+
- Yarn v2 incompatibiliy
|
|
132
|
+
- Build issues on mac OS big sur
|
|
120
133
|
|
|
121
134
|
## [1.8.0] - 2021-05-28
|
|
122
135
|
|
|
@@ -131,56 +144,56 @@ The old style is `drawPath(x1, y1, x2, y2..., options)` we now allow `drawPath([
|
|
|
131
144
|
|
|
132
145
|
### Added
|
|
133
146
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
147
|
+
- More electron 11.x releases
|
|
148
|
+
- Add electron 12.0.0
|
|
149
|
+
- Add electron 10.2, 10.3
|
|
150
|
+
- Add electron 9.4, 9.3
|
|
138
151
|
|
|
139
152
|
## [1.6.0] - 2021-02-17
|
|
140
153
|
|
|
141
154
|
### Fixed
|
|
142
155
|
|
|
143
|
-
|
|
144
|
-
|
|
156
|
+
- Update the g++ compiler from 4.8 to 5.4 (default on xenial) for linux builds
|
|
157
|
+
- Changed builds from travis and app veyor to github
|
|
145
158
|
|
|
146
159
|
### Added
|
|
147
160
|
|
|
148
|
-
|
|
149
|
-
|
|
161
|
+
- Electron 11
|
|
162
|
+
- Added Node 15
|
|
150
163
|
|
|
151
164
|
## [1.5.1] - 2020-10-10
|
|
152
165
|
|
|
153
166
|
### Added
|
|
154
167
|
|
|
155
|
-
|
|
168
|
+
- Added manual workflow to reduce release errors
|
|
156
169
|
|
|
157
170
|
### Fixed
|
|
158
171
|
|
|
159
|
-
|
|
172
|
+
- Huge package size as npm publish does not use .gitignore or .npmignore locally
|
|
160
173
|
|
|
161
174
|
## [1.5.0] - 2020-10-10
|
|
162
175
|
|
|
163
176
|
### Added
|
|
164
177
|
|
|
165
|
-
|
|
178
|
+
- Electron 7.3, 8.3, 8.4, 8.5 and 9.3
|
|
166
179
|
|
|
167
180
|
## [1.4.3] - 2020-10-09
|
|
168
181
|
|
|
169
182
|
### Fixed
|
|
170
183
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
184
|
+
- Return code fixed for builds on app veyor.
|
|
185
|
+
- Winwdows builds successfully with electron 10.x
|
|
186
|
+
- NPM version on app veyor fixed to build electron 2.x again
|
|
174
187
|
|
|
175
188
|
### Added
|
|
176
189
|
|
|
177
|
-
|
|
190
|
+
- Add electron 10.1.3
|
|
178
191
|
|
|
179
192
|
## [1.4.2] - 2020-08-27
|
|
180
193
|
|
|
181
194
|
### Added
|
|
182
195
|
|
|
183
|
-
|
|
196
|
+
- Add electron 10.0
|
|
184
197
|
|
|
185
198
|
## [1.4.1] - 2020-08-13
|
|
186
199
|
|
|
@@ -190,56 +203,55 @@ debug output.
|
|
|
190
203
|
|
|
191
204
|
### Fixed
|
|
192
205
|
|
|
193
|
-
|
|
194
|
-
|
|
206
|
+
- Removed debug output from packaged dependency `node-pre-gyp`
|
|
195
207
|
|
|
196
208
|
## [1.4.0] - 2020-08-10
|
|
197
209
|
|
|
198
210
|
### Added
|
|
199
211
|
|
|
200
|
-
|
|
212
|
+
- Add electron 9.2
|
|
201
213
|
|
|
202
214
|
## [1.3.0] - 2020-08-06
|
|
203
215
|
|
|
204
216
|
### Added
|
|
205
217
|
|
|
206
|
-
|
|
218
|
+
- Add electron-9.1 pre built
|
|
207
219
|
|
|
208
220
|
### Fixed
|
|
209
221
|
|
|
210
|
-
|
|
222
|
+
- Add missing typescript declaration files to published packages
|
|
211
223
|
|
|
212
224
|
## [1.2.0] - 2020-06-01
|
|
213
225
|
|
|
214
226
|
### Fixed
|
|
215
227
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
228
|
+
- Updated freetype to 2.10.0
|
|
229
|
+
- Updated libpng dependency to 1.6.37
|
|
230
|
+
- Updated libaesgm dependency
|
|
231
|
+
- Update libjpeg dependency to 9d
|
|
232
|
+
- Updated libtiff dependency to 3.9.7
|
|
221
233
|
|
|
222
234
|
## [1.1.0] - 2020-05-27
|
|
223
235
|
|
|
224
236
|
### Added
|
|
225
237
|
|
|
226
|
-
|
|
227
|
-
|
|
238
|
+
- Added infos about being hummusjs drop in replacement
|
|
239
|
+
- Added electron v9.0.0
|
|
228
240
|
|
|
229
241
|
### Fixed
|
|
230
242
|
|
|
231
|
-
|
|
243
|
+
- Updated dependencies and dev dependencies
|
|
232
244
|
|
|
233
245
|
## [1.0.1] - 2020-05-08
|
|
234
246
|
|
|
235
247
|
### Fixed
|
|
236
248
|
|
|
237
|
-
|
|
238
|
-
|
|
249
|
+
- Fixed readme to include infos about muhammaraJS and hummus
|
|
250
|
+
- Fixed node-pre-gyp binary download links
|
|
239
251
|
|
|
240
252
|
### Removed
|
|
241
253
|
|
|
242
|
-
|
|
254
|
+
- Unecessary dependency on aws-sdk
|
|
243
255
|
|
|
244
256
|
## [1.0.0] - 2020-05-07
|
|
245
257
|
|
|
@@ -248,22 +260,22 @@ with the following changes.
|
|
|
248
260
|
|
|
249
261
|
### Added
|
|
250
262
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
263
|
+
- Store releases @github
|
|
264
|
+
- Listen for tags instead of a commit message
|
|
265
|
+
- Added node v13, v14, electron 6.1, 7.1, 7.2, 8.0, 8.1, 8.2
|
|
254
266
|
|
|
255
267
|
### Fixed
|
|
256
268
|
|
|
257
|
-
|
|
269
|
+
- Updated v8:GET / v8:SET calls which are incompatible with newer node version (>13)
|
|
258
270
|
|
|
259
271
|
### Removed
|
|
260
272
|
|
|
261
|
-
|
|
262
|
-
|
|
273
|
+
- Dropped support for electron 1.8
|
|
263
274
|
|
|
264
|
-
|
|
275
|
+
- Initial release
|
|
265
276
|
|
|
266
|
-
[
|
|
277
|
+
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/3.1.0...HEAD
|
|
278
|
+
[3.1.0]: https://github.com/julianhille/MuhammaraJS/compare/3.0.0...3.1.0
|
|
267
279
|
[3.0.0]: https://github.com/julianhille/MuhammaraJS/compare/2.6.0...3.0.0
|
|
268
280
|
[2.6.0]: https://github.com/julianhille/MuhammaraJS/compare/2.5.0...2.6.0
|
|
269
281
|
[2.5.0]: https://github.com/julianhille/MuhammaraJS/compare/2.4.0...2.5.0
|
package/PDFRStreamForBuffer.js
CHANGED
|
@@ -4,38 +4,40 @@
|
|
|
4
4
|
@author Luciano Júnior
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
function PDFRStreamForBuffer(buffer){
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
PDFRStreamForBuffer.prototype.read = function(inAmount){
|
|
14
|
-
var amountToRead = inAmount;
|
|
15
|
-
var arr = this.innerArray.slice(this.rposition,this.rposition+amountToRead);
|
|
16
|
-
this.rposition += amountToRead;
|
|
17
|
-
return arr;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
PDFRStreamForBuffer.prototype.notEnded = function(){
|
|
21
|
-
return this.rposition < this.fileSize;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
PDFRStreamForBuffer.prototype.setPosition = function(inPosition){
|
|
25
|
-
this.rposition = inPosition;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
PDFRStreamForBuffer.prototype.setPositionFromEnd = function(inPosition){
|
|
29
|
-
this.rposition = this.fileSize-inPosition;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
PDFRStreamForBuffer.prototype.skip = function(inAmount){
|
|
33
|
-
this.rposition += inAmount;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
PDFRStreamForBuffer.prototype.getCurrentPosition = function(){
|
|
37
|
-
return this.rposition;
|
|
7
|
+
function PDFRStreamForBuffer(buffer) {
|
|
8
|
+
this.innerArray = Array.prototype.slice.call(buffer, 0);
|
|
9
|
+
this.rposition = 0;
|
|
10
|
+
this.fileSize = this.innerArray.length;
|
|
38
11
|
}
|
|
39
12
|
|
|
13
|
+
PDFRStreamForBuffer.prototype.read = function (inAmount) {
|
|
14
|
+
var amountToRead = inAmount;
|
|
15
|
+
var arr = this.innerArray.slice(
|
|
16
|
+
this.rposition,
|
|
17
|
+
this.rposition + amountToRead
|
|
18
|
+
);
|
|
19
|
+
this.rposition += amountToRead;
|
|
20
|
+
return arr;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
PDFRStreamForBuffer.prototype.notEnded = function () {
|
|
24
|
+
return this.rposition < this.fileSize;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
PDFRStreamForBuffer.prototype.setPosition = function (inPosition) {
|
|
28
|
+
this.rposition = inPosition;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
PDFRStreamForBuffer.prototype.setPositionFromEnd = function (inPosition) {
|
|
32
|
+
this.rposition = this.fileSize - inPosition;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
PDFRStreamForBuffer.prototype.skip = function (inAmount) {
|
|
36
|
+
this.rposition += inAmount;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
PDFRStreamForBuffer.prototype.getCurrentPosition = function () {
|
|
40
|
+
return this.rposition;
|
|
41
|
+
};
|
|
40
42
|
|
|
41
43
|
module.exports = PDFRStreamForBuffer;
|
package/PDFRStreamForFile.js
CHANGED
|
@@ -1,58 +1,49 @@
|
|
|
1
|
-
var fs = require(
|
|
1
|
+
var fs = require("fs");
|
|
2
2
|
/*
|
|
3
3
|
PDFRStreamForFile is an implementation of a read stream using the supplied file path.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
function PDFRStreamForFile(inPath)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.fileSize = fs.statSync(inPath)["size"];
|
|
6
|
+
function PDFRStreamForFile(inPath) {
|
|
7
|
+
this.rs = fs.openSync(inPath, "r");
|
|
8
|
+
this.path = inPath;
|
|
9
|
+
this.rposition = 0;
|
|
10
|
+
this.fileSize = fs.statSync(inPath)["size"];
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
PDFRStreamForFile.prototype.read = function(inAmount)
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var arr = [];
|
|
13
|
+
PDFRStreamForFile.prototype.read = function (inAmount) {
|
|
14
|
+
var buffer = new Buffer(inAmount * 2);
|
|
15
|
+
var bytesRead = fs.readSync(this.rs, buffer, 0, inAmount, this.rposition);
|
|
16
|
+
var arr = [];
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
18
|
+
for (var i = 0; i < bytesRead; ++i) arr.push(buffer[i]);
|
|
19
|
+
this.rposition += bytesRead;
|
|
20
|
+
return arr;
|
|
21
|
+
};
|
|
25
22
|
|
|
26
|
-
PDFRStreamForFile.prototype.notEnded = function()
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
23
|
+
PDFRStreamForFile.prototype.notEnded = function () {
|
|
24
|
+
return this.rposition < this.fileSize;
|
|
25
|
+
};
|
|
30
26
|
|
|
31
|
-
PDFRStreamForFile.prototype.setPosition = function(inPosition)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
27
|
+
PDFRStreamForFile.prototype.setPosition = function (inPosition) {
|
|
28
|
+
this.rposition = inPosition;
|
|
29
|
+
};
|
|
35
30
|
|
|
36
|
-
PDFRStreamForFile.prototype.setPositionFromEnd = function(inPosition)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
31
|
+
PDFRStreamForFile.prototype.setPositionFromEnd = function (inPosition) {
|
|
32
|
+
this.rposition = this.fileSize - inPosition;
|
|
33
|
+
};
|
|
40
34
|
|
|
41
|
-
PDFRStreamForFile.prototype.skip = function(inAmount)
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
35
|
+
PDFRStreamForFile.prototype.skip = function (inAmount) {
|
|
36
|
+
this.rposition += inAmount;
|
|
37
|
+
};
|
|
45
38
|
|
|
46
|
-
PDFRStreamForFile.prototype.getCurrentPosition = function()
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
39
|
+
PDFRStreamForFile.prototype.getCurrentPosition = function () {
|
|
40
|
+
return this.rposition;
|
|
41
|
+
};
|
|
50
42
|
|
|
51
43
|
function noop() {}
|
|
52
44
|
|
|
53
|
-
PDFRStreamForFile.prototype.close = function(inCallback)
|
|
54
|
-
|
|
55
|
-
fs.close(this.rs,inCallback ? inCallback : noop);
|
|
45
|
+
PDFRStreamForFile.prototype.close = function (inCallback) {
|
|
46
|
+
fs.close(this.rs, inCallback ? inCallback : noop);
|
|
56
47
|
};
|
|
57
48
|
|
|
58
|
-
module.exports = PDFRStreamForFile;
|
|
49
|
+
module.exports = PDFRStreamForFile;
|
package/PDFStreamForResponse.js
CHANGED
|
@@ -2,28 +2,21 @@
|
|
|
2
2
|
PDFStreamForResponse is an implementation of a write stream that writes directly to an HTTP response.
|
|
3
3
|
Using this stream frees the user from having to create a PDF file on disk when generating on-demand PDFs
|
|
4
4
|
*/
|
|
5
|
-
function PDFStreamForResponse(inResponse)
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
this.position = 0;
|
|
5
|
+
function PDFStreamForResponse(inResponse) {
|
|
6
|
+
this.response = inResponse;
|
|
7
|
+
this.position = 0;
|
|
9
8
|
}
|
|
10
9
|
|
|
11
|
-
PDFStreamForResponse.prototype.write = function(inBytesArray)
|
|
12
|
-
{
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return inBytesArray.length;
|
|
18
|
-
}
|
|
19
|
-
else
|
|
20
|
-
return 0;
|
|
10
|
+
PDFStreamForResponse.prototype.write = function (inBytesArray) {
|
|
11
|
+
if (inBytesArray.length > 0) {
|
|
12
|
+
this.response.write(new Buffer(inBytesArray));
|
|
13
|
+
this.position += inBytesArray.length;
|
|
14
|
+
return inBytesArray.length;
|
|
15
|
+
} else return 0;
|
|
21
16
|
};
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
return this.position;
|
|
18
|
+
PDFStreamForResponse.prototype.getCurrentPosition = function () {
|
|
19
|
+
return this.position;
|
|
27
20
|
};
|
|
28
21
|
|
|
29
|
-
module.exports = PDFStreamForResponse;
|
|
22
|
+
module.exports = PDFStreamForResponse;
|
package/PDFWStreamForBuffer.js
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
function PDFWStreamForBuffer()
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
this.position = 0;
|
|
1
|
+
function PDFWStreamForBuffer() {
|
|
2
|
+
this.buffer = null;
|
|
3
|
+
this.position = 0;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
|
-
PDFWStreamForBuffer.prototype.write = function(inBytesArray)
|
|
8
|
-
{
|
|
9
|
-
if(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.buffer = Buffer.from(inBytesArray);
|
|
14
|
-
}
|
|
15
|
-
else
|
|
16
|
-
{
|
|
17
|
-
this.buffer = Buffer.concat([this.buffer, Buffer.from(inBytesArray)]);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
this.position += inBytesArray.length;
|
|
21
|
-
return inBytesArray.length;
|
|
6
|
+
PDFWStreamForBuffer.prototype.write = function (inBytesArray) {
|
|
7
|
+
if (inBytesArray.length > 0) {
|
|
8
|
+
if (!this.buffer) {
|
|
9
|
+
this.buffer = Buffer.from(inBytesArray);
|
|
10
|
+
} else {
|
|
11
|
+
this.buffer = Buffer.concat([this.buffer, Buffer.from(inBytesArray)]);
|
|
22
12
|
}
|
|
23
13
|
|
|
24
|
-
|
|
14
|
+
this.position += inBytesArray.length;
|
|
15
|
+
return inBytesArray.length;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return 0;
|
|
25
19
|
};
|
|
26
20
|
|
|
27
|
-
PDFWStreamForBuffer.prototype.getCurrentPosition = function()
|
|
28
|
-
|
|
29
|
-
return this.position;
|
|
21
|
+
PDFWStreamForBuffer.prototype.getCurrentPosition = function () {
|
|
22
|
+
return this.position;
|
|
30
23
|
};
|
|
31
24
|
|
|
32
25
|
module.exports = PDFWStreamForBuffer;
|
package/PDFWStreamForFile.js
CHANGED
|
@@ -1,51 +1,38 @@
|
|
|
1
|
-
var fs = require(
|
|
1
|
+
var fs = require("fs");
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
PDFWStreamForFile is an implementation of a write stream using the supplied file path.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
function PDFWStreamForFile(inPath)
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.path = inPath;
|
|
7
|
+
function PDFWStreamForFile(inPath) {
|
|
8
|
+
this.ws = fs.createWriteStream(inPath);
|
|
9
|
+
this.position = 0;
|
|
10
|
+
this.path = inPath;
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
PDFWStreamForFile.prototype.write = function(inBytesArray)
|
|
15
|
-
{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return inBytesArray.length;
|
|
21
|
-
}
|
|
22
|
-
else
|
|
23
|
-
return 0;
|
|
13
|
+
PDFWStreamForFile.prototype.write = function (inBytesArray) {
|
|
14
|
+
if (inBytesArray.length > 0) {
|
|
15
|
+
this.ws.write(new Buffer(inBytesArray));
|
|
16
|
+
this.position += inBytesArray.length;
|
|
17
|
+
return inBytesArray.length;
|
|
18
|
+
} else return 0;
|
|
24
19
|
};
|
|
25
20
|
|
|
26
|
-
PDFWStreamForFile.prototype.getCurrentPosition = function()
|
|
27
|
-
|
|
28
|
-
return this.position;
|
|
21
|
+
PDFWStreamForFile.prototype.getCurrentPosition = function () {
|
|
22
|
+
return this.position;
|
|
29
23
|
};
|
|
30
24
|
|
|
31
|
-
PDFWStreamForFile.prototype.close = function(inCallback)
|
|
32
|
-
{
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
var self = this;
|
|
25
|
+
PDFWStreamForFile.prototype.close = function (inCallback) {
|
|
26
|
+
if (this.ws) {
|
|
27
|
+
var self = this;
|
|
36
28
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
else
|
|
45
|
-
{
|
|
46
|
-
if(inCallback)
|
|
47
|
-
inCallback();
|
|
48
|
-
}
|
|
29
|
+
this.ws.end(function () {
|
|
30
|
+
self.ws = null;
|
|
31
|
+
if (inCallback) inCallback();
|
|
32
|
+
});
|
|
33
|
+
} else {
|
|
34
|
+
if (inCallback) inCallback();
|
|
35
|
+
}
|
|
49
36
|
};
|
|
50
37
|
|
|
51
|
-
module.exports = PDFWStreamForFile;
|
|
38
|
+
module.exports = PDFWStreamForFile;
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# Welcome to MuhammaraJS
|
|
2
|
+
|
|
2
3
|
[](https://www.npmjs.org/package/muhammara)
|
|
3
4
|
[](https://github.com/julianhille/MuhammaraJS/actions/workflows/build.yml)
|
|
4
5
|
|
|
@@ -11,7 +12,6 @@ hummusJS github wiki: available [here](https://github.com/galkahana/HummusJS/wik
|
|
|
11
12
|
Welcome to HummusJS.
|
|
12
13
|
A Fast NodeJS Module for Creating, Parsing an Manipulating PDF Files and Streams.
|
|
13
14
|
|
|
14
|
-
|
|
15
15
|
Original Project
|
|
16
16
|
Project site is [here](http://www.pdfhummus.com).
|
|
17
17
|
|
package/binding.gyp
CHANGED
|
@@ -7,15 +7,28 @@
|
|
|
7
7
|
'dependencies': [
|
|
8
8
|
'./src/deps/PDFWriter/binding.gyp:pdfwriter'
|
|
9
9
|
],
|
|
10
|
+
"cflags_cc": [ "-std=c++17" ],
|
|
11
|
+
"cflags": [ "-std=c++17" ],
|
|
10
12
|
'include_dirs': [
|
|
11
13
|
'./src',
|
|
12
14
|
'./src/deps/PDFWriter',
|
|
13
15
|
'./src/deps/FreeType/include'
|
|
14
16
|
],
|
|
17
|
+
'msvs-settings':
|
|
18
|
+
{
|
|
19
|
+
'VCCLCompilerTool':
|
|
20
|
+
{
|
|
21
|
+
'AdditionalOptions':
|
|
22
|
+
[
|
|
23
|
+
'-std:c++17',
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
15
27
|
'conditions': [
|
|
16
28
|
['OS=="mac"', {
|
|
17
29
|
'xcode_settings': {
|
|
18
|
-
'CLANG_CXX_LIBRARY': 'libc++'
|
|
30
|
+
'CLANG_CXX_LIBRARY': 'libc++',
|
|
31
|
+
"OTHER_CFLAGS": [ "-std=c++17"]
|
|
19
32
|
}
|
|
20
33
|
}],
|
|
21
34
|
['OS=="win"', {
|
package/muhammara.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module "muhammara" {
|
|
2
2
|
import EventEmitter = require("events");
|
|
3
3
|
export type PosX = number;
|
|
4
4
|
export type PosY = number;
|
|
@@ -16,33 +16,36 @@ declare module 'muhammara' {
|
|
|
16
16
|
|
|
17
17
|
export function createWriter(
|
|
18
18
|
input: FilePath | WriteStream,
|
|
19
|
-
options?: PDFWriterOptions
|
|
19
|
+
options?: PDFWriterOptions
|
|
20
20
|
): PDFWriter;
|
|
21
21
|
export function createWriterToModify(
|
|
22
22
|
inFile: FilePath,
|
|
23
|
-
options?: PDFWriterToModifyOptions
|
|
23
|
+
options?: PDFWriterToModifyOptions
|
|
24
24
|
): PDFWriter;
|
|
25
25
|
export function createWriterToModify(
|
|
26
26
|
inStream: ReadStream,
|
|
27
27
|
outStream: WriteStream,
|
|
28
|
-
options?: PDFWriterToModifyOptions
|
|
28
|
+
options?: PDFWriterToModifyOptions
|
|
29
29
|
): PDFWriter;
|
|
30
30
|
|
|
31
31
|
export function createWriterToContinue(
|
|
32
32
|
restartFile: string,
|
|
33
33
|
restartStateFile: string,
|
|
34
|
-
options?: PDFWriterToContinueOptions
|
|
34
|
+
options?: PDFWriterToContinueOptions
|
|
35
35
|
): PDFWriter;
|
|
36
|
-
export function createReader(
|
|
36
|
+
export function createReader(
|
|
37
|
+
input: FilePath | ReadStream,
|
|
38
|
+
options?: PDFReaderOptions
|
|
39
|
+
): PDFReader;
|
|
37
40
|
export function recrypt(
|
|
38
41
|
originalPdfPath: FilePath,
|
|
39
42
|
newPdfPath: FilePath,
|
|
40
|
-
options?: PDFRecryptOptions
|
|
43
|
+
options?: PDFRecryptOptions
|
|
41
44
|
): void;
|
|
42
45
|
export function recrypt(
|
|
43
46
|
originalPdfStream: PDFRStreamForFile | PDFRStreamForBuffer,
|
|
44
47
|
newPdfStream: PDFWStreamForFile | PDFWStreamForBuffer,
|
|
45
|
-
options?: PDFRecryptOptions
|
|
48
|
+
options?: PDFRecryptOptions
|
|
46
49
|
): void;
|
|
47
50
|
|
|
48
51
|
export interface WriteStream {
|
|
@@ -73,7 +76,7 @@ declare module 'muhammara' {
|
|
|
73
76
|
new (
|
|
74
77
|
writer: PDFWriter,
|
|
75
78
|
pageIndex?: number,
|
|
76
|
-
ensureContentEncapsulation?: boolean
|
|
79
|
+
ensureContentEncapsulation?: boolean
|
|
77
80
|
): PDFPageModifier;
|
|
78
81
|
startContext(): this;
|
|
79
82
|
getContext(): XObjectContentContext;
|
|
@@ -83,12 +86,12 @@ declare module 'muhammara' {
|
|
|
83
86
|
left: number,
|
|
84
87
|
bottom: number,
|
|
85
88
|
right: number,
|
|
86
|
-
top: number
|
|
89
|
+
top: number
|
|
87
90
|
): this;
|
|
88
91
|
writePage(): this;
|
|
89
92
|
}
|
|
90
93
|
|
|
91
|
-
export type PDFImageType =
|
|
94
|
+
export type PDFImageType = "JPG" | "PDF" | "PNG" | "TIFF";
|
|
92
95
|
|
|
93
96
|
export interface PDFRStreamForFile extends ReadStream {
|
|
94
97
|
new (inPath: FilePath): PDFRStreamForFile;
|
|
@@ -105,41 +108,45 @@ declare module 'muhammara' {
|
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
export interface GraphicOptions extends ColorOptions {
|
|
108
|
-
type?:
|
|
111
|
+
type?: "stroke" | "fill" | "clip";
|
|
109
112
|
width?: number;
|
|
110
113
|
close?: boolean;
|
|
111
114
|
}
|
|
112
|
-
export type TransformationMatrix = [
|
|
113
|
-
|
|
115
|
+
export type TransformationMatrix = [
|
|
116
|
+
a: number,
|
|
117
|
+
b: number,
|
|
118
|
+
c: number,
|
|
119
|
+
d: number,
|
|
120
|
+
e: number,
|
|
121
|
+
f: number
|
|
122
|
+
];
|
|
114
123
|
|
|
115
124
|
enum LineJoinStyle {
|
|
116
125
|
LINEJOIN_ROUND,
|
|
117
126
|
LINEJOIN_BEVEL,
|
|
118
127
|
LINEJOIN_MITER_VARIABLE,
|
|
119
|
-
LINEJOIN_MITER
|
|
120
|
-
LINEJOIN_MITER_FIXED
|
|
128
|
+
LINEJOIN_MITER = 2,
|
|
129
|
+
LINEJOIN_MITER_FIXED = 3,
|
|
121
130
|
}
|
|
122
131
|
|
|
123
|
-
enum EEncoding
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
EEncodingHex = 'hex'
|
|
132
|
+
enum EEncoding {
|
|
133
|
+
EEncodingText = "text",
|
|
134
|
+
EEncodingCode = "code",
|
|
135
|
+
EEncodingHex = "hex",
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
enum LineCapStyle {
|
|
131
139
|
LINECAP_BUTT = 0,
|
|
132
140
|
LINECAP_ROUND,
|
|
133
|
-
LINECAP_SQUARE
|
|
141
|
+
LINECAP_SQUARE,
|
|
134
142
|
}
|
|
135
143
|
|
|
136
144
|
export interface TextRenderOptions {
|
|
137
|
-
encoding?: EEncoding
|
|
145
|
+
encoding?: EEncoding;
|
|
138
146
|
}
|
|
139
147
|
|
|
140
148
|
export type Glyph = Array<[number, number]>;
|
|
141
149
|
|
|
142
|
-
|
|
143
150
|
export interface AbstractContentContext {
|
|
144
151
|
b(): this;
|
|
145
152
|
B(): this;
|
|
@@ -208,24 +215,39 @@ declare module 'muhammara' {
|
|
|
208
215
|
Tf(fontReferenced: UsedFont | string, fontSize: number): this;
|
|
209
216
|
Tj(text: string | Glyph): this;
|
|
210
217
|
Quote(text: string | Glyph): this;
|
|
211
|
-
DoubleQuote(
|
|
218
|
+
DoubleQuote(
|
|
219
|
+
wordSpacing: number,
|
|
220
|
+
characterString: number,
|
|
221
|
+
text: string | Glyph
|
|
222
|
+
): this;
|
|
212
223
|
TJ(value: string | Glyph, options?: TextRenderOptions): this;
|
|
213
224
|
writeFreeCode(freeCode: string): this;
|
|
214
225
|
drawPath(...parameters: any[]): this; // This can't be materialized in TypeScript
|
|
215
226
|
////drawPath(...xyPairs: number[], options: GraphicOptions): this;
|
|
216
|
-
drawPath(xyPairs:
|
|
227
|
+
drawPath(xyPairs: Array<[number, number]>, options: GraphicOptions): this;
|
|
217
228
|
drawCircle(x: PosX, y: PosY, r: number, options: GraphicOptions): this;
|
|
218
229
|
drawSquare(x: PosX, y: PosY, l: number, options: GraphicOptions): this;
|
|
219
|
-
drawRectangle(
|
|
230
|
+
drawRectangle(
|
|
231
|
+
x: PosX,
|
|
232
|
+
y: PosY,
|
|
233
|
+
w: number,
|
|
234
|
+
h: number,
|
|
235
|
+
options: GraphicOptions
|
|
236
|
+
): this;
|
|
220
237
|
writeText(text: string, x: PosX, y: PosY, options?: WriteTextOptions): this;
|
|
221
|
-
drawImage(
|
|
238
|
+
drawImage(
|
|
239
|
+
x: PosX,
|
|
240
|
+
y: PosY,
|
|
241
|
+
imagePath: string,
|
|
242
|
+
options?: ImageOptions
|
|
243
|
+
): this;
|
|
222
244
|
}
|
|
223
245
|
|
|
224
246
|
export interface TransformationObject {
|
|
225
247
|
width: number;
|
|
226
248
|
height: number;
|
|
227
249
|
proportional?: boolean;
|
|
228
|
-
fit?:
|
|
250
|
+
fit?: "always" | "overflow";
|
|
229
251
|
}
|
|
230
252
|
|
|
231
253
|
export interface ImageOptions {
|
|
@@ -251,9 +273,9 @@ declare module 'muhammara' {
|
|
|
251
273
|
}
|
|
252
274
|
|
|
253
275
|
export interface PDFStreamForResponse extends WriteStream {
|
|
254
|
-
new (res:
|
|
276
|
+
new (res: NodeJS.WritableStream): PDFStreamForResponse;
|
|
255
277
|
}
|
|
256
|
-
|
|
278
|
+
|
|
257
279
|
export interface PDFWStreamForBuffer extends WriteStream {
|
|
258
280
|
new (): PDFWStreamForBuffer;
|
|
259
281
|
buffer: Promise<any>;
|
|
@@ -330,7 +352,7 @@ declare module 'muhammara' {
|
|
|
330
352
|
|
|
331
353
|
export interface ResourcesDictionary {
|
|
332
354
|
addFormXObjectMapping(formXObject: FormXObject): string;
|
|
333
|
-
addImageXObjectMapping(imageXObject: ImageXObject|number): string;
|
|
355
|
+
addImageXObjectMapping(imageXObject: ImageXObject | number): string;
|
|
334
356
|
addProcsetResource(procSetName: string): void;
|
|
335
357
|
addExtGStateMapping(stateObjectId: number): string;
|
|
336
358
|
addFontMapping(fontObjectId: number): string;
|
|
@@ -369,7 +391,10 @@ declare module 'muhammara' {
|
|
|
369
391
|
}
|
|
370
392
|
|
|
371
393
|
export interface UsedFont {
|
|
372
|
-
calculateTextDimensions(
|
|
394
|
+
calculateTextDimensions(
|
|
395
|
+
text: string | any,
|
|
396
|
+
fontSize: number
|
|
397
|
+
): TextDimension;
|
|
373
398
|
}
|
|
374
399
|
|
|
375
400
|
export interface ByteWriter {
|
|
@@ -395,7 +420,10 @@ declare module 'muhammara' {
|
|
|
395
420
|
getPagesCount(): number;
|
|
396
421
|
getTrailer(): PDFDictionary;
|
|
397
422
|
queryDictionaryObject(dictionary: PDFDictionary, name: string): PDFObject;
|
|
398
|
-
queryArrayObject(
|
|
423
|
+
queryArrayObject(
|
|
424
|
+
objectList: PDFArray,
|
|
425
|
+
index: number
|
|
426
|
+
): undefined | PDFObject;
|
|
399
427
|
parseNewObject(objectId: number): PDFObject;
|
|
400
428
|
getPageObjectID(objectId: number): number;
|
|
401
429
|
parsePageDictionary(objectId: number): PDFDictionary;
|
|
@@ -403,7 +431,11 @@ declare module 'muhammara' {
|
|
|
403
431
|
getObjectsCount(): number;
|
|
404
432
|
isEncrypted(): boolean;
|
|
405
433
|
getXrefSize(): number;
|
|
406
|
-
getXrefEntry(objectId: number): {
|
|
434
|
+
getXrefEntry(objectId: number): {
|
|
435
|
+
objectPosition: number;
|
|
436
|
+
revision: number;
|
|
437
|
+
type: number;
|
|
438
|
+
};
|
|
407
439
|
getXrefSize(): number;
|
|
408
440
|
getXrefPosition(objectId: number): number;
|
|
409
441
|
startReadingFromStream(inputStream: PDFStreamInput): ByteReader;
|
|
@@ -464,30 +496,30 @@ declare module 'muhammara' {
|
|
|
464
496
|
export interface OutputFile {
|
|
465
497
|
openFile(filePath: FilePath, append?: boolean): void;
|
|
466
498
|
closeFile(): void;
|
|
467
|
-
getFilePath(): string|undefined;
|
|
468
|
-
getOutputStream(): ByteWriterWithPosition|undefined;
|
|
499
|
+
getFilePath(): string | undefined;
|
|
500
|
+
getOutputStream(): ByteWriterWithPosition | undefined;
|
|
469
501
|
}
|
|
470
502
|
|
|
471
503
|
export interface InputFile {
|
|
472
504
|
openFile(filePath: FilePath): void;
|
|
473
505
|
closeFile(): void;
|
|
474
|
-
getFilePath(): string|undefined;
|
|
475
|
-
getFileSize(): number|undefined;
|
|
476
|
-
getInputStream(): ByteReaderWithPosition|undefined;
|
|
506
|
+
getFilePath(): string | undefined;
|
|
507
|
+
getFileSize(): number | undefined;
|
|
508
|
+
getInputStream(): ByteReaderWithPosition | undefined;
|
|
477
509
|
}
|
|
478
510
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
511
|
+
export enum EInfoTrapped {
|
|
512
|
+
EInfoTrappedTrue,
|
|
513
|
+
EInfoTrappedFalse,
|
|
514
|
+
EInfoTrappedUnknown,
|
|
515
|
+
}
|
|
484
516
|
|
|
485
517
|
export interface InfoDictionary {
|
|
486
518
|
addAdditionalInfoEntry(key: string, value: string): void;
|
|
487
519
|
removeAdditionalInfoEntry(key: string): void;
|
|
488
520
|
clearAdditionalInfoEntries(): void;
|
|
489
521
|
getAdditionalInfoEntry(key: string): string;
|
|
490
|
-
getAdditionalInfoEntries(key: string): {[key: string]: string}
|
|
522
|
+
getAdditionalInfoEntries(key: string): { [key: string]: string };
|
|
491
523
|
setCreationDate(date: string | Date): void;
|
|
492
524
|
setModDate(date: string | Date): void;
|
|
493
525
|
|
|
@@ -519,15 +551,21 @@ declare module 'muhammara' {
|
|
|
519
551
|
): number;
|
|
520
552
|
mergePDFPageToPage(target: PDFPage, sourcePageIndex: number): void;
|
|
521
553
|
appendPDFPageFromPDF(sourcePageNumber: number): number; // stream start bytes?
|
|
522
|
-
mergePDFPageToFormXObject(
|
|
523
|
-
|
|
554
|
+
mergePDFPageToFormXObject(
|
|
555
|
+
sourcePage: PDFPage,
|
|
556
|
+
targetPageNumber: number
|
|
557
|
+
): void;
|
|
558
|
+
getSourceDocumentParser(
|
|
559
|
+
input: FilePath | ReadStream,
|
|
560
|
+
options?: PDFReaderOptions
|
|
561
|
+
): PDFReader;
|
|
524
562
|
copyDirectObjectAsIs(objectToCopy: PDFObject): void;
|
|
525
563
|
copyObject(objectId: number): number;
|
|
526
564
|
copyDirectObjectWithDeepCopy(objectToCopy: PDFObject): Array<number>;
|
|
527
565
|
copyNewObjectsForDirectObject(objectIds: Array<number>): void;
|
|
528
566
|
getCopiedObjectID(objectId: number): number;
|
|
529
|
-
getCopiedObjects(): {[key: string]: number};
|
|
530
|
-
replaceSourceObjects(replaceMap: {[key: string]: number}): void;
|
|
567
|
+
getCopiedObjects(): { [key: string]: number };
|
|
568
|
+
replaceSourceObjects(replaceMap: { [key: string]: number }): void;
|
|
531
569
|
getSourceDocumentStream(): ByteReaderWithPosition;
|
|
532
570
|
}
|
|
533
571
|
|
|
@@ -540,13 +578,13 @@ declare module 'muhammara' {
|
|
|
540
578
|
writeNameValue(nameValue: string): this;
|
|
541
579
|
writeRectangleValue(values: Array<number>): this;
|
|
542
580
|
writeRectangleValue(a: number, b: number, c: number, d: number): this;
|
|
543
|
-
writeLiteralStringValue(literal: Array<number
|
|
581
|
+
writeLiteralStringValue(literal: Array<number> | string): this;
|
|
544
582
|
writeBooleanValue(boolValue: boolean): this;
|
|
545
583
|
writeObjectReferenceValue(objectId: number): this;
|
|
546
584
|
}
|
|
547
585
|
|
|
548
586
|
export interface ByteWriterWithPosition {
|
|
549
|
-
write(bytes: Array<number>):
|
|
587
|
+
write(bytes: Array<number>): number;
|
|
550
588
|
getCurrentPosition(): number;
|
|
551
589
|
}
|
|
552
590
|
|
|
@@ -557,7 +595,7 @@ declare module 'muhammara' {
|
|
|
557
595
|
enum ETokenSeparator {
|
|
558
596
|
eTokenSeparatorSpace,
|
|
559
597
|
eTokenSeparatorEndLine,
|
|
560
|
-
eTokenSeparatorNone
|
|
598
|
+
eTokenSeparatorNone,
|
|
561
599
|
}
|
|
562
600
|
|
|
563
601
|
export interface ObjectsContext {
|
|
@@ -569,7 +607,10 @@ declare module 'muhammara' {
|
|
|
569
607
|
endLine(): this;
|
|
570
608
|
endDictionary(dictionary: DictionaryContext): this;
|
|
571
609
|
endIndirectObject(): this;
|
|
572
|
-
writeIndirectObjectReference(
|
|
610
|
+
writeIndirectObjectReference(
|
|
611
|
+
objectId: FormXObjectId,
|
|
612
|
+
generationNumber?: number
|
|
613
|
+
): this;
|
|
573
614
|
startNewIndirectObject(objectId: FormXObjectId): this;
|
|
574
615
|
startNewIndirectObject(): FormXObjectId;
|
|
575
616
|
startModifiedIndirectObject(objectId: FormXObjectId): this;
|
|
@@ -647,7 +688,12 @@ declare module 'muhammara' {
|
|
|
647
688
|
PhotoshopYDensity?: number;
|
|
648
689
|
}
|
|
649
690
|
|
|
650
|
-
export type PDFRectangle = [
|
|
691
|
+
export type PDFRectangle = [
|
|
692
|
+
lowerLeftX: number,
|
|
693
|
+
lowerLeftY: number,
|
|
694
|
+
upperRightX: number,
|
|
695
|
+
upperRightY: number
|
|
696
|
+
];
|
|
651
697
|
|
|
652
698
|
export interface MergeOptions {
|
|
653
699
|
password?: string;
|
|
@@ -657,8 +703,7 @@ declare module 'muhammara' {
|
|
|
657
703
|
|
|
658
704
|
export interface AppendOptions extends MergeOptions {}
|
|
659
705
|
|
|
660
|
-
export type inInterPagesCallback = () => {}
|
|
661
|
-
|
|
706
|
+
export type inInterPagesCallback = () => {};
|
|
662
707
|
|
|
663
708
|
export interface PDFWriter {
|
|
664
709
|
end(): PDFWriter;
|
|
@@ -668,33 +713,82 @@ declare module 'muhammara' {
|
|
|
668
713
|
writePageAndReturnID(page: PDFPage): number;
|
|
669
714
|
startPageContentContext(page: PDFPage): PageContentContext;
|
|
670
715
|
pausePageContentContext(pageContextContext: PageContentContext): this;
|
|
671
|
-
createFormXObject(
|
|
716
|
+
createFormXObject(
|
|
717
|
+
x: PosX,
|
|
718
|
+
y: PosY,
|
|
719
|
+
width: Width,
|
|
720
|
+
height: Height,
|
|
721
|
+
objectId?: FormXObjectId
|
|
722
|
+
): FormXObject;
|
|
672
723
|
endFormXObject(formXObject: FormXObject): this;
|
|
673
|
-
createFormXObjectFromJPG(
|
|
724
|
+
createFormXObjectFromJPG(
|
|
725
|
+
file: FilePath | PDFRStreamForFile,
|
|
726
|
+
objectId?: FormXObjectId
|
|
727
|
+
): FormXObject;
|
|
674
728
|
getFontForFile(inFontFilePath: FilePath, index?: number): UsedFont;
|
|
675
729
|
getFontForFile(
|
|
676
730
|
inFontFilePath: FilePath,
|
|
677
731
|
inOptionalMetricsFile?: string,
|
|
678
|
-
index?: number
|
|
732
|
+
index?: number
|
|
679
733
|
): UsedFont;
|
|
680
|
-
attachURLLinktoCurrentPage(
|
|
734
|
+
attachURLLinktoCurrentPage(
|
|
735
|
+
url: string,
|
|
736
|
+
x: PosX,
|
|
737
|
+
y: PosY,
|
|
738
|
+
width: Width,
|
|
739
|
+
height: Height
|
|
740
|
+
): this;
|
|
681
741
|
shutdown(outputFilePath: FilePath): this;
|
|
682
|
-
createFormXObjectFromTIFF(
|
|
683
|
-
|
|
684
|
-
|
|
742
|
+
createFormXObjectFromTIFF(
|
|
743
|
+
filePath: FilePath | PDFRStreamForFile,
|
|
744
|
+
objectId?: FormXObjectId
|
|
745
|
+
): FormXObject;
|
|
746
|
+
createImageXObjectFromJPG(
|
|
747
|
+
filePath: FilePath | PDFRStreamForFile,
|
|
748
|
+
objectId?: FormXObjectId
|
|
749
|
+
): ImageXObject;
|
|
750
|
+
createFormXObjectFromPNG(
|
|
751
|
+
filePath: FilePath | PDFRStreamForFile,
|
|
752
|
+
objectId?: FormXObjectId
|
|
753
|
+
): FormXObject;
|
|
685
754
|
retrieveJPGImageInformation(filePath: FilePath): JPEGInformation;
|
|
686
755
|
getObjectsContext(): ObjectsContext;
|
|
687
756
|
getDocumentContext(): DocumentContext;
|
|
688
|
-
appendPDFPagesFromPDF(
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
757
|
+
appendPDFPagesFromPDF(
|
|
758
|
+
source: FilePath | ReadStream,
|
|
759
|
+
options?: AppendOptions
|
|
760
|
+
): number[];
|
|
761
|
+
mergePDFPagesToPage(
|
|
762
|
+
page: PDFPage,
|
|
763
|
+
file: FilePath | PDFRStreamForFile,
|
|
764
|
+
options?: MergeOptions,
|
|
765
|
+
callback?: inInterPagesCallback
|
|
766
|
+
): this;
|
|
767
|
+
mergePDFPagesToPage(
|
|
768
|
+
page: PDFPage,
|
|
769
|
+
file: FilePath | PDFRStreamForFile,
|
|
770
|
+
callback?: inInterPagesCallback
|
|
771
|
+
): this;
|
|
772
|
+
createPDFCopyingContext(
|
|
773
|
+
source: FilePath | ReadStream
|
|
774
|
+
): DocumentCopyingContext;
|
|
775
|
+
createFormXObjectsFromPDF(
|
|
776
|
+
file: FilePath,
|
|
777
|
+
box?: PDFBox | PDFPageBoxType,
|
|
778
|
+
options?: MergeOptions,
|
|
779
|
+
transformation?: TransformationMatrix,
|
|
780
|
+
objectIds?: FormXObjectId[]
|
|
781
|
+
): FormXObjectId[];
|
|
693
782
|
createPDFCopyingContextForModifiedFile(): DocumentCopyingContext;
|
|
694
783
|
createPDFTextString(): PDFTextString;
|
|
695
784
|
createPDFDate(): PDFDate;
|
|
696
|
-
getImageDimensions(
|
|
697
|
-
|
|
785
|
+
getImageDimensions(
|
|
786
|
+
inFontFilePath: FilePath | ReadStream
|
|
787
|
+
): RectangleDimension;
|
|
788
|
+
getImagePagesCount(
|
|
789
|
+
imagePath: FilePath,
|
|
790
|
+
options?: { password?: string }
|
|
791
|
+
): number;
|
|
698
792
|
getImageType(imagePath: FilePath): PDFImageType | undefined;
|
|
699
793
|
getModifiedFileParser(): PDFReader;
|
|
700
794
|
getModifiedInputFile(): InputFile;
|
|
@@ -704,6 +798,9 @@ declare module 'muhammara' {
|
|
|
704
798
|
|
|
705
799
|
/* Js Extensions (in muhammara.js) */
|
|
706
800
|
getEvents(): EventEmitter;
|
|
707
|
-
triggerDocumentExtensionEvent(
|
|
801
|
+
triggerDocumentExtensionEvent(
|
|
802
|
+
eventName: string | symbol,
|
|
803
|
+
eventParams: any
|
|
804
|
+
): void;
|
|
708
805
|
}
|
|
709
806
|
}
|
package/muhammara.js
CHANGED
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
var fs = require(
|
|
2
|
-
var path = require(
|
|
3
|
-
var pregyp = require(
|
|
4
|
-
var binding_path = pregyp.find(
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var fs = require("fs");
|
|
2
|
+
var path = require("path");
|
|
3
|
+
var pregyp = require("@mapbox/node-pre-gyp");
|
|
4
|
+
var binding_path = pregyp.find(
|
|
5
|
+
path.resolve(path.join(__dirname, "./package.json"))
|
|
6
|
+
);
|
|
7
|
+
var muhammara = (module.exports = require(binding_path));
|
|
8
|
+
var EventEmitter = require("events").EventEmitter;
|
|
7
9
|
|
|
8
10
|
/*
|
|
9
11
|
addons to PDFWriter prototype for events listening
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
|
-
muhammara.PDFWriter.prototype.getEvents = function() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
muhammara.PDFWriter.prototype.triggerDocumentExtensionEvent = function(eventName, eventParams) {
|
|
19
|
-
eventParams.writer = this;
|
|
20
|
-
this.getEvents().emit(eventName,eventParams);
|
|
21
|
-
}
|
|
14
|
+
muhammara.PDFWriter.prototype.getEvents = function () {
|
|
15
|
+
if (!this.events) this.events = new EventEmitter();
|
|
16
|
+
return this.events;
|
|
17
|
+
};
|
|
22
18
|
|
|
19
|
+
muhammara.PDFWriter.prototype.triggerDocumentExtensionEvent = function (
|
|
20
|
+
eventName,
|
|
21
|
+
eventParams
|
|
22
|
+
) {
|
|
23
|
+
eventParams.writer = this;
|
|
24
|
+
this.getEvents().emit(eventName, eventParams);
|
|
25
|
+
};
|
|
23
26
|
|
|
24
27
|
/*
|
|
25
28
|
addon class for simple node wrappers
|
|
26
29
|
*/
|
|
27
|
-
muhammara.PDFStreamForResponse = require(
|
|
28
|
-
muhammara.PDFWStreamForFile = require(
|
|
29
|
-
muhammara.PDFRStreamForFile = require(
|
|
30
|
-
muhammara.PDFRStreamForBuffer = require(
|
|
31
|
-
muhammara.PDFWStreamForBuffer = require(
|
|
30
|
+
muhammara.PDFStreamForResponse = require("./PDFStreamForResponse");
|
|
31
|
+
muhammara.PDFWStreamForFile = require("./PDFWStreamForFile");
|
|
32
|
+
muhammara.PDFRStreamForFile = require("./PDFRStreamForFile");
|
|
33
|
+
muhammara.PDFRStreamForBuffer = require("./PDFRStreamForBuffer");
|
|
34
|
+
muhammara.PDFWStreamForBuffer = require("./PDFWStreamForBuffer");
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# node-pre-gyp changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.10
|
|
4
|
+
- Upgraded minimist to 1.2.6 to address dependabot alert [CVE-2021-44906](https://nvd.nist.gov/vuln/detail/CVE-2021-44906)
|
|
5
|
+
|
|
3
6
|
## 1.0.9
|
|
4
7
|
- Upgraded node-fetch to 2.6.7 to address [CVE-2022-0235](https://www.cve.org/CVERecord?id=CVE-2022-0235)
|
|
5
8
|
- Upgraded detect-libc to 2.0.0 to use non-blocking NodeJS(>=12) Report API
|
|
@@ -81,7 +81,7 @@ Options include:
|
|
|
81
81
|
- `--runtime=node-webkit`: customize the runtime: `node`, `electron` and `node-webkit` are the valid options
|
|
82
82
|
- `--fallback-to-build`: fallback to building from source if pre-built binary is not available
|
|
83
83
|
- `--target=0.4.0`: Pass the target node or node-webkit version to compile against
|
|
84
|
-
- `--target_arch=ia32`: Pass the target arch and override the host `arch`.
|
|
84
|
+
- `--target_arch=ia32`: Pass the target arch and override the host `arch`. Any value that is [supported by Node.js](https://nodejs.org/api/os.html#osarch) is valid.
|
|
85
85
|
- `--target_platform=win32`: Pass the target platform and override the host `platform`. Valid values are `linux`, `darwin`, `win32`, `sunos`, `freebsd`, `openbsd`, and `aix`.
|
|
86
86
|
|
|
87
87
|
Both `--build-from-source` and `--fallback-to-build` can be passed alone or they can provide values. You can pass `--fallback-to-build=false` to override the option as declared in package.json. In addition to being able to pass `--build-from-source` you can also pass `--build-from-source=myapp` where `myapp` is the name of your module.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"_from": "@mapbox/node-pre-gyp@^1.0.5",
|
|
3
|
-
"_id": "@mapbox/node-pre-gyp@1.0.
|
|
3
|
+
"_id": "@mapbox/node-pre-gyp@1.0.10",
|
|
4
4
|
"_inBundle": false,
|
|
5
|
-
"_integrity": "sha512-
|
|
5
|
+
"_integrity": "sha512-4ySo4CjzStuprMwk35H5pPbkymjv1SF3jGLj6rAHp/xT/RF7TL7bd9CTm1xDY49K2qF7jmR/g7k+SkLETP6opA==",
|
|
6
6
|
"_location": "/@mapbox/node-pre-gyp",
|
|
7
7
|
"_phantomChildren": {},
|
|
8
8
|
"_requested": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"_requiredBy": [
|
|
20
20
|
"/"
|
|
21
21
|
],
|
|
22
|
-
"_resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.
|
|
23
|
-
"_shasum": "
|
|
22
|
+
"_resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.10.tgz",
|
|
23
|
+
"_shasum": "8e6735ccebbb1581e5a7e652244cadc8a844d03c",
|
|
24
24
|
"_spec": "@mapbox/node-pre-gyp@^1.0.5",
|
|
25
25
|
"_where": "/home/runner/work/MuhammaraJS/MuhammaraJS",
|
|
26
26
|
"author": {
|
|
@@ -93,5 +93,5 @@
|
|
|
93
93
|
"update-crosswalk": "node scripts/abi_crosswalk.js",
|
|
94
94
|
"upload-coverage": "nyc report --reporter json && codecov --clear --flags=unit --file=./coverage/coverage-final.json"
|
|
95
95
|
},
|
|
96
|
-
"version": "1.0.
|
|
96
|
+
"version": "1.0.10"
|
|
97
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muhammara",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "Create, read and modify PDF files and streams. A drop in replacement for hummusjs PDF library",
|
|
5
5
|
"homepage": "https://github.com/julianhille/Muhammarajs",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"install": "node-pre-gyp install --fallback-to-build ${EXTRA_NODE_PRE_GYP_FLAGS:-\"\"}",
|
|
15
15
|
"test": "mocha -R tap ./tests/*.js --timeout 15000",
|
|
16
|
+
"test:codestyle": "npx prettier -c ./",
|
|
16
17
|
"test:electron": "electron-mocha -R tap ./tests/*.js --timeout 15000",
|
|
17
18
|
"package": "node-pre-gyp package"
|
|
18
19
|
},
|
|
@@ -41,14 +42,12 @@
|
|
|
41
42
|
"dependencies": {
|
|
42
43
|
"@mapbox/node-pre-gyp": "^1.0.5"
|
|
43
44
|
},
|
|
44
|
-
"bundledDependencies": [
|
|
45
|
-
"@mapbox/node-pre-gyp"
|
|
46
|
-
],
|
|
47
45
|
"devDependencies": {
|
|
48
46
|
"@types/node": "^18.0.0",
|
|
49
47
|
"chai": "^4.3.6",
|
|
50
48
|
"mocha": "^8.4.0",
|
|
51
|
-
"npm": "^6.14.5"
|
|
49
|
+
"npm": "^6.14.5",
|
|
50
|
+
"prettier": "^2.7.1"
|
|
52
51
|
},
|
|
53
52
|
"binary": {
|
|
54
53
|
"module_name": "muhammara",
|
|
@@ -59,5 +58,8 @@
|
|
|
59
58
|
},
|
|
60
59
|
"publishConfig": {
|
|
61
60
|
"registry": "https://registry.npmjs.org/"
|
|
62
|
-
}
|
|
61
|
+
},
|
|
62
|
+
"bundleDependencies": [
|
|
63
|
+
"@mapbox/node-pre-gyp"
|
|
64
|
+
]
|
|
63
65
|
}
|