Skip to content

Commit

Permalink
Merge branch 'master' into feature/add-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joemoongit committed Sep 11, 2024
2 parents 771aaf6 + ed1ae9b commit 386c0f8
Show file tree
Hide file tree
Showing 134 changed files with 3,096 additions and 4,837 deletions.
462 changes: 294 additions & 168 deletions .github/workflows/build.yml

Large diffs are not rendered by default.

29 changes: 28 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- Tests for bold, italic, underline, strikethrough, and highlights in textboxes

## [5.0.0] - 2024-09-08

### Added

- Add electron 24.7 and 24.8
- Add electron 25.4, 25.5, 25.6, 25.7, 25.8 and 25.9
- Add electron 26.0, 26.1, 26.2, 26.3, 26.4, 26.5, 26.6
- Add electron 27.0, 27.1, 27.2 and 27.3
- Add electron 28.0, 28.1, 28.2 and 28.3
- Add electron 29.0, 29.1, 29.2, 29.3 and 29.4
- Add electron 30.0, 30.1, 30.2, 30.3 and 30.4
- Add electron 31.0, 31.1, 31.2, 31.3 and 31.4
- Add electron 32.0
- Add node v22.0.0

### Remove

- Outdated electron 23.x versions
- Node version <= 16

### Update

- Update dependencies
- Including tar which removes a security vulnerability
- new Buffer to Buffer.from

## [4.1.0] - 2023-12-13

### Fixed
Expand Down Expand Up @@ -416,7 +442,8 @@ with the following changes.

- Initial release

