aboutsummaryrefslogtreecommitdiffstats
path: root/src/scripts/functionality/mutation-application.ts
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-05-14 06:45:59 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2023-05-14 07:08:01 +0530
commitdedb4d40f2c64fc0ee507b021ac89d967a71e6df (patch)
treed8374624f0c5183e1f7ec13c200bae55b7eba5cf /src/scripts/functionality/mutation-application.ts
parentf073736852cf18bed789cc1150d8dc6d371174c9 (diff)
downloadbanglar-bhumi-utils-dedb4d40f2c64fc0ee507b021ac89d967a71e6df.tar.gz
banglar-bhumi-utils-dedb4d40f2c64fc0ee507b021ac89d967a71e6df.zip
Added date-time stamp to the bottom of the mutation application declaration pdf.
Diffstat (limited to 'src/scripts/functionality/mutation-application.ts')
-rw-r--r--src/scripts/functionality/mutation-application.ts13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/scripts/functionality/mutation-application.ts b/src/scripts/functionality/mutation-application.ts
index 3283089..afc133f 100644
--- a/src/scripts/functionality/mutation-application.ts
+++ b/src/scripts/functionality/mutation-application.ts
@@ -1,4 +1,4 @@
-import { PDFDocument } from "pdf-lib";
+import { PDFDocument, StandardFonts } from "pdf-lib";
import { observeDOM } from "@/shared/observe-dom";
const sanghaFacilitationCentreBannerUrl = chrome.runtime.getURL("/assets/sangha-facilitation-centre-banner.jpg");
@@ -25,11 +25,20 @@ document.addEventListener("DOMContentLoaded", () => {
const lastPage = pages[pages.length - 1];
const { width, height } = lastPage.getSize();
const bannerImage = await pdfDoc.embedJpg(await fetch(sanghaFacilitationCentreBannerUrl).then(res => res.arrayBuffer()));
+ const bannerImageHeight = width * (bannerImage.height / bannerImage.width);
+
lastPage.drawImage(bannerImage, {
x: 0,
y: 0,
width: width,
- height: width * (bannerImage.height / bannerImage.width),
+ height: bannerImageHeight
+ });
+
+ lastPage.drawText(pdfDoc.getCreationDate()!.toLocaleString(), {
+ x: 10,
+ y: bannerImageHeight,
+ size: 12,
+ font: await pdfDoc.embedFont(StandardFonts.TimesRoman)
});
const link = document.createElement("a");