Updated Page Functions

This commit is contained in:
Felix Kaspar
2023-11-14 20:36:27 +01:00
parent 7bf100daff
commit d7feec32dd
6 changed files with 11 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
import { PDFPage } from 'pdf-lib';
import { PdfFile, fromPdfLib } from '../wrappers/PdfFile';
import { PdfFile } from '../wrappers/PdfFile';
export type ScaleContentParamsType = {
file: PdfFile;
@@ -10,7 +10,7 @@ export type ScaleContentParamsType = {
export async function scaleContent(params: ScaleContentParamsType): Promise<PdfFile> {
const { file, scaleFactor } = params;
const pdfDoc = await file.getAsPdfLib();
const pdfDoc = await file.pdflibDocument;
const pages = pdfDoc.getPages();
if (Array.isArray(scaleFactor)) {
@@ -24,7 +24,7 @@ export async function scaleContent(params: ScaleContentParamsType): Promise<PdfF
pages.forEach(page => scalePage(page, scaleFactor));
}
return fromPdfLib(pdfDoc, file.filename);
return file;
};
function scalePage(page: PDFPage, scaleFactor: number) {