refactor: apply eslint

This commit is contained in:
sbplat
2024-01-04 20:17:54 -05:00
parent 5fd505d4f4
commit 9c1588d150
53 changed files with 647 additions and 636 deletions

View File

@@ -1,8 +1,8 @@
import { degrees } from 'pdf-lib';
import { PdfFile, RepresentationType } from '../wrappers/PdfFile';
import { degrees } from "pdf-lib";
import { PdfFile, RepresentationType } from "../wrappers/PdfFile";
export type RotateParamsType = {
export interface RotateParamsType {
file: PdfFile;
rotation: number|number[];
}
@@ -15,19 +15,19 @@ export async function rotatePages(params: RotateParamsType): Promise<PdfFile> {
if (Array.isArray(rotation)) {
if (rotation.length != pages.length) {
throw new Error(`Number of given rotations '${rotation.length}' is not the same as the number of pages '${pages.length}'`)
throw new Error(`Number of given rotations '${rotation.length}' is not the same as the number of pages '${pages.length}'`);
}
for (let i=0; i<rotation.length; i++) {
const oldRotation = pages[i].getRotation().angle
pages[i].setRotation(degrees(oldRotation + rotation[i]))
const oldRotation = pages[i].getRotation().angle;
pages[i].setRotation(degrees(oldRotation + rotation[i]));
}
} else {
pages.forEach(page => {
// Change page size
const oldRotation = page.getRotation().angle
page.setRotation(degrees(oldRotation + rotation))
const oldRotation = page.getRotation().angle;
page.setRotation(degrees(oldRotation + rotation));
});
}
return new PdfFile(file.originalFilename, pdfDoc, RepresentationType.PDFLibDocument, file.filename+"_rotated");
};
}