Skip to content
Snippets Groups Projects

Draft: Resolve "[Document Sealing] Implement PDF parser"

Open Zdravko Iliev requested to merge 1-document-sealing-implement-pdf-parser into master
Compare and Show latest version
2 files
+ 33
12
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 15
6
@@ -48,13 +48,22 @@ class PDFparser {
this.insertQrCode = (imgBytes) => __awaiter(this, void 0, void 0, function* () {
const pdfDoc = yield PDFDocument.load(this.document);
const img = yield pdfDoc.embedPng(imgBytes);
const imagePage = pdfDoc.insertPage(0);
imagePage.drawImage(img, {
x: 0,
y: 0,
width: imagePage.getWidth(),
height: imagePage.getHeight(),
// const imagePage = pdfDoc.insertPage(0);
const pages = pdfDoc.getPages();
const firstPage = pages[0];
const { width, height } = firstPage.getSize();
firstPage.drawImage(img, {
x: firstPage.getWidth() / 2 - img.width / 2,
y: firstPage.getHeight() / 2 - img.height / 2,
width: img.width,
height: img.height,
});
// firstPage.drawImage(img, {
// x: 0,
// y: 0,
// width: firstPage.getWidth(),
// height: firstPage.getHeight(),
// });
const pdfBytes = yield pdfDoc.save();
return pdfBytes;
});
Loading