1 31 package org.pdfbox.pdmodel.common; 32 33 import org.pdfbox.cos.COSStream; 34 35 import org.pdfbox.pdmodel.PDDocument; 36 37 38 39 46 public class PDObjectStream extends PDStream 47 { 48 49 54 public PDObjectStream( COSStream str ) 55 { 56 super( str ); 57 } 58 59 65 public static PDObjectStream createStream( PDDocument document ) 66 { 67 COSStream cosStream = new COSStream( document.getDocument().getScratchFile() ); 68 PDObjectStream strm = new PDObjectStream( cosStream ); 69 strm.getStream().setName( "Type", "ObjStm" ); 70 return strm; 71 } 72 73 78 public String getType() 79 { 80 return getStream().getNameAsString( "Type" ); 81 } 82 83 88 public int getNumberOfObjects() 89 { 90 return getStream().getInt( "N", 0 ); 91 } 92 93 98 public void setNumberOfObjects( int n ) 99 { 100 getStream().setInt( "N", n ); 101 } 102 103 108 public int getFirstByteOffset() 109 { 110 return getStream().getInt( "First", 0 ); 111 } 112 113 118 public void setFirstByteOffset( int n ) 119 { 120 getStream().setInt( "First", n ); 121 } 122 123 129 public PDObjectStream getExtends() 130 { 131 PDObjectStream retval = null; 132 COSStream stream = (COSStream)getStream().getDictionaryObject( "Extends" ); 133 if( stream != null ) 134 { 135 retval = new PDObjectStream( stream ); 136 } 137 return retval; 138 139 } 140 141 147 public void setExtends( PDObjectStream stream ) 148 { 149 getStream().setItem( "Extends", stream ); 150 } 151 } | Popular Tags |