Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
8.7.2
Detailed description of issue
I am trying to get the "draw signature’ through the exportSignatures(). I am getting the arrays of path points, to get the base64 img I am drawing the points on canvas then convert it into the base64. I m just draw simple ‘Z’ but it is drawing wrong, I’ve attached the screenshot for your reference.
Expected behaviour
Does your issue happen with every document, or just one?
Every time
Link to document
{Provide a link to the document in question if possible}
Code snippet
Not able to attached the code snippet as I m new users that’s why, I attached the wrong drawn signature
Here is my code:
const signatureTool1 = docViewer.getTool(‘AnnotationCreateSignature’);
signatureTool1.on(‘signatureSaved’, (annotation) => {
signatureTool1.exportSignatures().then((signature) => {
if (signature[2]) {
const signatureArray = JSON.parse(JSON.stringify(signature[2]));
const canvas = document.createElement(‘canvas’);
canvas.width = 500;
canvas.height = 500;
const ctx = canvas.getContext(‘2d’);
ctx.beginPath();
ctx.moveTo(signatureArray[0].x, signatureArray[0].y);
for (let i = 1; i < signatureArray[0].length; i++) {
ctx.lineTo(signatureArray[0][i].x, signatureArray[0][i].y);
}
ctx.closePath();
ctx.stroke();
console.log(canvas.toDataURL(‘image/png’));
}
});
});