created a PoC for the client
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
|
||||
import PDFLib from 'pdf-lib';
|
||||
import { PDFDocument, ParseSpeeds, degrees } from 'pdf-lib';
|
||||
|
||||
export async function rotatePages (snapshot, rotation) {
|
||||
export async function rotatePages(snapshot, rotation) {
|
||||
// Load the original PDF file
|
||||
const pdfDoc = await PDFLib.PDFDocument.load(snapshot, {
|
||||
parseSpeed: PDFLib.ParseSpeeds.Fastest,
|
||||
const pdfDoc = await PDFDocument.load(snapshot, {
|
||||
parseSpeed: ParseSpeeds.Fastest,
|
||||
});
|
||||
|
||||
const pages = pdfDoc.getPages();
|
||||
|
||||
pages.forEach(page => {
|
||||
// Change page size
|
||||
page.setRotation(PDFLib.degrees(rotation))
|
||||
page.setRotation(degrees(rotation))
|
||||
});
|
||||
|
||||
// Serialize the modified document
|
||||
|
||||
Reference in New Issue
Block a user