[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/4.1.0...HEAD
[unreleased]: https://github.com/julianhille/MuhammaraJS/compare/5.0.0...HEAD
[5.0.0]: https://github.com/julianhille/MuhammaraJS/compare/4.1.0...5.0.0
[4.1.0]: https://github.com/julianhille/MuhammaraJS/compare/4.0.0...4.1.0
[4.0.0]: https://github.com/julianhille/MuhammaraJS/compare/3.8.0...4.0.0
[3.8.0]: https://github.com/julianhille/MuhammaraJS/compare/3.7.0...3.8.0
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
[![Build status](https://github.com/julianhille/MuhammaraJS/actions/workflows/build.yml/badge.svg?branch=develop)](https://github.com/julianhille/MuhammaraJS/actions/workflows/build.yml)

Welcome to MuhammaraJS.
A Fast NodeJS Module for Creating, Parsing an Manipulating PDF Files and Streams.
A Fast NodeJS Module for creating, parsing and manipulating PDF files and streams.

Original Project (CPP base version)
Project site is [here](http://www.pdfhummus.com).

If you are looking for a C++ Library go [here](https://github.com/galkahana/PDF-Writer).
If you are looking for a C++ library go [here](https://github.com/galkahana/PDF-Writer).

## Hummus JS is the base

Expand All @@ -19,7 +19,7 @@ He did an awesome job, but discontinued hummusjs.
The documentation for MuhammaraJS / HummusJS is still located at the
hummusJS github wiki: available [here](https://github.com/galkahana/HummusJS/wiki)

## muhammara-recipe '(formerly known as hummus-recipe) as been added
## muhammara-recipe (formerly known as hummus-recipe) as been added

Muhammara-recipe and hummus-recipe has been integrated, dependencies updated
and is now shipped along with muhammara itself.
Expand Down Expand Up @@ -49,6 +49,12 @@ This won't affect a lot of you but still.
This means the glibc has been raised to 2.31 which might break pre-builts for you.
It is still possible to build for older glibc version.

### Version 5.x

- Node <= 16 pre-builts have been removed
- Electron <= 23 pre-builts have been removed
- GCC 13 needed / std ++ 20 (only needed if you compile yourself)

# Installation

```
Expand Down Expand Up @@ -167,7 +173,7 @@ pdfDoc
stroke: [0, 0, 140],
fill: [153, 143, 32],
lineWidth: 5,
}
},
)
.rectangle(240, 400, 50, 50, {
stroke: "#3b7721",
Expand Down
8 changes: 4 additions & 4 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
'dependencies': [
'./src/deps/PDFWriter/binding.gyp:pdfwriter'
],
"cflags_cc": [ "-std=c++17" ],
"cflags": [ "-std=c++17" ],
"cflags_cc": [ "-std=c++20" ],
"cflags": [ "-std=c++20" ],
'include_dirs': [
'./src',
'./src/deps/PDFWriter',
Expand All @@ -20,15 +20,15 @@
{
'AdditionalOptions':
[
'/std:c++17',
'/std:c++20',
]
}
},
'conditions': [
['OS=="mac"', {
'xcode_settings': {
'CLANG_CXX_LIBRARY': 'libc++',
"OTHER_CFLAGS": [ "-std=c++17"]
"OTHER_CFLAGS": [ "-std=c++20"]
}
}],
['OS=="win"', {
Expand Down
6 changes: 3 additions & 3 deletions docs/Embedding-pdf.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ The method call looks like this:
pdfWriter.createFormXObjectsFromPDF(
inSourceFilePath,
[inFormBox || inSourcePageBoxEnum],
[inPageRangeObject]
[inPageRangeObject],
);
```

Expand Down Expand Up @@ -72,7 +72,7 @@ You create a copying context for a source PDF using the following PDFWriter meth

```javascript
var cpyCxt = pdfWriter.createPDFCopyingContext(
inSourceFilePDF || inSourceFileStream
inSourceFilePDF || inSourceFileStream,
);
```

Expand All @@ -90,7 +90,7 @@ The following methods are available for these purposes:
cpyCxt.appendPDFPageFromPDF(inSourcePageIndex);
cpyCxt.createFormXObjectFromPDFPage(
inSourcePageIndex,
inFormBox || inPageBoxEnum
inFormBox || inPageBoxEnum,
);
cpyCxt.mergePDFPageToPage(inTargetPage, inSourcePageIndex);
cpyCxt.mergePDFPageToFormXObject(inTargetForm, inSourcePageIndex);
Expand Down
6 changes: 3 additions & 3 deletions docs/Show-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Usually you'd like to draw frames around images, or fit them. For this you'll ne

```javascript
var jpgDimensions = pdfWriter.getImageDimensions(
"./TestMaterials/Images/soundcloud_logo.jpg"
"./TestMaterials/Images/soundcloud_logo.jpg",
);
```

Expand All @@ -76,7 +76,7 @@ To create and use a PDF image object from a JPG do the following:

```javascript
var imageXObject = pdfWriter.createImageXObjectFromJPG(
"./TestMaterials/images/otherStage.JPG"
"./TestMaterials/images/otherStage.JPG",
);
var cxt = pdfWriter.startPageContentContext(page);
cxt.q().cm(500, 0, 0, 400, 0, 0).doXObject(imageXObject).Q();
Expand All @@ -96,7 +96,7 @@ If you don't wish to have an image object, but would rather a form object, that

```javascript
var formXObject = pdfWriter.createFormXObjectFromJPG(
"./TestMaterials/images/otherStage.JPG"
"./TestMaterials/images/otherStage.JPG",
);
```

Expand Down
2 changes: 1 addition & 1 deletion lib/PDFRStreamForBuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function PDFRStreamForBuffer(buffer) {
PDFRStreamForBuffer.prototype.read = function (inAmount) {
var amountToRead = inAmount;
var arr = Array.from(
this.buffer.subarray(this.rposition, this.rposition + amountToRead)
this.buffer.subarray(this.rposition, this.rposition + amountToRead),
);
this.rposition += amountToRead;
return arr;
Expand Down
2 changes: 1 addition & 1 deletion lib/PDFRStreamForFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function PDFRStreamForFile(inPath) {
}

PDFRStreamForFile.prototype.read = function (inAmount) {
var buffer = new Buffer(inAmount * 2);
var buffer = Buffer.alloc(inAmount * 2);
var bytesRead = fs.readSync(this.rs, buffer, 0, inAmount, this.rposition);
var arr = [];

Expand Down
2 changes: 1 addition & 1 deletion lib/PDFStreamForResponse.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function PDFStreamForResponse(inResponse) {

PDFStreamForResponse.prototype.write = function (inBytesArray) {
if (inBytesArray.length > 0) {
this.response.write(new Buffer(inBytesArray));
this.response.write(Buffer.from(inBytesArray));
this.position += inBytesArray.length;
return inBytesArray.length;
} else return 0;
Expand Down
2 changes: 1 addition & 1 deletion lib/PDFWStreamForFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function PDFWStreamForFile(inPath) {

PDFWStreamForFile.prototype.write = function (inBytesArray) {
if (inBytesArray.length > 0) {
this.ws.write(new Buffer(inBytesArray));
this.ws.write(Buffer.from(inBytesArray));
this.position += inBytesArray.length;
return inBytesArray.length;
} else return 0;
Expand Down
14 changes: 7 additions & 7 deletions lib/Recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class Recipe {
this.output,
Object.assign({}, this.encryptOptions, {
version: this._getVersion(this.options.version),
})
}),
);
} else {
this.read();
Expand All @@ -90,15 +90,15 @@ class Recipe {
new muhammara.PDFStreamForResponse(this.outStream),
Object.assign({}, this.encryptOptions, {
log: this.logFile,
})
}),
);
} else {
this.writer = muhammara.createWriterToModify(
this.src,
Object.assign({}, this.encryptOptions, {
modifiedFilePath: this.output,
log: this.logFile,
})
}),
);
}
} catch (err) {
Expand All @@ -122,7 +122,7 @@ class Recipe {
get position() {
const { ox, oy } = this._reverseCoordinate(
this._position.x,
this._position.y
this._position.y,
);
return {
x: ox,
Expand Down Expand Up @@ -222,15 +222,15 @@ class Recipe {
new muhammara.PDFStreamForResponse(this.outStream),
Object.assign({}, this.encryptOptions, {
log: this.logFile,
})
}),
);
} else {
this.writer = muhammara.createWriterToModify(
this.output,
Object.assign({}, this.encryptOptions, {
modifiedFilePath: this.output,
log: this.logFile,
})
}),
);
}

Expand All @@ -242,7 +242,7 @@ class Recipe {
if (this.isBufferSrc) {
// eslint-disable-next-line no-console
console.log(
"Feature: Inserting Pages is not supported in Buffer Mode yet."
"Feature: Inserting Pages is not supported in Buffer Mode yet.",
);
} else {
this._insertPages();
Expand Down
4 changes: 2 additions & 2 deletions lib/muhammara.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var path = require("path");
var pregyp = require("@mapbox/node-pre-gyp");
var binding_path = pregyp.find(
path.resolve(path.join(__dirname, "../package.json"))
path.resolve(path.join(__dirname, "../package.json")),
);
var muhammara = (module.exports = require(binding_path));
var EventEmitter = require("events").EventEmitter;
Expand All @@ -17,7 +17,7 @@ muhammara.PDFWriter.prototype.getEvents = function () {

muhammara.PDFWriter.prototype.triggerDocumentExtensionEvent = function (
eventName,
eventParams
eventParams,
) {
eventParams.writer = this;
this.getEvents().emit(eventName, eventParams);
Expand Down
6 changes: 3 additions & 3 deletions lib/recipe/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exports.annot = function annot(
x,
y,
subtype,
options = { text: "", width: 0, height: 0 }
options = { text: "", width: 0, height: 0 },
) {
const { text, width, height, replies } = options;
this.annotationsToWrite.push({
Expand Down Expand Up @@ -102,7 +102,7 @@ exports._annot = function _annot(subtype, args = {}, pageNumber, ref) {
open: false,
flag: "", // 'readonly'
},
options
options,
);

const ex = nWidth ? nWidth : 0;
Expand Down Expand Up @@ -133,7 +133,7 @@ exports._annot = function _annot(subtype, args = {}, pageNumber, ref) {
.writeLiteralStringValue(params.title || "")
.writeKey("M")
.writeLiteralStringValue(
this.writer.createPDFDate(new Date(params.date)).toString()
this.writer.createPDFDate(new Date(params.date)).toString(),
)
.writeKey("Open")
.writeBooleanValue(params.open)
Expand Down
2 changes: 1 addition & 1 deletion lib/recipe/colors.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ exports.chroma = function chroma(name, value, colorspace = "") {
// device colorspaces gray, rgb, and cmyk.
if (![2, 6, 8].includes(value.toString().length)) {
throw new Error(
"Color value has incorrect size for gray, rgb, or cmyk colorspaces"
"Color value has incorrect size for gray, rgb, or cmyk colorspaces",
);
}

Expand Down
10 changes: 5 additions & 5 deletions lib/recipe/coordinate.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ exports._calibrateCoordinate = function _calibrateCoordinate(
y,
offsetX = 0,
offsetY = 0,
pageNumber
pageNumber,
) {
pageNumber = pageNumber || this.pageNumber;
const { height, mediaBox } = this.metadata[pageNumber];
Expand All @@ -41,14 +41,14 @@ exports._calibrateCoordinateForAnnots = function _calibrateCoordinateForAnnots(
y,
offsetX = 0,
offsetY = 0,
pageNumber
pageNumber,
) {
const { nx: tx, ny: ty } = this._calibrateCoordinate(
x,
y,
offsetX,
offsetY,
pageNumber
pageNumber,
);
const { width, height, rotate, mediaBox } = this.metadata[pageNumber];
const startX = mediaBox[0];
Expand Down Expand Up @@ -78,7 +78,7 @@ exports._calibrateCoordinateForAnnots = function _calibrateCoordinateForAnnots(
ty,
360 - rotate,
rotateOffsetX,
rotateOffsetY
rotateOffsetY,
);
return {
nx,
Expand All @@ -91,7 +91,7 @@ exports._reverseCoordinate = function _reverseCoordinate(
y,
offsetX = 0,
offsetY = 0,
pageNumber
pageNumber,
) {
pageNumber = pageNumber || this.pageNumber;
const { height } = this.metadata[pageNumber];
Expand Down
2 changes: 1 addition & 1 deletion lib/recipe/encrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ exports.permission = function permission(flags = "print") {

exports._getEncryptOptions = function _getEncryptOptions(
options,
addPermissions = true
addPermissions = true,
) {
const encryptOptions = {};

Expand Down
Loading

0 comments on commit 386c0f8

Please sign in to comment.