Changed PdfFile.filename to exclude file extensions. Other naming fixes

This commit is contained in:
Saud Fatayerji
2023-11-16 02:24:10 +03:00
parent 667583984f
commit 576b0e02f6
11 changed files with 108 additions and 83 deletions

View File

@@ -1,6 +1,6 @@
import { degrees } from 'pdf-lib';
import { PdfFile } from '../wrappers/PdfFile';
import { PdfFile, RepresentationType } from '../wrappers/PdfFile';
export type RotateParamsType = {
file: PdfFile;
@@ -10,7 +10,8 @@ export type RotateParamsType = {
export async function rotatePages(params: RotateParamsType): Promise<PdfFile> {
const { file, rotation } = params;
const pages = (await file.pdfLibDocument).getPages();
const pdfDoc = await file.pdfLibDocument;
const pages = pdfDoc.getPages();
if (Array.isArray(rotation)) {
if (rotation.length != pages.length) {
@@ -28,5 +29,5 @@ export async function rotatePages(params: RotateParamsType): Promise<PdfFile> {
});
}
return file;
return new PdfFile(file.originalFilename, pdfDoc, RepresentationType.PDFLibDocument, file.filename+"_rotated");
};