updated to node 22.2.0 to work with pdf.js 4.2.67

This commit is contained in:
Felix Kaspar
2024-05-16 18:52:24 +02:00
parent e72f3d5525
commit efd4bdc493
7 changed files with 88 additions and 58 deletions

View File

@@ -11,12 +11,11 @@
"dependencies": {
"@stirling-tools/joi": "github:Stirling-Tools/joi",
"buffer": "^6.0.3",
"canvas": "^2.11.2",
"i18next-resources-to-backend": "^1.2.0",
"image-js": "^0.35.5",
"memfs": "^4.9.2",
"next-i18next": "^15.1.1",
"pdf-lib": "^1.17.1",
"pdfjs-dist": "^4.0.269"
"pdfjs-dist": "^4.2.67"
}
}

View File

@@ -3,8 +3,6 @@ import { PDFPageProxy } from "pdfjs-dist/types/src/display/api";
import * as PDFJS from "pdfjs-dist";
import { createCanvas } from "canvas";
export interface PDFJSImage {
width: number;
height: number;

View File

@@ -1,4 +1,5 @@
import * as PDFJS from "pdfjs-dist";
import type { PDFDocumentProxy as PDFJSDocument } from "pdfjs-dist/types/src/display/api";
import { PDFDocument as PDFLibDocument } from "pdf-lib";

View File

@@ -6,8 +6,9 @@ export const JoiPDFFileSchema = Joi.custom((value: Express.Multer.File[] /* <- a
if(isPdfFileArray(value))
return value;
else { // File(s)
if(value.some(f => f.mimetype != "application/pdf"))
throw new Error("at least one of the files provided doesn't seem to be a PDF.");
const firstWrongFile = value.find(f => f.mimetype != "application/pdf")
if(firstWrongFile)
throw new Error(`at least one of the files provided doesn't seem to be a PDF. Got ${firstWrongFile.mimetype} instead.`);
return PdfFile.fromMulterFiles(value);
}