Added support for PDFJS to PdfFile. Migrated some operations to use this new wrapper

This commit is contained in:
Saud Fatayerji
2023-11-12 04:46:09 +03:00
parent 3fad22c4fe
commit 0d915fcc33
12 changed files with 369 additions and 223 deletions

View File

@@ -1,11 +1,12 @@
import { DocumentInitParameters, PDFPageProxy } from "pdfjs-dist/types/src/display/api.js";
import * as PDFJS from 'pdfjs-dist';
import { PdfFile } from '../../wrappers/PdfFile';
import { PDFPageProxy } from "pdfjs-dist/types/src/display/api.js";
import { Image } from 'image-js';
import { getImagesOnPage } from "./getImagesOnPage.js";
export async function detectEmptyPages(snapshot: string | URL | ArrayBuffer | DocumentInitParameters, whiteThreashold: number) {
const pdfDoc = await PDFJS.getDocument(snapshot).promise;
export async function detectEmptyPages(file: PdfFile, whiteThreashold: number): Promise<number[]> {
const pdfDoc = await file.getAsPdfJs();
const emptyPages: number[] = [];
for (let i = 1; i <= pdfDoc.numPages; i++) {