Skip to content

Commit 01b25b2

Browse files
Merge pull request #14391 from KouWakai/annot-border-correct
Handle non-integer Annotation border widths correctly (issue 14203)
2 parents 07c32f0 + 98158b6 commit 01b25b2

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

src/core/annotation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -922,7 +922,7 @@ class AnnotationBorderStyle {
922922
this.width = 0; // This is consistent with the behaviour in Adobe Reader.
923923
return;
924924
}
925-
if (Number.isInteger(width)) {
925+
if (typeof width === "number") {
926926
if (width > 0) {
927927
const maxWidth = (rect[2] - rect[0]) / 2;
928928
const maxHeight = (rect[3] - rect[1]) / 2;

test/pdfs/issue14203.pdf.link

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/mozilla/pdf.js/files/7428963/pdfcomment.pdf

test/test_manifest.json

+9
Original file line numberDiff line numberDiff line change
@@ -4212,6 +4212,15 @@
42124212
"rounds": 1,
42134213
"type": "eq"
42144214
},
4215+
{ "id": "issue14203",
4216+
"file": "pdfs/issue14203.pdf",
4217+
"md5": "26c1c1e7341bc23fb28d805fa516dbbe",
4218+
"link": true,
4219+
"rounds": 1,
4220+
"firstPage": 11,
4221+
"lastPage": 11,
4222+
"type": "eq"
4223+
},
42154224
{ "id": "issue11045",
42164225
"file": "pdfs/issue11045.pdf",
42174226
"md5": "101d4cb649cc006e0f2b14923e8d97d6",

test/unit/annotation_spec.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -414,10 +414,13 @@ describe("annotation", function () {
414414

415415
describe("AnnotationBorderStyle", function () {
416416
it("should set and get a valid width", function () {
417-
const borderStyle = new AnnotationBorderStyle();
418-
borderStyle.setWidth(3);
417+
const borderStyleInt = new AnnotationBorderStyle();
418+
borderStyleInt.setWidth(3);
419+
const borderStyleNum = new AnnotationBorderStyle();
420+
borderStyleNum.setWidth(2.5);
419421

420-
expect(borderStyle.width).toEqual(3);
422+
expect(borderStyleInt.width).toEqual(3);
423+
expect(borderStyleNum.width).toEqual(2.5);
421424
});
422425

423426
it("should not set and get an invalid width", function () {

0 commit comments

Comments
 (0)