jobs. folder-job, file-change-trigger and some cleanup
This commit is contained in:
@@ -13,16 +13,19 @@ export async function detectQRCodePages(file: PdfFile) {
|
||||
const page = await pdfDoc.getPage(i + 1);
|
||||
|
||||
const images = await getImagesOnPage(page);
|
||||
// console.log("images:", images);
|
||||
console.log("images:", images);
|
||||
for (const image of images) {
|
||||
const data = await checkForQROnImage(image);
|
||||
if(["https://github.com/Stirling-Tools/Stirling-PDF", "https://github.com/Frooodle/Stirling-PDF"].includes(data)) {
|
||||
pagesWithQR.push(i);
|
||||
}
|
||||
else {
|
||||
console.log("Found QR code with unrelated data: " + data);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(pagesWithQR.length == 0) {
|
||||
console.warn("Could not find any QR Codes in the provided PDF.");
|
||||
console.warn("Could not find any QR Codes in the provided PDF. This may happen if the provided QR-Code is not an image but a path (e.g. SVG).");
|
||||
}
|
||||
return pagesWithQR;
|
||||
}
|
||||
|
||||
@@ -16,10 +16,11 @@ export async function getImagesOnPage(page: PDFPageProxy): Promise<PDFJSImage[]>
|
||||
const images: PDFJSImage[] = [];
|
||||
for (let j=0; j < ops.fnArray.length; j++) {
|
||||
if (ops.fnArray[j] == PDFJS.OPS.paintImageXObject) {
|
||||
const image: PDFJSImage = page.objs.get(ops.argsArray[j][0])
|
||||
|
||||
console.log("Image: ", image);
|
||||
images.push(image);
|
||||
console.log("Found", ops.argsArray[j])
|
||||
page.objs.get(ops.argsArray[j][0], (image: PDFJSImage) => {
|
||||
console.log("Image: ", image);
|
||||
images.push(image);
|
||||
})
|
||||
}
|
||||
}
|
||||
return images;
|
||||
|
||||
Reference in New Issue
Block a user