|
|
@ -27,15 +27,24 @@ describe('Annotation layer', function() { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
var annotationFactory; |
|
|
|
function PDFManagerMock(params) { |
|
|
|
|
|
|
|
this.docBaseUrl = params.docBaseUrl || null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
PDFManagerMock.prototype = {}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var annotationFactory, pdfManagerMock; |
|
|
|
|
|
|
|
|
|
|
|
beforeAll(function (done) { |
|
|
|
beforeAll(function (done) { |
|
|
|
annotationFactory = new AnnotationFactory(); |
|
|
|
annotationFactory = new AnnotationFactory(); |
|
|
|
|
|
|
|
pdfManagerMock = new PDFManagerMock({ |
|
|
|
|
|
|
|
docBaseUrl: null, |
|
|
|
|
|
|
|
}); |
|
|
|
done(); |
|
|
|
done(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
afterAll(function () { |
|
|
|
afterAll(function () { |
|
|
|
annotationFactory = null; |
|
|
|
annotationFactory = null; |
|
|
|
|
|
|
|
pdfManagerMock = null; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('AnnotationFactory', function () { |
|
|
|
describe('AnnotationFactory', function () { |
|
|
@ -49,7 +58,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
@ -66,8 +76,10 @@ describe('Annotation layer', function() { |
|
|
|
var uniquePrefix = 'p0_', idCounters = { obj: 0, }; |
|
|
|
var uniquePrefix = 'p0_', idCounters = { obj: 0, }; |
|
|
|
|
|
|
|
|
|
|
|
var annotation1 = annotationFactory.create(xref, annotationDict, |
|
|
|
var annotation1 = annotationFactory.create(xref, annotationDict, |
|
|
|
|
|
|
|
pdfManagerMock, |
|
|
|
uniquePrefix, idCounters); |
|
|
|
uniquePrefix, idCounters); |
|
|
|
var annotation2 = annotationFactory.create(xref, annotationDict, |
|
|
|
var annotation2 = annotationFactory.create(xref, annotationDict, |
|
|
|
|
|
|
|
pdfManagerMock, |
|
|
|
uniquePrefix, idCounters); |
|
|
|
uniquePrefix, idCounters); |
|
|
|
var data1 = annotation1.data, data2 = annotation2.data; |
|
|
|
var data1 = annotation1.data, data2 = annotation2.data; |
|
|
|
expect(data1.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data1.annotationType).toEqual(AnnotationType.LINK); |
|
|
@ -86,7 +98,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toBeUndefined(); |
|
|
|
expect(data.annotationType).toBeUndefined(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -270,11 +283,14 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toEqual('http://www.ctan.org/tex-archive/info/lshort'); |
|
|
|
expect(data.url).toEqual('http://www.ctan.org/tex-archive/info/lshort'); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toEqual( |
|
|
|
|
|
|
|
'http://www.ctan.org/tex-archive/info/lshort'); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -295,11 +311,13 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toEqual('http://www.hmrc.gov.uk'); |
|
|
|
expect(data.url).toEqual('http://www.hmrc.gov.uk/'); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toEqual('http://www.hmrc.gov.uk'); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -326,11 +344,14 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toEqual( |
|
|
|
expect(data.url).toEqual( |
|
|
|
|
|
|
|
new URL(stringToUTF8String('http://www.example.com/üöä')).href); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toEqual( |
|
|
|
stringToUTF8String('http://www.example.com/üöä')); |
|
|
|
stringToUTF8String('http://www.example.com/üöä')); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -351,11 +372,13 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined(); |
|
|
|
expect(data.dest).toEqual('page.157'); |
|
|
|
expect(data.dest).toEqual('page.157'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -378,15 +401,49 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toBeUndefined(); // ../../0013/001346/134685E.pdf#4.3
|
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3'); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.newWindow).toEqual(true); |
|
|
|
expect(data.newWindow).toEqual(true); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should correctly parse a GoToR action, containing a relative URL, ' + |
|
|
|
|
|
|
|
'with the "docBaseUrl" parameter specified', function() { |
|
|
|
|
|
|
|
var actionDict = new Dict(); |
|
|
|
|
|
|
|
actionDict.set('Type', Name.get('Action')); |
|
|
|
|
|
|
|
actionDict.set('S', Name.get('GoToR')); |
|
|
|
|
|
|
|
actionDict.set('F', '../../0013/001346/134685E.pdf'); |
|
|
|
|
|
|
|
actionDict.set('D', '4.3'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var annotationDict = new Dict(); |
|
|
|
|
|
|
|
annotationDict.set('Type', Name.get('Annot')); |
|
|
|
|
|
|
|
annotationDict.set('Subtype', Name.get('Link')); |
|
|
|
|
|
|
|
annotationDict.set('A', actionDict); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var annotationRef = new Ref(489, 0); |
|
|
|
|
|
|
|
var xref = new XRefMock([ |
|
|
|
|
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
var pdfManager = new PDFManagerMock({ |
|
|
|
|
|
|
|
docBaseUrl: 'http://www.example.com/test/pdfs/qwerty.pdf', |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManager); |
|
|
|
|
|
|
|
var data = annotation.data; |
|
|
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toEqual( |
|
|
|
|
|
|
|
'http://www.example.com/0013/001346/134685E.pdf#4.3'); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toEqual('../../0013/001346/134685E.pdf#4.3'); |
|
|
|
|
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should correctly parse a GoToR action, with named destination', |
|
|
|
it('should correctly parse a GoToR action, with named destination', |
|
|
|
function() { |
|
|
|
function() { |
|
|
|
var actionDict = new Dict(); |
|
|
|
var actionDict = new Dict(); |
|
|
@ -405,11 +462,14 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toEqual('http://www.example.com/test.pdf#nameddest=15'); |
|
|
|
expect(data.url).toEqual('http://www.example.com/test.pdf#nameddest=15'); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toEqual( |
|
|
|
|
|
|
|
'http://www.example.com/test.pdf#nameddest=15'); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.newWindow).toBeFalsy(); |
|
|
|
expect(data.newWindow).toBeFalsy(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -432,12 +492,15 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toEqual('http://www.example.com/test.pdf#' + |
|
|
|
expect(data.url).toEqual(new URL('http://www.example.com/test.pdf#' + |
|
|
|
'[14,{"name":"XYZ"},null,298.043,null]'); |
|
|
|
'[14,{"name":"XYZ"},null,298.043,null]').href); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toEqual('http://www.example.com/test.pdf#' + |
|
|
|
|
|
|
|
'[14,{"name":"XYZ"},null,298.043,null]'); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.dest).toBeUndefined(); |
|
|
|
expect(data.newWindow).toBeFalsy(); |
|
|
|
expect(data.newWindow).toBeFalsy(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -458,11 +521,13 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined(); |
|
|
|
expect(data.action).toEqual('GoToPage'); |
|
|
|
expect(data.action).toEqual('GoToPage'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -477,13 +542,39 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef); |
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = annotation.data; |
|
|
|
var data = annotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined(); |
|
|
|
expect(data.dest).toEqual('LI0'); |
|
|
|
expect(data.dest).toEqual('LI0'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should correctly parse a simple Dest, with explicit destination array', |
|
|
|
|
|
|
|
function() { |
|
|
|
|
|
|
|
var annotationDict = new Dict(); |
|
|
|
|
|
|
|
annotationDict.set('Type', Name.get('Annot')); |
|
|
|
|
|
|
|
annotationDict.set('Subtype', Name.get('Link')); |
|
|
|
|
|
|
|
annotationDict.set('Dest', [new Ref(17, 0), Name.get('XYZ'), |
|
|
|
|
|
|
|
0, 841.89, null]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var annotationRef = new Ref(10, 0); |
|
|
|
|
|
|
|
var xref = new XRefMock([ |
|
|
|
|
|
|
|
{ ref: annotationRef, data: annotationDict, } |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var annotation = annotationFactory.create(xref, annotationRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
|
|
|
|
var data = annotation.data; |
|
|
|
|
|
|
|
expect(data.annotationType).toEqual(AnnotationType.LINK); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
expect(data.url).toBeUndefined(); |
|
|
|
|
|
|
|
expect(data.unsafeUrl).toBeUndefined(); |
|
|
|
|
|
|
|
expect(data.dest).toEqual([{ num: 17, gen: 0, }, { name: 'XYZ' }, |
|
|
|
|
|
|
|
0, 841.89, null]); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('TextWidgetAnnotation', function() { |
|
|
|
describe('TextWidgetAnnotation', function() { |
|
|
@ -509,7 +600,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); |
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.maxLen).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.maxLen).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.readOnly).toEqual(false); |
|
|
|
expect(textWidgetAnnotation.data.readOnly).toEqual(false); |
|
|
@ -528,7 +620,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); |
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.maxLen).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.maxLen).toEqual(null); |
|
|
|
expect(textWidgetAnnotation.data.readOnly).toEqual(false); |
|
|
|
expect(textWidgetAnnotation.data.readOnly).toEqual(false); |
|
|
@ -548,7 +641,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); |
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(1); |
|
|
|
expect(textWidgetAnnotation.data.textAlignment).toEqual(1); |
|
|
|
expect(textWidgetAnnotation.data.maxLen).toEqual(20); |
|
|
|
expect(textWidgetAnnotation.data.maxLen).toEqual(20); |
|
|
|
expect(textWidgetAnnotation.data.readOnly).toEqual(true); |
|
|
|
expect(textWidgetAnnotation.data.readOnly).toEqual(true); |
|
|
@ -563,7 +657,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); |
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
expect(textWidgetAnnotation.data.comb).toEqual(false); |
|
|
|
expect(textWidgetAnnotation.data.comb).toEqual(false); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -576,7 +671,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef); |
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
expect(textWidgetAnnotation.data.comb).toEqual(true); |
|
|
|
expect(textWidgetAnnotation.data.comb).toEqual(true); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -600,9 +696,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
{ ref: textWidgetRef, data: textWidgetDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var textWidgetAnnotation = annotationFactory.create(xref, textWidgetRef, |
|
|
|
textWidgetRef); |
|
|
|
pdfManagerMock); |
|
|
|
|
|
|
|
|
|
|
|
var valid = (invalidFieldFlags.length === 0); |
|
|
|
var valid = (invalidFieldFlags.length === 0); |
|
|
|
expect(textWidgetAnnotation.data.comb).toEqual(valid); |
|
|
|
expect(textWidgetAnnotation.data.comb).toEqual(valid); |
|
|
|
|
|
|
|
|
|
|
@ -637,7 +732,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.options).toEqual([]); |
|
|
|
expect(data.options).toEqual([]); |
|
|
@ -664,7 +760,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.options).toEqual(expected); |
|
|
|
expect(data.options).toEqual(expected); |
|
|
@ -691,7 +788,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.options).toEqual(expected); |
|
|
|
expect(data.options).toEqual(expected); |
|
|
@ -708,7 +806,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.fieldValue).toEqual(fieldValue); |
|
|
|
expect(data.fieldValue).toEqual(fieldValue); |
|
|
@ -725,7 +824,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.fieldValue).toEqual([fieldValue]); |
|
|
|
expect(data.fieldValue).toEqual([fieldValue]); |
|
|
@ -738,7 +838,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.readOnly).toEqual(false); |
|
|
|
expect(data.readOnly).toEqual(false); |
|
|
@ -755,7 +856,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.readOnly).toEqual(false); |
|
|
|
expect(data.readOnly).toEqual(false); |
|
|
@ -774,7 +876,8 @@ describe('Annotation layer', function() { |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
var choiceWidgetAnnotation = annotationFactory.create(xref, |
|
|
|
choiceWidgetRef); |
|
|
|
choiceWidgetRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
var data = choiceWidgetAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.WIDGET); |
|
|
|
expect(data.readOnly).toEqual(true); |
|
|
|
expect(data.readOnly).toEqual(true); |
|
|
@ -833,7 +936,8 @@ describe('Annotation layer', function() { |
|
|
|
{ ref: popupRef, data: popupDict, } |
|
|
|
{ ref: popupRef, data: popupDict, } |
|
|
|
]); |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
var popupAnnotation = annotationFactory.create(xref, popupRef); |
|
|
|
var popupAnnotation = annotationFactory.create(xref, popupRef, |
|
|
|
|
|
|
|
pdfManagerMock); |
|
|
|
var data = popupAnnotation.data; |
|
|
|
var data = popupAnnotation.data; |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.POPUP); |
|
|
|
expect(data.annotationType).toEqual(AnnotationType.POPUP); |
|
|
|
|
|
|
|
|
|
|
|