1 31 package org.pdfbox.pdmodel.fdf; 32 33 import java.util.ArrayList ; 34 import java.util.List ; 35 36 import org.pdfbox.cos.COSArray; 37 import org.pdfbox.cos.COSBase; 38 import org.pdfbox.cos.COSDictionary; 39 40 import org.pdfbox.pdmodel.common.COSArrayList; 41 import org.pdfbox.pdmodel.common.COSObjectable; 42 43 49 public class FDFTemplate implements COSObjectable 50 { 51 private COSDictionary template; 52 53 56 public FDFTemplate() 57 { 58 template = new COSDictionary(); 59 } 60 61 66 public FDFTemplate( COSDictionary t ) 67 { 68 template = t; 69 } 70 71 76 public COSBase getCOSObject() 77 { 78 return template; 79 } 80 81 86 public COSDictionary getCOSDictionary() 87 { 88 return template; 89 } 90 91 96 public FDFNamedPageReference getTemplateReference() 97 { 98 FDFNamedPageReference retval = null; 99 COSDictionary dict = (COSDictionary)template.getDictionaryObject( "TRef" ); 100 if( dict != null ) 101 { 102 retval = new FDFNamedPageReference( dict ); 103 } 104 return retval; 105 } 106 107 112 public void setTemplateReference( FDFNamedPageReference tRef ) 113 { 114 template.setItem( "TRef", tRef ); 115 } 116 117 122 public List getFields() 123 { 124 List retval = null; 125 COSArray array = (COSArray)template.getDictionaryObject( "Fields" ); 126 if( array != null ) 127 { 128 List fields = new ArrayList (); 129 for( int i=0; i<array.size(); i++ ) 130 { 131 fields.add( new FDFField( (COSDictionary)array.getObject( i ) ) ); 132 } 133 retval = new COSArrayList( fields, array ); 134 } 135 return retval; 136 } 137 138 143 public void setFields( List fields ) 144 { 145 template.setItem( "Fields", COSArrayList.converterToCOSArray( fields ) ); 146 } 147 148 153 public boolean shouldRename() 154 { 155 return template.getBoolean( "Rename", false ); 156 } 157 158 163 public void setRename( boolean value ) 164 { 165 template.setBoolean( "Rename", value ); 166 } 167 } | Popular Tags |