Handle non-integer Annotation border widths correctly (issue 14203)
The existing code appears to be wrong, since according to the PDF specification the border width of an Annotation only has to be a number and not specifically an integer. Please see: - https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#page=392 - https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G11.2096210 - https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf#G6.1965562
This commit is contained in:
parent
41dab8e7b6
commit
98158b67a3
@ -922,7 +922,7 @@ class AnnotationBorderStyle {
|
||||
this.width = 0; // This is consistent with the behaviour in Adobe Reader.
|
||||
return;
|
||||
}
|
||||
if (Number.isInteger(width)) {
|
||||
if (typeof width === "number") {
|
||||
if (width > 0) {
|
||||
const maxWidth = (rect[2] - rect[0]) / 2;
|
||||
const maxHeight = (rect[3] - rect[1]) / 2;
|
||||
|
1
test/pdfs/issue14203.pdf.link
Normal file
1
test/pdfs/issue14203.pdf.link
Normal file
@ -0,0 +1 @@
|
||||
https://github.com/mozilla/pdf.js/files/7428963/pdfcomment.pdf
|
@ -4211,6 +4211,15 @@
|
||||
"md5": "ae37cf36f2e319688c608e4086836824",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue14203",
|
||||
"file": "pdfs/issue14203.pdf",
|
||||
"md5": "26c1c1e7341bc23fb28d805fa516dbbe",
|
||||
"link": true,
|
||||
"rounds": 1,
|
||||
"firstPage": 11,
|
||||
"lastPage": 11,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue11045",
|
||||
"file": "pdfs/issue11045.pdf",
|
||||
|
@ -414,10 +414,13 @@ describe("annotation", function () {
|
||||
|
||||
describe("AnnotationBorderStyle", function () {
|
||||
it("should set and get a valid width", function () {
|
||||
const borderStyle = new AnnotationBorderStyle();
|
||||
borderStyle.setWidth(3);
|
||||
const borderStyleInt = new AnnotationBorderStyle();
|
||||
borderStyleInt.setWidth(3);
|
||||
const borderStyleNum = new AnnotationBorderStyle();
|
||||
borderStyleNum.setWidth(2.5);
|
||||
|
||||
expect(borderStyle.width).toEqual(3);
|
||||
expect(borderStyleInt.width).toEqual(3);
|
||||
expect(borderStyleNum.width).toEqual(2.5);
|
||||
});
|
||||
|
||||
it("should not set and get an invalid width", function () {
|
||||
|
Loading…
Reference in New Issue
Block a user