diff --git a/dist/pdfParser.d.ts b/dist/pdfParser.d.ts index 05d9f6f360b2c693191cc9945fa1c82ed9176a86..6644c4a3c7eb307d99b21b5f6a6c1b8b72243b4b 100644 --- a/dist/pdfParser.d.ts +++ b/dist/pdfParser.d.ts @@ -5,7 +5,7 @@ declare class PDFparser { readonly config: any; constructor(document: Buffer); getPDFMeta: () => Promise<IGetMetaResponse>; - insertQrCode: (imgBytes: ArrayBuffer, url: string, scaleFactor: number) => Promise<ArrayBuffer>; + insertQrCode: (imgBytes: ArrayBuffer, url: string, coords: any, scaleFactor: number) => Promise<ArrayBuffer>; private createPageLinkAnnotation; } export default PDFparser; diff --git a/dist/pdfParser.js b/dist/pdfParser.js index 94d4530339c18f78776738e53d871bbe44c3f32a..2c64a8e6c788d591a931c2d6dfcc57f94b7ee4d9 100644 --- a/dist/pdfParser.js +++ b/dist/pdfParser.js @@ -45,13 +45,17 @@ class PDFparser { throw new errors_1.GeneralError(error); } }); - this.insertQrCode = (imgBytes, url, scaleFactor) => __awaiter(this, void 0, void 0, function* () { + this.insertQrCode = (imgBytes, url, coords, scaleFactor) => __awaiter(this, void 0, void 0, function* () { const pdfDoc = yield pdf_lib_1.PDFDocument.load(this.document); const img = yield pdfDoc.embedPng(imgBytes); const scaled = img.scale(scaleFactor); const pages = pdfDoc.getPages(); for (let index = 0; index < pages.length; index++) { const page = pages[index]; + console.log("dynamic x ", coords[index + 1].x); + console.log("dynamic y ", coords[index + 1].y); + console.log("x", page.getWidth() / 2 - scaled.width / 2); + console.log("y", page.getHeight() / 2 - scaled.height / 2); page.drawImage(img, { x: page.getWidth() / 2 - scaled.width / 2, y: page.getHeight() / 2 - scaled.height / 2, diff --git a/src/pdfParser.ts b/src/pdfParser.ts index 0729fa8ef0cfd058fbfca0df2d864f5c94671b70..d2433748d4ad670f64a7dc4f598f738039819483 100644 --- a/src/pdfParser.ts +++ b/src/pdfParser.ts @@ -50,6 +50,7 @@ class PDFparser { insertQrCode = async ( imgBytes: ArrayBuffer, url: string, + coords: any, scaleFactor: number ): Promise<ArrayBuffer> => { const pdfDoc = await PDFDocument.load(this.document); @@ -62,6 +63,12 @@ class PDFparser { for (let index = 0; index < pages.length; index++) { const page = pages[index]; + console.log("dynamic x ", coords[index + 1].x); + console.log("dynamic y ", coords[index + 1].y); + + console.log("x", page.getWidth() / 2 - scaled.width / 2); + console.log("y", page.getHeight() / 2 - scaled.height / 2); + page.drawImage(img, { x: page.getWidth() / 2 - scaled.width / 2, y: page.getHeight() / 2 - scaled.height / 2,