Stirling-PDF/shared-operations/functions/getImagesOnPage.ts

15 lines
476 B
TypeScript
Raw Normal View History

import { PDFPageProxy } from "pdfjs-dist/types/src/display/api.js";
import PDFJS from 'pdfjs-dist';
export async function getImagesOnPage(page: PDFPageProxy) {
2023-10-27 02:56:13 +02:00
const ops = await page.getOperatorList();
const images: any = [];
2023-10-27 02:56:13 +02:00
for (var j=0; j < ops.fnArray.length; j++) {
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;
}