MVP - Scale Pages, Scale Content

This commit is contained in:
Felix Kaspar
2023-10-16 23:11:33 +02:00
commit 542d74b9cc
10 changed files with 569 additions and 0 deletions

16
public/index.js Normal file
View File

@@ -0,0 +1,16 @@
import { scaleContent } from "./functions/scaleContent.js";
import { scalePage, PageSize } from "./functions/scalePage.js";
(async () => {
const pdfFileInput = document.getElementById('pdfFile');
pdfFileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
if (file) {
let pdfBuffer = new Uint8Array(await file.arrayBuffer());
pdfBuffer = await scaleContent(pdfBuffer, 2);
pdfBuffer = await scalePage(pdfBuffer, PageSize.letter);
download(pdfBuffer, "pdf-lib_creation_example.pdf", "application/pdf");
}
});
})();