mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2024-12-27 00:07:01 +01:00
19 lines
471 B
JavaScript
19 lines
471 B
JavaScript
|
|
import { PDFDocument, ParseSpeeds, degrees } from 'pdf-lib';
|
|
|
|
export async function rotatePages(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();
|
|
}; |