1 31 package org.pdfbox.pdmodel.fdf; 32 33 import java.io.IOException ; 34 import java.io.Writer ; 35 36 import org.pdfbox.cos.COSBase; 37 import org.pdfbox.cos.COSDictionary; 38 39 import org.pdfbox.pdmodel.common.COSObjectable; 40 41 import org.pdfbox.pdmodel.interactive.digitalsignature.PDSignature; 42 43 import org.w3c.dom.Element ; 44 45 51 public class FDFCatalog implements COSObjectable 52 { 53 private COSDictionary catalog; 54 55 58 public FDFCatalog() 59 { 60 catalog = new COSDictionary(); 61 } 62 63 68 public FDFCatalog( COSDictionary cat ) 69 { 70 catalog = cat; 71 } 72 73 79 public FDFCatalog( Element element ) throws IOException 80 { 81 this(); 82 FDFDictionary fdfDict = new FDFDictionary( element ); 83 setFDF( fdfDict ); 84 } 85 86 93 public void writeXML( Writer output ) throws IOException 94 { 95 FDFDictionary fdf = getFDF(); 96 fdf.writeXML( output ); 97 } 98 99 104 public COSBase getCOSObject() 105 { 106 return catalog; 107 } 108 109 114 public COSDictionary getCOSDictionary() 115 { 116 return catalog; 117 } 118 119 124 public String getVersion() 125 { 126 return catalog.getNameAsString( "Version" ); 127 } 128 129 134 public void setVersion( String version ) 135 { 136 catalog.setName( "Version", version ); 137 } 138 139 144 public FDFDictionary getFDF() 145 { 146 COSDictionary fdf = (COSDictionary)catalog.getDictionaryObject( "FDF" ); 147 FDFDictionary retval = null; 148 if( fdf != null ) 149 { 150 retval = new FDFDictionary( fdf ); 151 } 152 else 153 { 154 retval = new FDFDictionary(); 155 setFDF( retval ); 156 } 157 return retval; 158 } 159 160 165 public void setFDF( FDFDictionary fdf ) 166 { 167 catalog.setItem( "FDF", fdf ); 168 } 169 170 175 public PDSignature getSignature() 176 { 177 PDSignature signature = null; 178 COSDictionary sig = (COSDictionary)catalog.getDictionaryObject( "Sig" ); 179 if( sig != null ) 180 { 181 signature = new PDSignature( sig ); 182 } 183 return signature; 184 } 185 186 191 public void setSignature( PDSignature sig ) 192 { 193 catalog.setItem( "Sig", sig ); 194 } 195 } | Popular Tags |