1 31 package org.pdfbox.pdmodel.common.filespecification; 32 33 import java.io.IOException ; 34 import java.io.InputStream ; 35 import java.util.Calendar ; 36 37 import org.pdfbox.cos.COSDictionary; 38 import org.pdfbox.cos.COSStream; 39 import org.pdfbox.pdmodel.PDDocument; 40 import org.pdfbox.pdmodel.common.PDStream; 41 42 48 public class PDEmbeddedFile extends PDStream 49 { 50 51 56 public PDEmbeddedFile( PDDocument document ) 57 { 58 super( document ); 59 getStream().setName( "Type", "EmbeddedFile" ); 60 61 } 62 63 68 public PDEmbeddedFile( COSStream str ) 69 { 70 super( str ); 71 } 72 73 81 public PDEmbeddedFile( PDDocument doc, InputStream str ) throws IOException 82 { 83 super( doc, str ); 84 getStream().setName( "Type", "EmbeddedFile" ); 85 } 86 87 96 public PDEmbeddedFile( PDDocument doc, InputStream str, boolean filtered ) throws IOException 97 { 98 super( doc, str, filtered ); 99 getStream().setName( "Type", "EmbeddedFile" ); 100 } 101 102 107 public void setSubtype( String mimeType ) 108 { 109 getStream().setName( "Subtype", mimeType ); 110 } 111 112 117 public String getSubtype() 118 { 119 return getStream().getNameAsString( "Subtype" ); 120 } 121 122 127 public int getSize() 128 { 129 return getStream().getEmbeddedInt( "Params", "Size" ); 130 } 131 132 137 public void setSize( int size ) 138 { 139 getStream().setEmbeddedInt( "Params", "Size", size ); 140 } 141 142 148 public Calendar getCreationDate() throws IOException 149 { 150 return getStream().getEmbeddedDate( "Params", "CreationDate" ); 151 } 152 153 158 public void setCreationDate( Calendar creation ) 159 { 160 getStream().setEmbeddedDate( "Params", "CreationDate", creation ); 161 } 162 163 169 public Calendar getModDate() throws IOException 170 { 171 return getStream().getEmbeddedDate( "Params", "ModDate" ); 172 } 173 174 179 public void setModDate( Calendar mod ) 180 { 181 getStream().setEmbeddedDate( "Params", "ModDate", mod ); 182 } 183 184 189 public String getCheckSum() 190 { 191 return getStream().getEmbeddedString( "Params", "CheckSum" ); 192 } 193 194 199 public void setCheckSum( String checksum ) 200 { 201 getStream().setEmbeddedString( "Params", "CheckSum", checksum ); 202 } 203 204 209 public String getMacSubtype() 210 { 211 String retval = null; 212 COSDictionary params = (COSDictionary)getStream().getDictionaryObject( "Params" ); 213 if( params != null ) 214 { 215 retval = params.getEmbeddedString( "Mac", "Subtype" ); 216 } 217 return retval; 218 } 219 220 225 public void setMacSubtype( String macSubtype ) 226 { 227 COSDictionary params = (COSDictionary)getStream().getDictionaryObject( "Params" ); 228 if( params == null && macSubtype != null ) 229 { 230 params = new COSDictionary(); 231 getStream().setItem( "Params", params ); 232 } 233 if( params != null ) 234 { 235 params.setEmbeddedString( "Mac", "Subtype", macSubtype ); 236 } 237 } 238 239 244 public String getMacCreator() 245 { 246 String retval = null; 247 COSDictionary params = (COSDictionary)getStream().getDictionaryObject( "Params" ); 248 if( params != null ) 249 { 250 retval = params.getEmbeddedString( "Mac", "Creator" ); 251 } 252 return retval; 253 } 254 255 260 public void setMacCreator( String macCreator ) 261 { 262 COSDictionary params = (COSDictionary)getStream().getDictionaryObject( "Params" ); 263 if( params == null && macCreator != null ) 264 { 265 params = new COSDictionary(); 266 getStream().setItem( "Params", params ); 267 } 268 if( params != null ) 269 { 270 params.setEmbeddedString( "Mac", "Creator", macCreator ); 271 } 272 } 273 274 279 public String getMacResFork() 280 { 281 String retval = null; 282 COSDictionary params = (COSDictionary)getStream().getDictionaryObject( "Params" ); 283 if( params != null ) 284 { 285 retval = params.getEmbeddedString( "Mac", "ResFork" ); 286 } 287 return retval; 288 } 289 290 295 public void setMacResFork( String macResFork ) 296 { 297 COSDictionary params = (COSDictionary)getStream().getDictionaryObject( "Params" ); 298 if( params == null && macResFork != null ) 299 { 300 params = new COSDictionary(); 301 getStream().setItem( "Params", params ); 302 } 303 if( params != null ) 304 { 305 params.setEmbeddedString( "Mac", "ResFork", macResFork); 306 } 307 } 308 309 310 311 } | Popular Tags |