2023-11-08 00:11:49 +01:00
|
|
|
|
2023-11-08 01:33:22 +01:00
|
|
|
import { PDFPageProxy } from "pdfjs-dist/types/src/display/api.js";
|
2023-11-08 00:11:49 +01:00
|
|
|
import PDFJS from 'pdfjs-dist';
|
|
|
|
|
2023-11-08 01:33:22 +01:00
|
|
|
export async function getImagesOnPage(page: PDFPageProxy) {
|
2023-10-27 02:56:13 +02:00
|
|
|
const ops = await page.getOperatorList();
|
2023-11-08 01:33:22 +01:00
|
|
|
const images: any = [];
|
2023-10-27 02:56:13 +02:00
|
|
|
for (var j=0; j < ops.fnArray.length; j++) {
|
2023-11-08 01:33:22 +01:00
|
|
|
if (ops.fnArray[j] == PDFJS.OPS.paintImageXObject) {
|
2023-10-27 02:56:13 +02:00
|
|
|
const image = page.objs.get(ops.argsArray[j][0]);
|
|
|
|
images.push(image);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return images;
|
|
|
|
}
|