pdfcpu & wasm update, server side functions init, README.md, CONTRIBUTE.md

This commit is contained in:
Felix Kaspar
2023-10-18 23:56:56 +02:00
parent 21e0385a31
commit c60de02e14
16 changed files with 360 additions and 32 deletions

31
functions/scalePage.js Normal file
View File

@@ -0,0 +1,31 @@
import { PDFDocument, ParseSpeeds } from 'pdf-lib'
export const scalePage = async (snapshot, page_size) => {
// Load the original PDF file
const pdfDoc = await PDFDocument.load(snapshot, {
parseSpeed: ParseSpeeds.Fastest,
});
const new_size = page_size;
const pages = pdfDoc.getPages();
pages.forEach(page => {
// Change page size
page.setSize(new_size.width, new_size.height);
});
// Serialize the modified document
return pdfDoc.save();
};
export const PageSize = {
a4: {
width: 594.96,
height: 841.92
},
letter: {
width: 612,
height: 792
}
};