mirror of
				https://github.com/Frooodle/Stirling-PDF.git
				synced 2025-11-01 01:21:18 +01:00 
			
		
		
		
	Cleanup, Typed Images
This commit is contained in:
		
							parent
							
								
									ae99ba0fab
								
							
						
					
					
						commit
						8f1f64f6c0
					
				@ -29,7 +29,6 @@ router.post("/:workflowUuid?", [
 | 
				
			|||||||
            return new PdfFile(file.originalname.replace(/\.[^/.]+$/, ""), new Uint8Array(await file.buffer), RepresentationType.Uint8Array, file.originalname.replace(/\.[^/.]+$/, ""));
 | 
					            return new PdfFile(file.originalname.replace(/\.[^/.]+$/, ""), new Uint8Array(await file.buffer), RepresentationType.Uint8Array, file.originalname.replace(/\.[^/.]+$/, ""));
 | 
				
			||||||
        }));
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // TODO: Enable if traverse & organize migration is done.
 | 
					 | 
				
			||||||
        // Allow option to do it synchronously and just make a long request
 | 
					        // Allow option to do it synchronously and just make a long request
 | 
				
			||||||
        if(req.body.async === "false") {
 | 
					        if(req.body.async === "false") {
 | 
				
			||||||
            console.log("Don't do async");
 | 
					            console.log("Don't do async");
 | 
				
			||||||
 | 
				
			|||||||
@ -1,14 +1,22 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { PDFPageProxy } from "pdfjs-dist/types/src/display/api.js";
 | 
					import { PDFPageProxy } from "pdfjs-dist/types/src/display/api.js";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import * as PDFJS from 'pdfjs-dist';
 | 
					import * as PDFJS from 'pdfjs-dist';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// TODO: Type Return Value
 | 
					export type PDFJSImage = {
 | 
				
			||||||
export async function getImagesOnPage(page: PDFPageProxy) {
 | 
					    width: number;
 | 
				
			||||||
 | 
					    height: number;
 | 
				
			||||||
 | 
					    interpolate?: any;
 | 
				
			||||||
 | 
					    kind: number;
 | 
				
			||||||
 | 
					    data: Uint8Array;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export async function getImagesOnPage(page: PDFPageProxy): Promise<PDFJSImage[]> {
 | 
				
			||||||
    const ops = await page.getOperatorList();
 | 
					    const ops = await page.getOperatorList();
 | 
				
			||||||
    const images: any = [];
 | 
					    const images: PDFJSImage[] = [];
 | 
				
			||||||
    for (var j=0; j < ops.fnArray.length; j++) {
 | 
					    for (var j=0; j < ops.fnArray.length; j++) {
 | 
				
			||||||
        if (ops.fnArray[j] == PDFJS.OPS.paintImageXObject) {
 | 
					        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);
 | 
					            images.push(image);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,7 +1,7 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import { PdfFile } from '../../wrappers/PdfFile';
 | 
					import { PdfFile } from '../../wrappers/PdfFile';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export async function sortPdfs(
 | 
					export async function sortPdfArray(
 | 
				
			||||||
        files: PdfFile[],
 | 
					        files: PdfFile[],
 | 
				
			||||||
        sortType: "orderProvided"|"byFileName"|"byDateModified"|"byDateCreated"|"byPDFTitle" = "orderProvided"
 | 
					        sortType: "orderProvided"|"byFileName"|"byDateModified"|"byDateCreated"|"byPDFTitle" = "orderProvided"
 | 
				
			||||||
    ): Promise<PdfFile[]> {
 | 
					    ): Promise<PdfFile[]> {
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user