1 50 51 package com.lowagie.text.pdf; 52 53 import java.io.IOException ; 54 import java.io.OutputStream ; 55 56 import com.lowagie.text.DocWriter; 57 58 72 73 public class PdfIndirectObject { 74 75 77 78 protected int number; 79 80 81 protected int generation = 0; 82 83 static final byte STARTOBJ[] = DocWriter.getISOBytes(" obj"); 84 static final byte ENDOBJ[] = DocWriter.getISOBytes("\nendobj\n"); 85 static final int SIZEOBJ = STARTOBJ.length + ENDOBJ.length; 86 PdfObject object; 87 PdfWriter writer; 88 89 91 97 98 PdfIndirectObject(int number, PdfObject object, PdfWriter writer) { 99 this(number, 0, object, writer); 100 } 101 102 PdfIndirectObject(PdfIndirectReference ref, PdfObject object, PdfWriter writer) { 103 this(ref.getNumber(),ref.getGeneration(),object,writer); 104 } 105 112 113 PdfIndirectObject(int number, int generation, PdfObject object, PdfWriter writer) { 114 this.writer = writer; 115 this.number = number; 116 this.generation = generation; 117 this.object = object; 118 PdfEncryption crypto = null; 119 if (writer != null) 120 crypto = writer.getEncryption(); 121 if (crypto != null) { 122 crypto.setHashKey(number, generation); 123 } 124 } 125 126 128 133 134 141 142 147 148 public PdfIndirectReference getIndirectReference() { 149 return new PdfIndirectReference(object.type(), number, generation); 150 } 151 152 158 void writeTo(OutputStream os) throws IOException 159 { 160 os.write(DocWriter.getISOBytes(String.valueOf(number))); 161 os.write(' '); 162 os.write(DocWriter.getISOBytes(String.valueOf(generation))); 163 os.write(STARTOBJ); 164 int type = object.type(); 165 if (type != PdfObject.ARRAY && type != PdfObject.DICTIONARY && type != PdfObject.NAME && type != PdfObject.STRING) 166 os.write(' '); 167 object.toPdf(writer, os); 168 os.write(ENDOBJ); 169 } 170 } 171 | Popular Tags |