muhammara 4.1.0 → 5.0.1
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 +38 -3
- package/README.md +13 -4
- package/binding.gyp +4 -4
- package/lib/PDFRStreamForBuffer.js +1 -1
- package/lib/PDFRStreamForFile.js +1 -1
- package/lib/PDFStreamForResponse.js +1 -1
- package/lib/PDFWStreamForFile.js +1 -1
- package/lib/Recipe.js +7 -7
- package/lib/muhammara.js +2 -2
- package/lib/recipe/annotation.js +3 -3
- package/lib/recipe/colors.js +1 -1
- package/lib/recipe/coordinate.js +5 -5
- package/lib/recipe/encrypt.js +1 -1
- package/lib/recipe/font.js +6 -6
- package/lib/recipe/htmlToTextObjects.js +8 -5
- package/lib/recipe/image.js +1 -1
- package/lib/recipe/info.js +5 -5
- package/lib/recipe/insertPage.js +2 -2
- package/lib/recipe/page.js +7 -7
- package/lib/recipe/shapes.js +14 -14
- package/lib/recipe/split.js +1 -1
- package/lib/recipe/table.js +5 -5
- package/lib/recipe/text.helper.js +3 -3
- package/lib/recipe/text.js +28 -28
- package/lib/recipe/utils.js +3 -3
- package/lib/recipe/vector-polygon.js +2 -2
- package/lib/recipe/vector.helper.js +6 -6
- package/lib/recipe/vector.js +17 -17
- package/muhammara.d.ts +50 -46
- package/node_modules/@mapbox/node-pre-gyp/package.json +5 -5
- package/node_modules/are-we-there-yet/package.json +1 -1
- package/node_modules/balanced-match/package.json +1 -1
- package/node_modules/brace-expansion/package.json +1 -2
- package/node_modules/debug/README.md +1 -1
- package/node_modules/debug/package.json +9 -8
- package/node_modules/debug/src/browser.js +3 -1
- package/node_modules/debug/src/node.js +2 -2
- package/node_modules/detect-libc/lib/detect-libc.js +3 -15
- package/node_modules/detect-libc/lib/process.js +8 -3
- package/node_modules/detect-libc/package.json +6 -6
- package/node_modules/gauge/package.json +1 -1
- package/node_modules/glob/package.json +1 -1
- package/node_modules/inflight/package.json +1 -1
- package/node_modules/ms/index.js +1 -1
- package/node_modules/ms/license.md +1 -1
- package/node_modules/ms/package.json +19 -17
- package/node_modules/ms/readme.md +1 -2
- package/node_modules/npmlog/package.json +1 -1
- package/node_modules/path-is-absolute/package.json +1 -2
- package/node_modules/rimraf/package.json +1 -1
- package/node_modules/semver/README.md +49 -32
- package/node_modules/semver/bin/semver.js +5 -14
- package/node_modules/semver/classes/range.js +28 -13
- package/node_modules/semver/classes/semver.js +1 -1
- package/node_modules/semver/functions/coerce.js +13 -5
- package/node_modules/semver/internal/lrucache.js +40 -0
- package/node_modules/semver/internal/re.js +7 -2
- package/node_modules/semver/package.json +11 -21
- package/node_modules/tar/README.md +10 -0
- package/node_modules/tar/lib/unpack.js +22 -5
- package/node_modules/tar/package.json +5 -5
- package/node_modules/yallist/package.json +1 -2
- package/package.json +10 -10
- package/src/FormXObjectDriver.cpp +1 -1
- package/src/FormXObjectDriver.h +1 -1
- package/src/ImageXObjectDriver.cpp +1 -1
- package/src/ImageXObjectDriver.h +1 -1
- package/src/InfoDictionaryDriver.cpp +14 -14
- package/src/InfoDictionaryDriver.h +14 -14
- package/src/PDFBooleanDriver.cpp +1 -1
- package/src/PDFBooleanDriver.h +1 -1
- package/src/PDFHexStringDriver.cpp +1 -1
- package/src/PDFHexStringDriver.h +1 -1
- package/src/PDFIntegerDriver.cpp +1 -1
- package/src/PDFIntegerDriver.h +1 -1
- package/src/PDFLiteralStringDriver.cpp +1 -1
- package/src/PDFLiteralStringDriver.h +1 -1
- package/src/PDFNameDriver.cpp +1 -1
- package/src/PDFNameDriver.h +1 -1
- package/src/PDFNullDriver.cpp +1 -1
- package/src/PDFNullDriver.h +1 -1
- package/src/PDFPageDriver.cpp +12 -12
- package/src/PDFPageDriver.h +12 -12
- package/src/PDFRealDriver.cpp +1 -1
- package/src/PDFRealDriver.h +1 -1
- package/src/PDFSymbolDriver.cpp +1 -1
- package/src/PDFSymbolDriver.h +1 -1
- package/src/deps/LibTiff/tif_config.h +2 -0
- package/src/deps/ZLib/binding.gyp +3 -3
- package/src/deps/ZLib/zconf.h +6 -0
- package/src/nodes.h +10 -2
- package/node_modules/lru-cache/LICENSE +0 -15
- package/node_modules/lru-cache/README.md +0 -166
- package/node_modules/lru-cache/index.js +0 -334
- package/node_modules/lru-cache/package.json +0 -69
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,39 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [5.0.1] - 2024-09-28
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Tests for bold, italic, underline, strikethrough, and highlights in textboxes
|
|
15
|
+
- Add missing node v21 and v22 to the build matrix (#417)
|
|
16
|
+
|
|
17
|
+
## [5.0.0] - 2024-09-08
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- Add electron 24.7 and 24.8
|
|
22
|
+
- Add electron 25.4, 25.5, 25.6, 25.7, 25.8 and 25.9
|
|
23
|
+
- Add electron 26.0, 26.1, 26.2, 26.3, 26.4, 26.5, 26.6
|
|
24
|
+
- Add electron 27.0, 27.1, 27.2 and 27.3
|
|
25
|
+
- Add electron 28.0, 28.1, 28.2 and 28.3
|
|
26
|
+
- Add electron 29.0, 29.1, 29.2, 29.3 and 29.4
|
|
27
|
+
- Add electron 30.0, 30.1, 30.2, 30.3 and 30.4
|
|
28
|
+
- Add electron 31.0, 31.1, 31.2, 31.3 and 31.4
|
|
29
|
+
- Add electron 32.0
|
|
30
|
+
- Add node v22.0.0
|
|
31
|
+
|
|
32
|
+
### Remove
|
|
33
|
+
|
|
34
|
+
- Outdated electron 23.x versions
|
|
35
|
+
- Node version <= 16
|
|
36
|
+
|
|
37
|
+
### Update
|
|
38
|
+
|
|
39
|
+
- Update dependencies
|
|
40
|
+
- Including tar which removes a security vulnerability
|
|
41
|
+
- new Buffer to Buffer.from
|
|
42
|
+
|
|
10
43
|
## [4.1.0] - 2023-12-13
|
|
11
44
|
|
|
12
45
|
### Fixed
|
|
@@ -24,15 +57,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
|
24
57
|
|
|
25
58
|
### Fixed
|
|
26
59
|
|
|
27
|
-
- Underline in text object
|
|
28
60
|
- Recipe type / arg documentation
|
|
29
61
|
- Add missing type `userPassword` to `EncryptOptions`
|
|
62
|
+
- Underline in text object
|
|
30
63
|
|
|
31
64
|
### Added
|
|
32
65
|
|
|
33
|
-
- Strikethrough implementation in text object
|
|
34
66
|
- Add electron 23.2., 23.3
|
|
35
67
|
- Recipe infos to readme
|
|
68
|
+
- Strikethrough implementation in text object
|
|
36
69
|
- Electron v24.1, 24.2, 24.3, 24.4, 24.5, 24.6
|
|
37
70
|
- Add node 20.x
|
|
38
71
|
- Add electron v25.0, 25.1, 25.2, 25.3
|
|
@@ -412,7 +445,9 @@ with the following changes.
|
|
|
412
445
|
|
|
413
446
|
- Initial release
|
|
414
447
|
|
|
415
|
-
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/
|
|
448
|
+
:[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/5.0.1...HEAD
|
|
449
|
+
[5.0.1]: https://github.com/julianhille/MuhammaraJS/compare/5.0.0...5.0.1
|
|
450
|
+
[5.0.0]: https://github.com/julianhille/MuhammaraJS/compare/4.1.0...5.0.0
|
|
416
451
|
[4.1.0]: https://github.com/julianhille/MuhammaraJS/compare/4.0.0...4.1.0
|
|
417
452
|
[4.0.0]: https://github.com/julianhille/MuhammaraJS/compare/3.8.0...4.0.0
|
|
418
453
|
[3.8.0]: https://github.com/julianhille/MuhammaraJS/compare/3.7.0...3.8.0
|
package/README.md
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
[](https://github.com/julianhille/MuhammaraJS/actions/workflows/build.yml)
|
|
5
5
|
|
|
6
6
|
Welcome to MuhammaraJS.
|
|
7
|
-
A Fast NodeJS Module for
|
|
7
|
+
A Fast NodeJS Module for creating, parsing and manipulating PDF files and streams.
|
|
8
8
|
|
|
9
9
|
Original Project (CPP base version)
|
|
10
10
|
Project site is [here](http://www.pdfhummus.com).
|
|
11
11
|
|
|
12
|
-
If you are looking for a C++
|
|
12
|
+
If you are looking for a C++ library go [here](https://github.com/galkahana/PDF-Writer).
|
|
13
13
|
|
|
14
14
|
## Hummus JS is the base
|
|
15
15
|
|
|
@@ -19,7 +19,7 @@ He did an awesome job, but discontinued hummusjs.
|
|
|
19
19
|
The documentation for MuhammaraJS / HummusJS is still located at the
|
|
20
20
|
hummusJS github wiki: available [here](https://github.com/galkahana/HummusJS/wiki)
|
|
21
21
|
|
|
22
|
-
## muhammara-recipe
|
|
22
|
+
## muhammara-recipe (formerly known as hummus-recipe) as been added
|
|
23
23
|
|
|
24
24
|
Muhammara-recipe and hummus-recipe has been integrated, dependencies updated
|
|
25
25
|
and is now shipped along with muhammara itself.
|
|
@@ -49,6 +49,15 @@ This won't affect a lot of you but still.
|
|
|
49
49
|
This means the glibc has been raised to 2.31 which might break pre-builts for you.
|
|
50
50
|
It is still possible to build for older glibc version.
|
|
51
51
|
|
|
52
|
+
### Version 5.x
|
|
53
|
+
|
|
54
|
+
- You may need to update your base linux distro where you use this as muhammara now needs GLIBCXX_3.4.31
|
|
55
|
+
Github removed ubuntu 18.04 runners and so we build on 20.04 now.
|
|
56
|
+
Ubuntu 20.04 comes with newer libstdc++6 and this brings newer glibc with it.
|
|
57
|
+
- Node <= 16 pre-builts have been removed
|
|
58
|
+
- Electron <= 23 pre-builts have been removed
|
|
59
|
+
- GCC 13 needed / std ++ 20 (only needed if you compile yourself)
|
|
60
|
+
|
|
52
61
|
# Installation
|
|
53
62
|
|
|
54
63
|
```
|
|
@@ -167,7 +176,7 @@ pdfDoc
|
|
|
167
176
|
stroke: [0, 0, 140],
|
|
168
177
|
fill: [153, 143, 32],
|
|
169
178
|
lineWidth: 5,
|
|
170
|
-
}
|
|
179
|
+
},
|
|
171
180
|
)
|
|
172
181
|
.rectangle(240, 400, 50, 50, {
|
|
173
182
|
stroke: "#3b7721",
|
package/binding.gyp
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
'dependencies': [
|
|
8
8
|
'./src/deps/PDFWriter/binding.gyp:pdfwriter'
|
|
9
9
|
],
|
|
10
|
-
"cflags_cc": [ "-std=c++
|
|
11
|
-
"cflags": [ "-std=c++
|
|
10
|
+
"cflags_cc": [ "-std=c++20" ],
|
|
11
|
+
"cflags": [ "-std=c++20" ],
|
|
12
12
|
'include_dirs': [
|
|
13
13
|
'./src',
|
|
14
14
|
'./src/deps/PDFWriter',
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
{
|
|
21
21
|
'AdditionalOptions':
|
|
22
22
|
[
|
|
23
|
-
'/std:c++
|
|
23
|
+
'/std:c++20',
|
|
24
24
|
]
|
|
25
25
|
}
|
|
26
26
|
},
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
['OS=="mac"', {
|
|
29
29
|
'xcode_settings': {
|
|
30
30
|
'CLANG_CXX_LIBRARY': 'libc++',
|
|
31
|
-
"OTHER_CFLAGS": [ "-std=c++
|
|
31
|
+
"OTHER_CFLAGS": [ "-std=c++20"]
|
|
32
32
|
}
|
|
33
33
|
}],
|
|
34
34
|
['OS=="win"', {
|
|
@@ -14,7 +14,7 @@ function PDFRStreamForBuffer(buffer) {
|
|
|
14
14
|
PDFRStreamForBuffer.prototype.read = function (inAmount) {
|
|
15
15
|
var amountToRead = inAmount;
|
|
16
16
|
var arr = Array.from(
|
|
17
|
-
this.buffer.subarray(this.rposition, this.rposition + amountToRead)
|
|
17
|
+
this.buffer.subarray(this.rposition, this.rposition + amountToRead),
|
|
18
18
|
);
|
|
19
19
|
this.rposition += amountToRead;
|
|
20
20
|
return arr;
|
package/lib/PDFRStreamForFile.js
CHANGED
|
@@ -12,7 +12,7 @@ function PDFRStreamForFile(inPath) {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
PDFRStreamForFile.prototype.read = function (inAmount) {
|
|
15
|
-
var buffer =
|
|
15
|
+
var buffer = Buffer.alloc(inAmount * 2);
|
|
16
16
|
var bytesRead = fs.readSync(this.rs, buffer, 0, inAmount, this.rposition);
|
|
17
17
|
var arr = [];
|
|
18
18
|
|
|
@@ -9,7 +9,7 @@ function PDFStreamForResponse(inResponse) {
|
|
|
9
9
|
|
|
10
10
|
PDFStreamForResponse.prototype.write = function (inBytesArray) {
|
|
11
11
|
if (inBytesArray.length > 0) {
|
|
12
|
-
this.response.write(
|
|
12
|
+
this.response.write(Buffer.from(inBytesArray));
|
|
13
13
|
this.position += inBytesArray.length;
|
|
14
14
|
return inBytesArray.length;
|
|
15
15
|
} else return 0;
|
package/lib/PDFWStreamForFile.js
CHANGED
|
@@ -12,7 +12,7 @@ function PDFWStreamForFile(inPath) {
|
|
|
12
12
|
|
|
13
13
|
PDFWStreamForFile.prototype.write = function (inBytesArray) {
|
|
14
14
|
if (inBytesArray.length > 0) {
|
|
15
|
-
this.ws.write(
|
|
15
|
+
this.ws.write(Buffer.from(inBytesArray));
|
|
16
16
|
this.position += inBytesArray.length;
|
|
17
17
|
return inBytesArray.length;
|
|
18
18
|
} else return 0;
|
package/lib/Recipe.js
CHANGED
|
@@ -79,7 +79,7 @@ class Recipe {
|
|
|
79
79
|
this.output,
|
|
80
80
|
Object.assign({}, this.encryptOptions, {
|
|
81
81
|
version: this._getVersion(this.options.version),
|
|
82
|
-
})
|
|
82
|
+
}),
|
|
83
83
|
);
|
|
84
84
|
} else {
|
|
85
85
|
this.read();
|
|
@@ -90,7 +90,7 @@ class Recipe {
|
|
|
90
90
|
new muhammara.PDFStreamForResponse(this.outStream),
|
|
91
91
|
Object.assign({}, this.encryptOptions, {
|
|
92
92
|
log: this.logFile,
|
|
93
|
-
})
|
|
93
|
+
}),
|
|
94
94
|
);
|
|
95
95
|
} else {
|
|
96
96
|
this.writer = muhammara.createWriterToModify(
|
|
@@ -98,7 +98,7 @@ class Recipe {
|
|
|
98
98
|
Object.assign({}, this.encryptOptions, {
|
|
99
99
|
modifiedFilePath: this.output,
|
|
100
100
|
log: this.logFile,
|
|
101
|
-
})
|
|
101
|
+
}),
|
|
102
102
|
);
|
|
103
103
|
}
|
|
104
104
|
} catch (err) {
|
|
@@ -122,7 +122,7 @@ class Recipe {
|
|
|
122
122
|
get position() {
|
|
123
123
|
const { ox, oy } = this._reverseCoordinate(
|
|
124
124
|
this._position.x,
|
|
125
|
-
this._position.y
|
|
125
|
+
this._position.y,
|
|
126
126
|
);
|
|
127
127
|
return {
|
|
128
128
|
x: ox,
|
|
@@ -222,7 +222,7 @@ class Recipe {
|
|
|
222
222
|
new muhammara.PDFStreamForResponse(this.outStream),
|
|
223
223
|
Object.assign({}, this.encryptOptions, {
|
|
224
224
|
log: this.logFile,
|
|
225
|
-
})
|
|
225
|
+
}),
|
|
226
226
|
);
|
|
227
227
|
} else {
|
|
228
228
|
this.writer = muhammara.createWriterToModify(
|
|
@@ -230,7 +230,7 @@ class Recipe {
|
|
|
230
230
|
Object.assign({}, this.encryptOptions, {
|
|
231
231
|
modifiedFilePath: this.output,
|
|
232
232
|
log: this.logFile,
|
|
233
|
-
})
|
|
233
|
+
}),
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
|
|
@@ -242,7 +242,7 @@ class Recipe {
|
|
|
242
242
|
if (this.isBufferSrc) {
|
|
243
243
|
// eslint-disable-next-line no-console
|
|
244
244
|
console.log(
|
|
245
|
-
"Feature: Inserting Pages is not supported in Buffer Mode yet."
|
|
245
|
+
"Feature: Inserting Pages is not supported in Buffer Mode yet.",
|
|
246
246
|
);
|
|
247
247
|
} else {
|
|
248
248
|
this._insertPages();
|
package/lib/muhammara.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var path = require("path");
|
|
2
2
|
var pregyp = require("@mapbox/node-pre-gyp");
|
|
3
3
|
var binding_path = pregyp.find(
|
|
4
|
-
path.resolve(path.join(__dirname, "../package.json"))
|
|
4
|
+
path.resolve(path.join(__dirname, "../package.json")),
|
|
5
5
|
);
|
|
6
6
|
var muhammara = (module.exports = require(binding_path));
|
|
7
7
|
var EventEmitter = require("events").EventEmitter;
|
|
@@ -17,7 +17,7 @@ muhammara.PDFWriter.prototype.getEvents = function () {
|
|
|
17
17
|
|
|
18
18
|
muhammara.PDFWriter.prototype.triggerDocumentExtensionEvent = function (
|
|
19
19
|
eventName,
|
|
20
|
-
eventParams
|
|
20
|
+
eventParams,
|
|
21
21
|
) {
|
|
22
22
|
eventParams.writer = this;
|
|
23
23
|
this.getEvents().emit(eventName, eventParams);
|
package/lib/recipe/annotation.js
CHANGED
|
@@ -48,7 +48,7 @@ exports.annot = function annot(
|
|
|
48
48
|
x,
|
|
49
49
|
y,
|
|
50
50
|
subtype,
|
|
51
|
-
options = { text: "", width: 0, height: 0 }
|
|
51
|
+
options = { text: "", width: 0, height: 0 },
|
|
52
52
|
) {
|
|
53
53
|
const { text, width, height, replies } = options;
|
|
54
54
|
this.annotationsToWrite.push({
|
|
@@ -102,7 +102,7 @@ exports._annot = function _annot(subtype, args = {}, pageNumber, ref) {
|
|
|
102
102
|
open: false,
|
|
103
103
|
flag: "", // 'readonly'
|
|
104
104
|
},
|
|
105
|
-
options
|
|
105
|
+
options,
|
|
106
106
|
);
|
|
107
107
|
|
|
108
108
|
const ex = nWidth ? nWidth : 0;
|
|
@@ -133,7 +133,7 @@ exports._annot = function _annot(subtype, args = {}, pageNumber, ref) {
|
|
|
133
133
|
.writeLiteralStringValue(params.title || "")
|
|
134
134
|
.writeKey("M")
|
|
135
135
|
.writeLiteralStringValue(
|
|
136
|
-
this.writer.createPDFDate(new Date(params.date)).toString()
|
|
136
|
+
this.writer.createPDFDate(new Date(params.date)).toString(),
|
|
137
137
|
)
|
|
138
138
|
.writeKey("Open")
|
|
139
139
|
.writeBooleanValue(params.open)
|
package/lib/recipe/colors.js
CHANGED
|
@@ -81,7 +81,7 @@ exports.chroma = function chroma(name, value, colorspace = "") {
|
|
|
81
81
|
// device colorspaces gray, rgb, and cmyk.
|
|
82
82
|
if (![2, 6, 8].includes(value.toString().length)) {
|
|
83
83
|
throw new Error(
|
|
84
|
-
"Color value has incorrect size for gray, rgb, or cmyk colorspaces"
|
|
84
|
+
"Color value has incorrect size for gray, rgb, or cmyk colorspaces",
|
|
85
85
|
);
|
|
86
86
|
}
|
|
87
87
|
|
package/lib/recipe/coordinate.js
CHANGED
|
@@ -20,7 +20,7 @@ exports._calibrateCoordinate = function _calibrateCoordinate(
|
|
|
20
20
|
y,
|
|
21
21
|
offsetX = 0,
|
|
22
22
|
offsetY = 0,
|
|
23
|
-
pageNumber
|
|
23
|
+
pageNumber,
|
|
24
24
|
) {
|
|
25
25
|
pageNumber = pageNumber || this.pageNumber;
|
|
26
26
|
const { height, mediaBox } = this.metadata[pageNumber];
|
|
@@ -41,14 +41,14 @@ exports._calibrateCoordinateForAnnots = function _calibrateCoordinateForAnnots(
|
|
|
41
41
|
y,
|
|
42
42
|
offsetX = 0,
|
|
43
43
|
offsetY = 0,
|
|
44
|
-
pageNumber
|
|
44
|
+
pageNumber,
|
|
45
45
|
) {
|
|
46
46
|
const { nx: tx, ny: ty } = this._calibrateCoordinate(
|
|
47
47
|
x,
|
|
48
48
|
y,
|
|
49
49
|
offsetX,
|
|
50
50
|
offsetY,
|
|
51
|
-
pageNumber
|
|
51
|
+
pageNumber,
|
|
52
52
|
);
|
|
53
53
|
const { width, height, rotate, mediaBox } = this.metadata[pageNumber];
|
|
54
54
|
const startX = mediaBox[0];
|
|
@@ -78,7 +78,7 @@ exports._calibrateCoordinateForAnnots = function _calibrateCoordinateForAnnots(
|
|
|
78
78
|
ty,
|
|
79
79
|
360 - rotate,
|
|
80
80
|
rotateOffsetX,
|
|
81
|
-
rotateOffsetY
|
|
81
|
+
rotateOffsetY,
|
|
82
82
|
);
|
|
83
83
|
return {
|
|
84
84
|
nx,
|
|
@@ -91,7 +91,7 @@ exports._reverseCoordinate = function _reverseCoordinate(
|
|
|
91
91
|
y,
|
|
92
92
|
offsetX = 0,
|
|
93
93
|
offsetY = 0,
|
|
94
|
-
pageNumber
|
|
94
|
+
pageNumber,
|
|
95
95
|
) {
|
|
96
96
|
pageNumber = pageNumber || this.pageNumber;
|
|
97
97
|
const { height } = this.metadata[pageNumber];
|
package/lib/recipe/encrypt.js
CHANGED
package/lib/recipe/font.js
CHANGED
|
@@ -12,7 +12,7 @@ const path = require("path");
|
|
|
12
12
|
exports.registerFont = function registerFont(
|
|
13
13
|
fontName = "",
|
|
14
14
|
fontSrcPath = "",
|
|
15
|
-
type = "regular"
|
|
15
|
+
type = "regular",
|
|
16
16
|
) {
|
|
17
17
|
return this._registerFont(fontName, fontSrcPath, type);
|
|
18
18
|
};
|
|
@@ -55,7 +55,7 @@ exports._loadFonts = function _loadFonts(fontSrcPath) {
|
|
|
55
55
|
exports._registerFont = function _registerFont(
|
|
56
56
|
fontName,
|
|
57
57
|
fontSrcPath,
|
|
58
|
-
type = "regular"
|
|
58
|
+
type = "regular",
|
|
59
59
|
) {
|
|
60
60
|
this.fonts = this.fonts || {};
|
|
61
61
|
let family = fontName.toLowerCase();
|
|
@@ -91,10 +91,10 @@ function _getFontFile(self, options = {}) {
|
|
|
91
91
|
(options.bold || options.isBold) && (options.italic || options.isItalic)
|
|
92
92
|
? "bi"
|
|
93
93
|
: options.italic || options.isItalic
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
? "i"
|
|
95
|
+
: options.bold || options.isBold
|
|
96
|
+
? "b"
|
|
97
|
+
: "r";
|
|
98
98
|
|
|
99
99
|
if (options.font) {
|
|
100
100
|
const fontFamily = self.fonts[options.font.toLowerCase()];
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const DOMParser = require("@xmldom/xmldom").DOMParser;
|
|
2
2
|
|
|
3
|
-
exports.htmlToTextObjects = function (htmlCodes) {
|
|
3
|
+
exports.htmlToTextObjects = function (htmlCodes, options = {}) {
|
|
4
4
|
htmlCodes = htmlCodes.replace(/<br\/?>/g, "<p>[@@DONOT_RENDER_THIS@@]</p>");
|
|
5
5
|
const nodes = new DOMParser().parseFromString(
|
|
6
6
|
`<html>${htmlCodes}</html>`,
|
|
7
|
-
"text/html"
|
|
7
|
+
"text/html",
|
|
8
8
|
);
|
|
9
|
-
const textObjects = parseNode(nodes).childs[0].childs;
|
|
9
|
+
const textObjects = parseNode(nodes, options).childs[0].childs;
|
|
10
10
|
return textObjects;
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -40,7 +40,7 @@ function isItalicTag(tagName = "") {
|
|
|
40
40
|
return italicTags.includes(tagName);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function parseNode(node) {
|
|
43
|
+
function parseNode(node, options) {
|
|
44
44
|
const attributes = [];
|
|
45
45
|
const styles = {};
|
|
46
46
|
for (let i in node.attributes) {
|
|
@@ -82,6 +82,7 @@ function parseNode(node) {
|
|
|
82
82
|
const parsedData = {
|
|
83
83
|
value,
|
|
84
84
|
tag: node.tagName,
|
|
85
|
+
font: options.font,
|
|
85
86
|
isBold: isBoldTag(node.tagName),
|
|
86
87
|
isItalic: isItalicTag(node.tagName),
|
|
87
88
|
underline: node.tagName == "u",
|
|
@@ -89,12 +90,14 @@ function parseNode(node) {
|
|
|
89
90
|
attributes,
|
|
90
91
|
styles,
|
|
91
92
|
needsLineBreaker: needsLineBreaker(node.tagName),
|
|
93
|
+
size: options.size,
|
|
92
94
|
sizeRatio: getFontSizeRatio(node.tagName),
|
|
95
|
+
sizeRatios: [getFontSizeRatio(node.tagName)],
|
|
93
96
|
link: node.tagName == "a" ? node.attributes[0].value : null,
|
|
94
97
|
childs: [],
|
|
95
98
|
};
|
|
96
99
|
for (let num in node.childNodes) {
|
|
97
|
-
parsedData.childs.push(parseNode(node.childNodes[num]));
|
|
100
|
+
parsedData.childs.push(parseNode(node.childNodes[num], options));
|
|
98
101
|
}
|
|
99
102
|
const ignoreValue = ["\n", "\n\n"];
|
|
100
103
|
parsedData.childs = parsedData.childs.filter((item) => {
|
package/lib/recipe/image.js
CHANGED
package/lib/recipe/info.js
CHANGED
|
@@ -36,7 +36,7 @@ exports._readInfo = function _readInfo() {
|
|
|
36
36
|
.getSourceDocumentParser()
|
|
37
37
|
.queryDictionaryObject(
|
|
38
38
|
copyCtx.getSourceDocumentParser().getTrailer(),
|
|
39
|
-
"Info"
|
|
39
|
+
"Info",
|
|
40
40
|
);
|
|
41
41
|
|
|
42
42
|
const oldInfo =
|
|
@@ -138,19 +138,19 @@ exports._writeInfo = function _writeInfo() {
|
|
|
138
138
|
case "modDate":
|
|
139
139
|
infoDictionary.addAdditionalInfoEntry(
|
|
140
140
|
"source-ModDate",
|
|
141
|
-
oldInfo.modDate
|
|
141
|
+
oldInfo.modDate,
|
|
142
142
|
);
|
|
143
143
|
break;
|
|
144
144
|
case "creator":
|
|
145
145
|
infoDictionary.addAdditionalInfoEntry(
|
|
146
146
|
"source-Creator",
|
|
147
|
-
oldInfo.creator
|
|
147
|
+
oldInfo.creator,
|
|
148
148
|
);
|
|
149
149
|
break;
|
|
150
150
|
case "producer":
|
|
151
151
|
infoDictionary.addAdditionalInfoEntry(
|
|
152
152
|
"source-Producer",
|
|
153
|
-
oldInfo.producer
|
|
153
|
+
oldInfo.producer,
|
|
154
154
|
);
|
|
155
155
|
break;
|
|
156
156
|
default:
|
|
@@ -301,7 +301,7 @@ exports.structure = function structure(output) {
|
|
|
301
301
|
|
|
302
302
|
const itemTrailer = pdfReader.queryDictionaryObject(
|
|
303
303
|
pdfReader.getTrailer(),
|
|
304
|
-
item
|
|
304
|
+
item,
|
|
305
305
|
);
|
|
306
306
|
logToFile(item);
|
|
307
307
|
iterateObjectTypes(itemTrailer);
|
package/lib/recipe/insertPage.js
CHANGED
|
@@ -13,7 +13,7 @@ const hummusUtils = require("./utils");
|
|
|
13
13
|
exports.insertPage = function insertPage(
|
|
14
14
|
afterPageNumber,
|
|
15
15
|
pdfSrc,
|
|
16
|
-
srcPageNumber
|
|
16
|
+
srcPageNumber,
|
|
17
17
|
) {
|
|
18
18
|
if (isNaN(afterPageNumber)) {
|
|
19
19
|
throw new Error("The afterPageNumber is inValid.");
|
|
@@ -68,7 +68,7 @@ exports._insertPages = function _insertPages() {
|
|
|
68
68
|
hummusUtils.appendPDFPagesFromPDFWithAnnotations(
|
|
69
69
|
pdfWriter,
|
|
70
70
|
info.pdfSrc,
|
|
71
|
-
{ specificRanges }
|
|
71
|
+
{ specificRanges },
|
|
72
72
|
);
|
|
73
73
|
});
|
|
74
74
|
}
|
package/lib/recipe/page.js
CHANGED
|
@@ -111,7 +111,7 @@ exports.editPage = function editPage(pageNumber) {
|
|
|
111
111
|
const pageModifier = new muhammara.PDFPageModifier(
|
|
112
112
|
pdfWriter,
|
|
113
113
|
pageIndex,
|
|
114
|
-
true
|
|
114
|
+
true,
|
|
115
115
|
);
|
|
116
116
|
this.page = pageModifier;
|
|
117
117
|
this.pageNumber = pageNumber;
|
|
@@ -135,31 +135,31 @@ exports.editPage = function editPage(pageNumber) {
|
|
|
135
135
|
`[${startX}, ${startY}] is HERE`,
|
|
136
136
|
startX,
|
|
137
137
|
startY,
|
|
138
|
-
textOptions
|
|
138
|
+
textOptions,
|
|
139
139
|
);
|
|
140
140
|
context.writeText(
|
|
141
141
|
`[${startX}, width/2] is HERE`,
|
|
142
142
|
startX,
|
|
143
143
|
width / 2,
|
|
144
|
-
textOptions
|
|
144
|
+
textOptions,
|
|
145
145
|
);
|
|
146
146
|
context.writeText(
|
|
147
147
|
`[${startX}, height/2] is HERE`,
|
|
148
148
|
startX,
|
|
149
149
|
height / 2,
|
|
150
|
-
textOptions
|
|
150
|
+
textOptions,
|
|
151
151
|
);
|
|
152
152
|
context.writeText(
|
|
153
153
|
`[width/2, ${startY}] is HERE`,
|
|
154
154
|
width / 2,
|
|
155
155
|
startY,
|
|
156
|
-
textOptions
|
|
156
|
+
textOptions,
|
|
157
157
|
);
|
|
158
158
|
context.writeText(
|
|
159
159
|
`[height/2, ${startY}] is HERE`,
|
|
160
160
|
height / 2,
|
|
161
161
|
startY,
|
|
162
|
-
textOptions
|
|
162
|
+
textOptions,
|
|
163
163
|
);
|
|
164
164
|
}
|
|
165
165
|
return this;
|
|
@@ -167,7 +167,7 @@ exports.editPage = function editPage(pageNumber) {
|
|
|
167
167
|
|
|
168
168
|
exports._resumePageRotation = function _resumePageRotation(
|
|
169
169
|
pageNumber,
|
|
170
|
-
context
|
|
170
|
+
context,
|
|
171
171
|
) {
|
|
172
172
|
pageNumber = pageNumber || this.pageNumber;
|
|
173
173
|
const {
|
package/lib/recipe/shapes.js
CHANGED
|
@@ -88,8 +88,8 @@ function _n_gon(sides, cx, cy, radius, options = {}) {
|
|
|
88
88
|
lineWidth = options.lineWidth
|
|
89
89
|
? options.lineWidth
|
|
90
90
|
: options.width
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
? options.width
|
|
92
|
+
: 2;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
let ngon = [];
|
|
@@ -372,7 +372,7 @@ exports.triangle = function triangle(x, y, traits, options = {}) {
|
|
|
372
372
|
|
|
373
373
|
if (traits.length !== 3) {
|
|
374
374
|
throw new Error(
|
|
375
|
-
"Triangle requires 3 traits (sides/angles) for definition."
|
|
375
|
+
"Triangle requires 3 traits (sides/angles) for definition.",
|
|
376
376
|
);
|
|
377
377
|
}
|
|
378
378
|
|
|
@@ -456,21 +456,21 @@ exports.triangle = function triangle(x, y, traits, options = {}) {
|
|
|
456
456
|
[ma_A.point(1).x, ma_A.point(1).y],
|
|
457
457
|
[ma_A.point(2).x, ma_A.point(2).y],
|
|
458
458
|
],
|
|
459
|
-
{ color: "green", width: 0.5 }
|
|
459
|
+
{ color: "green", width: 0.5 },
|
|
460
460
|
);
|
|
461
461
|
this.line(
|
|
462
462
|
[
|
|
463
463
|
[mb_B.point(1).x, mb_B.point(1).y],
|
|
464
464
|
[mb_B.point(2).x, mb_B.point(2).y],
|
|
465
465
|
],
|
|
466
|
-
{ color: "green", width: 0.5 }
|
|
466
|
+
{ color: "green", width: 0.5 },
|
|
467
467
|
);
|
|
468
468
|
this.line(
|
|
469
469
|
[
|
|
470
470
|
[mc_C.point(1).x, mc_C.point(1).y],
|
|
471
471
|
[mc_C.point(2).x, mc_C.point(2).y],
|
|
472
472
|
],
|
|
473
|
-
{ color: "green", width: 0.5 }
|
|
473
|
+
{ color: "green", width: 0.5 },
|
|
474
474
|
);
|
|
475
475
|
}
|
|
476
476
|
|
|
@@ -478,7 +478,7 @@ exports.triangle = function triangle(x, y, traits, options = {}) {
|
|
|
478
478
|
triangle.incenter.point.x,
|
|
479
479
|
triangle.incenter.point.y,
|
|
480
480
|
triangle.incenter.radius,
|
|
481
|
-
{ color: "green", width: 0.5 }
|
|
481
|
+
{ color: "green", width: 0.5 },
|
|
482
482
|
);
|
|
483
483
|
let ctr_A = new Line(triangle.incenter.point, triangle.A);
|
|
484
484
|
let ap = ctr_A.extend(10);
|
|
@@ -533,7 +533,7 @@ const Triangle = class Triangle {
|
|
|
533
533
|
});
|
|
534
534
|
if (sss[0] + sss[1] <= sss[2]) {
|
|
535
535
|
throw new Error(
|
|
536
|
-
"Not a valid triangle inequality (sum of 2 shortest sides must be greater than third side"
|
|
536
|
+
"Not a valid triangle inequality (sum of 2 shortest sides must be greater than third side",
|
|
537
537
|
);
|
|
538
538
|
}
|
|
539
539
|
|
|
@@ -550,7 +550,7 @@ const Triangle = class Triangle {
|
|
|
550
550
|
angC = 180 - angA - angB;
|
|
551
551
|
if (angC <= 0) {
|
|
552
552
|
throw new Error(
|
|
553
|
-
"Not a valid triangle angle specification (sum of 2 angles must less than 180)"
|
|
553
|
+
"Not a valid triangle angle specification (sum of 2 angles must less than 180)",
|
|
554
554
|
);
|
|
555
555
|
}
|
|
556
556
|
a = (c * Math.sin(toRadians(angA))) / Math.sin(toRadians(angC));
|
|
@@ -861,7 +861,7 @@ exports.arrow = function arrow(x, y, options = {}) {
|
|
|
861
861
|
head.I[0],
|
|
862
862
|
y - halfShaft,
|
|
863
863
|
head.E[0],
|
|
864
|
-
y - halfShaft
|
|
864
|
+
y - halfShaft,
|
|
865
865
|
);
|
|
866
866
|
const ke_shaft_intercept = KE.intersect(shaft_top);
|
|
867
867
|
arrow.joinShaft(ke_shaft_intercept);
|
|
@@ -894,7 +894,7 @@ exports.arrow = function arrow(x, y, options = {}) {
|
|
|
894
894
|
arrow.tip.K,
|
|
895
895
|
arrow.tip.I,
|
|
896
896
|
],
|
|
897
|
-
options
|
|
897
|
+
options,
|
|
898
898
|
);
|
|
899
899
|
} else {
|
|
900
900
|
// Starting at arrow head tip (Pt I below),
|
|
@@ -921,7 +921,7 @@ exports.arrow = function arrow(x, y, options = {}) {
|
|
|
921
921
|
arrow.tip.K,
|
|
922
922
|
arrow.tip.I,
|
|
923
923
|
],
|
|
924
|
-
options
|
|
924
|
+
options,
|
|
925
925
|
); // back to point of arrow to close polygon
|
|
926
926
|
}
|
|
927
927
|
|
|
@@ -1193,7 +1193,7 @@ const Line = class Line {
|
|
|
1193
1193
|
if (!this._length) {
|
|
1194
1194
|
this._length = Math.sqrt(
|
|
1195
1195
|
Math.pow(this._pt2.x - this._pt1.x, 2) +
|
|
1196
|
-
Math.pow(this._pt2.y - this._pt1.y, 2)
|
|
1196
|
+
Math.pow(this._pt2.y - this._pt1.y, 2),
|
|
1197
1197
|
);
|
|
1198
1198
|
}
|
|
1199
1199
|
|
|
@@ -1243,7 +1243,7 @@ const Line = class Line {
|
|
|
1243
1243
|
deltaX = distance * ss;
|
|
1244
1244
|
deltaY = slope * deltaX;
|
|
1245
1245
|
newLen = Math.sqrt(
|
|
1246
|
-
Math.pow(opt.x - (x + deltaX), 2) + Math.pow(opt.y - (y + deltaY), 2)
|
|
1246
|
+
Math.pow(opt.x - (x + deltaX), 2) + Math.pow(opt.y - (y + deltaY), 2),
|
|
1247
1247
|
);
|
|
1248
1248
|
break;
|
|
1249
1249
|
}
|