Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies #366

Merged
merged 9 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
12 changes: 6 additions & 6 deletions lib/recipe/font.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require("path");
exports.registerFont = function registerFont(
fontName = "",
fontSrcPath = "",
type = "regular"
type = "regular",
) {
return this._registerFont(fontName, fontSrcPath, type);
};
Expand Down Expand Up @@ -55,7 +55,7 @@ exports._loadFonts = function _loadFonts(fontSrcPath) {
exports._registerFont = function _registerFont(
fontName,
fontSrcPath,
type = "regular"
type = "regular",
) {
this.fonts = this.fonts || {};
let family = fontName.toLowerCase();
Expand Down Expand Up @@ -91,10 +91,10 @@ function _getFontFile(self, options = {}) {
(options.bold || options.isBold) && (options.italic || options.isItalic)
? "bi"
: options.italic || options.isItalic
? "i"
: options.bold || options.isBold
? "b"
: "r";
? "i"
: options.bold || options.isBold
? "b"
: "r";

if (options.font) {
const fontFamily = self.fonts[options.font.toLowerCase()];
Expand Down
2 changes: 1 addition & 1 deletion lib/recipe/htmlToTextObjects.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.htmlToTextObjects = function (htmlCodes) {
htmlCodes = htmlCodes.replace(/<br\/?>/g, "<p>[@@DONOT_RENDER_THIS@@]</p>");
const nodes = new DOMParser().parseFromString(
`<html>${htmlCodes}</html>`,
"text/html"
"text/html",
);
const textObjects = parseNode(nodes).childs[0].childs;
return textObjects;
Expand Down
2 changes: 1 addition & 1 deletion lib/recipe/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
exports.image = function image(imgSrc, x, y, options = {}) {
const { width, height, offsetX, offsetY } = this._getImgOffset(
imgSrc,
options
options,
);
const imgOptions = {
transformation: {
Expand Down
10 changes: 5 additions & 5 deletions lib/recipe/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports._readInfo = function _readInfo() {
.getSourceDocumentParser()
.queryDictionaryObject(
copyCtx.getSourceDocumentParser().getTrailer(),
"Info"
"Info",
);

const oldInfo =
Expand Down Expand Up @@ -138,19 +138,19 @@ exports._writeInfo = function _writeInfo() {
case "modDate":
infoDictionary.addAdditionalInfoEntry(
"source-ModDate",
oldInfo.modDate
oldInfo.modDate,
);
break;
case "creator":
infoDictionary.addAdditionalInfoEntry(
"source-Creator",
oldInfo.creator
oldInfo.creator,
);
break;
case "producer":
infoDictionary.addAdditionalInfoEntry(
"source-Producer",
oldInfo.producer
oldInfo.producer,
);
break;
default:
Expand Down Expand Up @@ -301,7 +301,7 @@ exports.structure = function structure(output) {

const itemTrailer = pdfReader.queryDictionaryObject(
pdfReader.getTrailer(),
item
item,
);
logToFile(item);
iterateObjectTypes(itemTrailer);
Expand Down
4 changes: 2 additions & 2 deletions lib/recipe/insertPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const hummusUtils = require("./utils");
exports.insertPage = function insertPage(
afterPageNumber,
pdfSrc,
srcPageNumber
srcPageNumber,
) {
if (isNaN(afterPageNumber)) {
throw new Error("The afterPageNumber is inValid.");
Expand Down Expand Up @@ -68,7 +68,7 @@ exports._insertPages = function _insertPages() {
hummusUtils.appendPDFPagesFromPDFWithAnnotations(
pdfWriter,
info.pdfSrc,
{ specificRanges }
{ specificRanges },
);
});
}
Expand Down
14 changes: 7 additions & 7 deletions lib/recipe/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ exports.editPage = function editPage(pageNumber) {
const pageModifier = new muhammara.PDFPageModifier(
pdfWriter,
pageIndex,
true
true,
);
this.page = pageModifier;
this.pageNumber = pageNumber;
Expand All @@ -135,39 +135,39 @@ exports.editPage = function editPage(pageNumber) {
`[${startX}, ${startY}] is HERE`,
startX,
startY,
textOptions
textOptions,
);
context.writeText(
`[${startX}, width/2] is HERE`,
startX,
width / 2,
textOptions
textOptions,
);
context.writeText(
`[${startX}, height/2] is HERE`,
startX,
height / 2,
textOptions
textOptions,
);
context.writeText(
`[width/2, ${startY}] is HERE`,
width / 2,
startY,
textOptions
textOptions,
);
context.writeText(
`[height/2, ${startY}] is HERE`,
height / 2,
startY,
textOptions
textOptions,
);
}
return this;
};

exports._resumePageRotation = function _resumePageRotation(
pageNumber,
context
context,
) {
pageNumber = pageNumber || this.pageNumber;
const {
Expand Down
Loading
Loading