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
+ 48
29
Compare changes
  • Side-by-side
  • Inline
Files
2
+ 21
13
@@ -52,19 +52,27 @@ class PDFparser {
const pages = pdfDoc.getPages();
for (let index = 0; index < pages.length; index++) {
const page = pages[index];
page.drawImage(img, {
x: parseFloat(coords[index + 1].x),
y: parseFloat(coords[index + 1].y),
width: scaled.width,
height: scaled.height,
});
const link = this.createPageLinkAnnotation(page, url, {
imgXPos: parseFloat(coords[index + 1].x),
imgYPos: parseFloat(coords[index + 1].y),
imgWidth: scaled.width,
imagHeight: scaled.height,
});
page.node.set(pdf_lib_1.PDFName.of("Annots"), pdfDoc.context.obj([link]));
const x = typeof coords[index + 1] !== "undefined"
? parseFloat(coords[index + 1].x)
: null;
const y = typeof typeof coords[index + 1] !== "undefined"
? parseFloat(coords[index + 1].y)
: null;
if (x && y) {
page.drawImage(img, {
x,
y,
width: scaled.width,
height: scaled.height,
});
const link = this.createPageLinkAnnotation(page, url, {
imgXPos: x,
imgYPos: y,
imgWidth: scaled.width,
imagHeight: scaled.height,
});
page.node.set(pdf_lib_1.PDFName.of("Annots"), pdfDoc.context.obj([link]));
}
}
const pdfBytes = yield pdfDoc.save();
return pdfBytes;
Loading