mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-21 07:38:07 +02:00
Interactive forms: make choice widget options inheritable (issue 8094)
Even though the PDF specification does not state that `Opt` fields are inheritable, in practice there are PDF generators that let annotations inherit the options from a parent.
This commit is contained in:
parent
da08b801a5
commit
8990de8614
2 changed files with 32 additions and 1 deletions
|
@ -1142,6 +1142,34 @@ describe('annotation', function() {
|
|||
expect(data.options).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle inherited option arrays (issue 8094)', function() {
|
||||
var options = [
|
||||
['Value1', 'Description1'],
|
||||
['Value2', 'Description2'],
|
||||
];
|
||||
var expected = [
|
||||
{ exportValue: 'Value1', displayValue: 'Description1' },
|
||||
{ exportValue: 'Value2', displayValue: 'Description2' },
|
||||
];
|
||||
|
||||
var parentDict = new Dict();
|
||||
parentDict.set('Opt', options);
|
||||
|
||||
choiceWidgetDict.set('Parent', parentDict);
|
||||
|
||||
var choiceWidgetRef = new Ref(123, 0);
|
||||
var xref = new XRefMock([
|
||||
{ ref: choiceWidgetRef, data: choiceWidgetDict, },
|
||||
]);
|
||||
|
||||
var annotation = annotationFactory.create(xref, choiceWidgetRef,
|
||||
pdfManagerMock, idFactoryMock);
|
||||
var data = annotation.data;
|
||||
expect(data.annotationType).toEqual(AnnotationType.WIDGET);
|
||||
|
||||
expect(data.options).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should handle array field values', function() {
|
||||
var fieldValue = ['Foo', 'Bar'];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue