extract, rotate, split

This commit is contained in:
Felix Kaspar
2023-10-17 03:40:54 +02:00
parent 8e8c4596bf
commit fddbec2408
6 changed files with 185 additions and 5 deletions

View File

@@ -0,0 +1,18 @@
const { PDFDocument, ParseSpeeds, degrees } = PDFLib;
export const rotatePages = async (snapshot, rotation) => {
// Load the original PDF file
const pdfDoc = await PDFDocument.load(snapshot, {
parseSpeed: ParseSpeeds.Fastest,
});
const pages = pdfDoc.getPages();
pages.forEach(page => {
// Change page size
page.setRotation(degrees(rotation))
});
// Serialize the modified document
return pdfDoc.save();
};