1 31 package org.pdfbox.pdmodel.interactive.form; 32 33 import org.pdfbox.cos.COSArray; 34 import org.pdfbox.cos.COSDictionary; 35 import org.pdfbox.cos.COSName; 36 import org.pdfbox.cos.COSString; 37 38 import org.pdfbox.pdmodel.common.COSArrayList; 39 40 import java.util.ArrayList ; 41 import java.util.List ; 42 43 49 public abstract class PDChoiceButton extends PDField 50 { 51 52 58 public PDChoiceButton( PDAcroForm theAcroForm, COSDictionary field) 59 { 60 super(theAcroForm, field); 61 } 62 63 68 public List getOptions() 69 { 70 List retval = null; 71 COSArray array = (COSArray)getDictionary().getDictionaryObject( COSName.getPDFName( "Opt" ) ); 72 if( array != null ) 73 { 74 List strings = new ArrayList(); 75 for( int i=0; i<array.size(); i++ ) 76 { 77 strings.add( ((COSString)array.getObject( i )).getString() ); 78 } 79 retval = new COSArrayList( strings, array ); 80 } 81 return retval; 82 } 83 84 89 public void setOptions( List options ) 90 { 91 getDictionary().setItem( 92 COSName.getPDFName( "Opt" ), 93 COSArrayList.converterToCOSArray( options ) ); 94 } 95 } | Popular Tags |