mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2025-01-23 00:06:08 +01:00
18 lines
463 B
JavaScript
18 lines
463 B
JavaScript
import { PDFDocument, ParseSpeeds } from 'pdf-lib'
|
|
|
|
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();
|
|
}; |