1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Fix annotation border style parsing by handling empty dash arrays

The PDF specification states that empty dash arrays, i.e. arrays with
zero elements, are in fact valid. In that case the dash array simply
corresponds to a solid, unbroken line. However, this case was erroneously
being flagged as invalid and therefore the annotation was not drawn
because its width was set to zero. This commit fixes the issue by
allowing dash arrays to have a length of zero.
This commit is contained in:
Tim van der Meij 2024-04-08 16:01:30 +02:00
parent 5adad89eb3
commit d01a0bd0c8
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
5 changed files with 22 additions and 4 deletions

View file

@ -514,6 +514,7 @@
!issue11549_reduced.pdf
!issue8097_reduced.pdf
!issue15262.pdf
!issue17904.pdf
!bug1743245.pdf
!quadpoints.pdf
!transparent.pdf

BIN
test/pdfs/issue17904.pdf Normal file

Binary file not shown.

View file

@ -3858,6 +3858,14 @@
"type": "eq",
"annotations": true
},
{
"id": "issue17904",
"file": "pdfs/issue17904.pdf",
"md5": "4b8f0b565a61bf068ef72d232c997cef",
"rounds": 1,
"type": "eq",
"annotations": true
},
{
"id": "issue6179_reduced",
"file": "pdfs/issue6179_reduced.pdf",

View file

@ -549,6 +549,15 @@ describe("annotation", function () {
expect(borderStyle.dashArray).toEqual([3]);
});
it("should not set the width to zero if the dash array is empty (issue 17904)", function () {
const borderStyle = new AnnotationBorderStyle();
borderStyle.setWidth(3);
borderStyle.setDashArray([]);
expect(borderStyle.width).toEqual(3);
expect(borderStyle.dashArray).toEqual([]);
});
it("should set and get a valid horizontal corner radius", function () {
const borderStyle = new AnnotationBorderStyle();
borderStyle.setHorizontalCornerRadius(3);