Removed duplicate code of node backend

Frontend traverser needs to be updated
This commit is contained in:
Felix Kaspar
2023-10-22 00:55:28 +02:00
parent b5ba2b25cd
commit 26cdb1d04f
19 changed files with 128 additions and 255 deletions

View File

@@ -1,9 +1,7 @@
const { PDFDocument, ParseSpeeds } = PDFLib;
export const scaleContent = async (snapshot, scale_factor) => {
export async function scaleContent(snapshot, scaleFactor, PDFLib) {
// Load the original PDF file
const pdfDoc = await PDFDocument.load(snapshot, {
parseSpeed: ParseSpeeds.Fastest,
const pdfDoc = await PDFLib.PDFDocument.load(snapshot, {
parseSpeed: PDFLib.ParseSpeeds.Fastest,
});
const pages = pdfDoc.getPages();
@@ -13,10 +11,10 @@ export const scaleContent = async (snapshot, scale_factor) => {
const height = page.getHeight();
// Scale content
page.scaleContent(scale_factor, scale_factor);
page.scaleContent(scaleFactor, scaleFactor);
const scaled_diff = {
width: Math.round(width - scale_factor * width),
height: Math.round(height - scale_factor * height),
width: Math.round(width - scaleFactor * width),
height: Math.round(height - scaleFactor * height),
};
// Center content in new page format