import PDFContext from 'src/core/PDFContext' ; import PDFDict from 'src/core/objects/PDFDict' ; import PDFNumber from 'src/core/objects/PDFNumber' ; import PDFString from 'src/core/objects/PDFString' ; import PDFHexString from 'src/core/objects/PDFHexString' ; import PDFName from 'src/core/objects/PDFName' ; import PDFRef from 'src/core/objects/PDFRef' ; import PDFAcroTerminal from 'src/core/acroform/PDFAcroTerminal' ; class PDFAcroText extends PDFAcroTerminal { static fromDict = ( dict , ref ) => new PDFAcroText ( dict , ref ) ; static create = ( context ) => { const dict = context . obj ( { FT : 'Tx' , Kids : [ ] , } ) ; const ref = context . register ( dict ) ; return new PDFAcroText ( dict , ref ) ; } ; MaxLen ( ) { const maxLen = this . dict . lookup ( PDFName . of ( 'MaxLen' ) ) ; if ( maxLen instanceof PDFNumber ) return maxLen ; return undefined ; } Q ( ) { const q = this . dict . lookup ( PDFName . of ( 'Q' ) ) ; if ( q instanceof PDFNumber ) return q ; return undefined ; } setMaxLength ( maxLength ) { this . dict . set ( PDFName . of ( 'MaxLen' ) , PDFNumber . of ( maxLength ) ) ; } removeMaxLength ( ) { this . dict . delete ( PDFName . of ( 'MaxLen' ) ) ; } getMaxLength ( ) { return this . MaxLen ( ) ?. asNumber ( ) ; } setQuadding ( quadding ) { this . dict . set ( PDFName . of ( 'Q' ) , PDFNumber . of ( quadding ) ) ; } getQuadding ( ) { return this . Q ( ) ?. asNumber ( ) ; } setValue ( value ) { this . dict . set ( PDFName . of ( 'V' ) , value ) ; } removeValue ( ) { this . dict . delete ( PDFName . of ( 'V' ) ) ; } getValue ( ) { const v = this . V ( ) ; if ( v instanceof PDFString || v instanceof PDFHexString ) return v ; return undefined ; } } export default PDFAcroText ;