1 50 51 package com.lowagie.text.rtf.text; 52 53 import java.io.ByteArrayOutputStream ; 54 import java.io.IOException ; 55 import java.io.OutputStream ; 56 57 import com.lowagie.text.Chapter; 58 import com.lowagie.text.rtf.RtfBasicElement; 59 import com.lowagie.text.rtf.document.RtfDocument; 60 61 62 70 public class RtfChapter extends RtfSection { 71 72 78 public RtfChapter(RtfDocument doc, Chapter chapter) { 79 super(doc, chapter); 80 } 81 82 88 public byte[] write() { 89 ByteArrayOutputStream result = new ByteArrayOutputStream (); 90 try { 91 writeContent(result); 92 } catch(IOException ioe) { 93 ioe.printStackTrace(); 94 } 95 return result.toByteArray(); 96 } 97 98 101 public void writeContent(final OutputStream result) throws IOException 102 { 103 if(this.document.getLastElementWritten() != null && !(this.document.getLastElementWritten() instanceof RtfChapter)) { 104 result.write("\\page".getBytes()); 105 } 106 result.write("\\sectd".getBytes()); 107 document.getDocumentHeader().writeSectionDefinition(result); 109 if(this.title != null) { 110 this.title.writeContent(result); 112 } 113 for(int i = 0; i < items.size(); i++) { 114 RtfBasicElement rbe = (RtfBasicElement)items.get(i); 115 rbe.writeContent(result); 117 } 118 result.write("\\sect".getBytes()); 119 } 120 121 } 122 | Popular Tags |