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.Annotation; 58 import com.lowagie.text.rtf.RtfElement; 59 import com.lowagie.text.rtf.document.RtfDocument; 60 61 62 70 public class RtfAnnotation extends RtfElement { 71 72 75 private static final byte[] ANNOTATION_ID = "\\*\\atnid".getBytes(); 76 79 private static final byte[] ANNOTATION_AUTHOR = "\\*\\atnauthor".getBytes(); 80 83 private static final byte[] ANNOTATION = "\\*\\annotation".getBytes(); 84 85 88 private String title = ""; 89 92 private String content = ""; 93 94 100 public RtfAnnotation(RtfDocument doc, Annotation annotation) { 101 super(doc); 102 title = annotation.title(); 103 content = annotation.content(); 104 } 105 106 112 public byte[] write() { 113 ByteArrayOutputStream result = new ByteArrayOutputStream (); 114 try { 115 writeContent(result); 116 } catch(IOException ioe) { 117 ioe.printStackTrace(); 118 } 119 return result.toByteArray(); 120 } 121 124 public void writeContent(final OutputStream result) throws IOException 125 { 126 result.write(OPEN_GROUP); 127 result.write(ANNOTATION_ID); 128 result.write(DELIMITER); 129 result.write(intToByteArray(document.getRandomInt())); 130 result.write(CLOSE_GROUP); 131 result.write(OPEN_GROUP); 132 result.write(ANNOTATION_AUTHOR); 133 result.write(DELIMITER); 134 result.write(title.getBytes()); 135 result.write(CLOSE_GROUP); 136 result.write(OPEN_GROUP); 137 result.write(ANNOTATION); 138 result.write(RtfParagraph.PARAGRAPH_DEFAULTS); 139 result.write(DELIMITER); 140 result.write(content.getBytes()); 141 result.write(CLOSE_GROUP); 142 } 143 } 144 | Popular Tags |