Cleanup, Typed Images
This commit is contained in:
@@ -1,14 +1,22 @@
|
||||
|
||||
import { PDFPageProxy } from "pdfjs-dist/types/src/display/api.js";
|
||||
|
||||
import * as PDFJS from 'pdfjs-dist';
|
||||
|
||||
// TODO: Type Return Value
|
||||
export async function getImagesOnPage(page: PDFPageProxy) {
|
||||
export type PDFJSImage = {
|
||||
width: number;
|
||||
height: number;
|
||||
interpolate?: any;
|
||||
kind: number;
|
||||
data: Uint8Array;
|
||||
};
|
||||
|
||||
export async function getImagesOnPage(page: PDFPageProxy): Promise<PDFJSImage[]> {
|
||||
const ops = await page.getOperatorList();
|
||||
const images: any = [];
|
||||
const images: PDFJSImage[] = [];
|
||||
for (var j=0; j < ops.fnArray.length; j++) {
|
||||
if (ops.fnArray[j] == PDFJS.OPS.paintImageXObject) {
|
||||
const image = page.objs.get(ops.argsArray[j][0]);
|
||||
const image = page.objs.get(ops.argsArray[j][0]) as PDFJSImage;
|
||||
images.push(image);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
import { PdfFile } from '../../wrappers/PdfFile';
|
||||
|
||||
export async function sortPdfs(
|
||||
export async function sortPdfArray(
|
||||
files: PdfFile[],
|
||||
sortType: "orderProvided"|"byFileName"|"byDateModified"|"byDateCreated"|"byPDFTitle" = "orderProvided"
|
||||
): Promise<PdfFile[]> {
|
||||
Reference in New Issue
Block a user