-
-
Notifications
You must be signed in to change notification settings - Fork 673
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Hex String Default Appearances (#693)
* Support hexadecimal Default Appearance (#677) * Add test for PDFAcroField.getDefaultAppearance * Add test for PDFWidgetAnnotation.getDefaultAppearance * Cleanup Co-authored-by: Bj Tecu <[email protected]>
- Loading branch information
Showing
4 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { | ||
PDFAcroTerminal, | ||
PDFContext, | ||
PDFString, | ||
PDFHexString, | ||
} from 'src/index'; | ||
|
||
describe(`PDFAcroField`, () => { | ||
it(`returns undefined for missing (DAs)`, () => { | ||
const context = PDFContext.create(); | ||
|
||
const dict = context.obj({ | ||
DA: null, | ||
}); | ||
const dictRef = context.register(dict); | ||
const field = PDFAcroTerminal.fromDict(dict, dictRef); | ||
|
||
expect(field.getDefaultAppearance()).toBe(undefined); | ||
}); | ||
|
||
it(`returns normal direct appearance strings (DAs)`, () => { | ||
const context = PDFContext.create(); | ||
|
||
const dict = context.obj({ | ||
DA: PDFString.of('/ZaDb 10 Tf 0 g'), | ||
}); | ||
const dictRef = context.register(dict); | ||
const field = PDFAcroTerminal.fromDict(dict, dictRef); | ||
|
||
expect(field.getDefaultAppearance()).toBe('/ZaDb 10 Tf 0 g'); | ||
}); | ||
|
||
it(`returns hexadecimal (non-standard) direct appearance strings (DAs)`, () => { | ||
const context = PDFContext.create(); | ||
|
||
const dict = context.obj({ | ||
DA: PDFHexString.fromText('/ZaDb 10 Tf 0 g'), | ||
}); | ||
const dictRef = context.register(dict); | ||
const field = PDFAcroTerminal.fromDict(dict, dictRef); | ||
|
||
expect(field.getDefaultAppearance()).toBe('/ZaDb 10 Tf 0 g'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
PDFWidgetAnnotation, | ||
PDFContext, | ||
PDFString, | ||
PDFHexString, | ||
PDFName, | ||
PDFNull, | ||
} from 'src/index'; | ||
|
||
describe(`PDFWidgetAnnotation`, () => { | ||
it(`returns undefined for missing (DAs)`, () => { | ||
const context = PDFContext.create(); | ||
|
||
const parentRef = context.nextRef(); | ||
const widget = PDFWidgetAnnotation.create(context, parentRef); | ||
widget.dict.set(PDFName.of('DA'), PDFNull); | ||
|
||
expect(widget.getDefaultAppearance()).toBe(undefined); | ||
}); | ||
|
||
it(`returns normal direct appearance strings (DAs)`, () => { | ||
const context = PDFContext.create(); | ||
|
||
const parentRef = context.nextRef(); | ||
const widget = PDFWidgetAnnotation.create(context, parentRef); | ||
widget.dict.set(PDFName.of('DA'), PDFString.of('/ZaDb 10 Tf 0 g')); | ||
|
||
expect(widget.getDefaultAppearance()).toBe('/ZaDb 10 Tf 0 g'); | ||
}); | ||
|
||
it(`returns hexadecimal (non-standard) direct appearance strings (DAs)`, () => { | ||
const context = PDFContext.create(); | ||
|
||
const parentRef = context.nextRef(); | ||
const widget = PDFWidgetAnnotation.create(context, parentRef); | ||
widget.dict.set(PDFName.of('DA'), PDFHexString.fromText('/ZaDb 10 Tf 0 g')); | ||
|
||
expect(widget.getDefaultAppearance()).toBe('/ZaDb 10 Tf 0 g'); | ||
}); | ||
}); |