Skip to content
Snippets Groups Projects
Commit 60b08df6 authored by Zdravko Iliev's avatar Zdravko Iliev
Browse files

qrcode in center

parent c7b432b6
No related branches found
No related tags found
1 merge request!1Draft: Resolve "[Document Sealing] Implement PDF parser"
Pipeline #49093 passed with stages
in 50 seconds
......@@ -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;
});
......
......@@ -44,15 +44,27 @@ class PDFparser {
insertQrCode = async (imgBytes: ArrayBuffer): Promise<ArrayBuffer> => {
const pdfDoc = await PDFDocument.load(this.document);
const img = await pdfDoc.embedPng(imgBytes);
const imagePage = pdfDoc.insertPage(0);
// const imagePage = pdfDoc.insertPage(0);
imagePage.drawImage(img, {
x: 0,
y: 0,
width: imagePage.getWidth(),
height: imagePage.getHeight(),
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 = await pdfDoc.save();
return pdfBytes;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment