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

Add support of Ink annotation

This commit is contained in:
Simon Leblanc 2018-09-30 16:29:16 +02:00
parent 1cfb723dd4
commit b5806735d8
7 changed files with 173 additions and 1 deletions

View file

@ -272,6 +272,7 @@
!text_clip_cff_cid.pdf
!issue4801.pdf
!issue5334.pdf
!annotation-caret-ink.pdf
!bug1186827.pdf
!issue215.pdf
!issue5044.pdf

Binary file not shown.

View file

@ -1776,6 +1776,13 @@
"lastPage": 1,
"type": "load"
},
{ "id": "annotation-caret-ink",
"file": "pdfs/annotation-caret-ink.pdf",
"md5": "6218ca235580d1975474c979e0128c2d",
"rounds": 1,
"type": "eq",
"annotations": true
},
{ "id": "bug1130815-eq",
"file": "pdfs/bug1130815.pdf",
"md5": "3ff3b550c3af766991b2a1b11d00de85",

View file

@ -1435,4 +1435,59 @@ describe('annotation', function() {
}, done.fail);
});
});
describe('InkAnnotation', function() {
it('should handle a single ink list', function(done) {
const inkDict = new Dict();
inkDict.set('Type', Name.get('Annot'));
inkDict.set('Subtype', Name.get('Ink'));
inkDict.set('InkList', [[1, 1, 1, 2, 2, 2, 3, 3]]);
const inkRef = new Ref(142, 0);
const xref = new XRefMock([
{ ref: inkRef, data: inkDict, }
]);
AnnotationFactory.create(xref, inkRef, pdfManagerMock,
idFactoryMock).then(({ data, }) => {
expect(data.annotationType).toEqual(AnnotationType.INK);
expect(data.inkLists.length).toEqual(1);
expect(data.inkLists[0]).toEqual([
{ x: 1, y: 1, },
{ x: 1, y: 2, },
{ x: 2, y: 2, },
{ x: 3, y: 3, },
]);
done();
}, done.fail);
});
it('should handle multiple ink lists', function(done) {
const inkDict = new Dict();
inkDict.set('Type', Name.get('Annot'));
inkDict.set('Subtype', Name.get('Ink'));
inkDict.set('InkList', [
[1, 1, 1, 2],
[3, 3, 4, 5],
]);
const inkRef = new Ref(143, 0);
const xref = new XRefMock([
{ ref: inkRef, data: inkDict, }
]);
AnnotationFactory.create(xref, inkRef, pdfManagerMock,
idFactoryMock).then(({ data, }) => {
expect(data.annotationType).toEqual(AnnotationType.INK);
expect(data.inkLists.length).toEqual(2);
expect(data.inkLists[0]).toEqual([
{ x: 1, y: 1, }, { x: 1, y: 2, }
]);
expect(data.inkLists[1]).toEqual([
{ x: 3, y: 3, }, { x: 4, y: 5, }
]);
done();
}, done.fail);
});
});
});