diff --git a/src/core/annotation.js b/src/core/annotation.js index 6307dd36f..a01efdd9b 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -4397,14 +4397,20 @@ class InkAnnotation extends MarkupAnnotation { buffer.push( `${numberToString(bezier[0])} ${numberToString(bezier[1])} m` ); - for (let i = 2, ii = bezier.length; i < ii; i += 6) { - const curve = bezier - .slice(i, i + 6) - .map(numberToString) - .join(" "); - buffer.push(`${curve} c`); + if (bezier.length === 2) { + buffer.push( + `${numberToString(bezier[0])} ${numberToString(bezier[1])} l S` + ); + } else { + for (let i = 2, ii = bezier.length; i < ii; i += 6) { + const curve = bezier + .slice(i, i + 6) + .map(numberToString) + .join(" "); + buffer.push(`${curve} c`); + } + buffer.push("S"); } - buffer.push("S"); appearanceBuffer.push(buffer.join("\n")); } const appearance = appearanceBuffer.join("\n"); diff --git a/src/display/editor/ink.js b/src/display/editor/ink.js index dea3e7fb4..24a0a07c4 100644 --- a/src/display/editor/ink.js +++ b/src/display/editor/ink.js @@ -628,7 +628,7 @@ class InkEditor extends AnnotationEditor { this.parent.addInkEditorIfNeeded(/* isCommitting = */ true); - // When commiting, the position of this editor is changed, hence we must + // When committing, the position of this editor is changed, hence we must // move it to the right position in the DOM. this.moveInDOM(); this.div.focus({ @@ -994,6 +994,14 @@ class InkEditor extends AnnotationEditor { const points = []; for (let j = 0, jj = bezier.length; j < jj; j++) { const [first, control1, control2, second] = bezier[j]; + if (first[0] === second[0] && first[1] === second[1] && jj === 1) { + // We have only one point. + const p0 = s * first[0] + shiftX; + const p1 = s * first[1] + shiftY; + buffer.push(p0, p1); + points.push(p0, p1); + break; + } const p10 = s * first[0] + shiftX; const p11 = s * first[1] + shiftY; const p20 = s * control1[0] + shiftX; diff --git a/test/test_manifest.json b/test/test_manifest.json index aece61a10..0a0f3c4d0 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -8458,5 +8458,43 @@ "structTreeParentId": null } } + }, + { + "id": "issue17418", + "file": "pdfs/empty.pdf", + "md5": "2bfd06746bd5c2e6fc3492c83c152bc5", + "rounds": 1, + "type": "eq", + "save": true, + "print": true, + "annotationStorage": { + "pdfjs_internal_editor_0": { + "annotationType": 15, + "color": [ 53, 228, 47 ], + "thickness": 20, + "opacity": 1, + "paths": [ + { + "bezier": [ + 279.9183673469388, + 477.0105263157895 + ], + "points": [ + 279.9183673469388, + 477.0105263157895 + ] + } + ], + "pageIndex": 0, + "rect": [ + 269.9183673469388, + 443.93684210526317, + 312.9387755102041, + 487.0105263157895 + ], + "rotation": 0, + "structTreeParentId": null + } + } } ]