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

add scale factor to inserQrCOde

parent 1d62a8df
No related branches found
No related tags found
1 merge request!1Draft: Resolve "[Document Sealing] Implement PDF parser"
Pipeline #49151 passed with stages
in 49 seconds
...@@ -5,7 +5,7 @@ declare class PDFparser { ...@@ -5,7 +5,7 @@ declare class PDFparser {
readonly config: any; readonly config: any;
constructor(document: Buffer); constructor(document: Buffer);
getPDFMeta: () => Promise<IgetMetaResponse>; getPDFMeta: () => Promise<IgetMetaResponse>;
insertQrCode: (imgBytes: ArrayBuffer, url: string) => Promise<ArrayBuffer>; insertQrCode: (imgBytes: ArrayBuffer, url: string, scaleFactor: number) => Promise<ArrayBuffer>;
private createPageLinkAnnotation; private createPageLinkAnnotation;
} }
export default PDFparser; export default PDFparser;
...@@ -46,10 +46,10 @@ class PDFparser { ...@@ -46,10 +46,10 @@ class PDFparser {
throw new Error("Could not get pdf metadata"); throw new Error("Could not get pdf metadata");
} }
}); });
this.insertQrCode = (imgBytes, url) => __awaiter(this, void 0, void 0, function* () { this.insertQrCode = (imgBytes, url, scaleFactor) => __awaiter(this, void 0, void 0, function* () {
const pdfDoc = yield PDFDocument.load(this.document); const pdfDoc = yield PDFDocument.load(this.document);
const img = yield pdfDoc.embedPng(imgBytes); const img = yield pdfDoc.embedPng(imgBytes);
const scaled = img.scale(0.2); const scaled = img.scale(scaleFactor);
const pages = pdfDoc.getPages(); const pages = pdfDoc.getPages();
for (let index = 0; index < pages.length; index++) { for (let index = 0; index < pages.length; index++) {
const page = pages[index]; const page = pages[index];
......
...@@ -43,12 +43,13 @@ class PDFparser { ...@@ -43,12 +43,13 @@ class PDFparser {
insertQrCode = async ( insertQrCode = async (
imgBytes: ArrayBuffer, imgBytes: ArrayBuffer,
url: string url: string,
scaleFactor: number
): Promise<ArrayBuffer> => { ): Promise<ArrayBuffer> => {
const pdfDoc = await PDFDocument.load(this.document); const pdfDoc = await PDFDocument.load(this.document);
const img = await pdfDoc.embedPng(imgBytes); const img = await pdfDoc.embedPng(imgBytes);
const scaled = img.scale(0.2); const scaled = img.scale(scaleFactor);
const pages = pdfDoc.getPages(); const pages = pdfDoc.getPages();
......
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