1 50 51 package com.lowagie.text.rtf.field; 52 53 import java.io.ByteArrayOutputStream ; 54 import java.io.IOException ; 55 import java.io.OutputStream ; 56 57 import com.lowagie.text.Anchor; 58 import com.lowagie.text.rtf.document.RtfDocument; 59 import com.lowagie.text.rtf.text.RtfPhrase; 60 61 62 70 public class RtfAnchor extends RtfField 71 { 72 75 private static final byte[] HYPERLINK = "HYPERLINK".getBytes(); 76 77 80 private String url = ""; 81 84 private RtfPhrase content = null; 85 86 92 public RtfAnchor(RtfDocument doc, Anchor anchor) { 93 super(doc); 94 this.url = anchor.getReference(); 95 this.content = new RtfPhrase(doc, anchor); 96 } 97 98 106 protected byte[] writeFieldInstContent() throws IOException 107 { 108 ByteArrayOutputStream result = new ByteArrayOutputStream (); 109 writeFieldInstContent(result); 110 return result.toByteArray(); 111 } 112 protected void writeFieldInstContent(OutputStream result) throws IOException 113 { 114 result.write(HYPERLINK); 115 result.write(DELIMITER); 116 this.document.filterSpecialChar(result, url, true, true); 118 } 119 120 128 protected byte[] writeFieldResultContent() throws IOException 129 { 130 return content.write(); 131 } 132 136 protected void writeFieldResultContent(OutputStream out) throws IOException 137 { 138 content.writeContent(out); 139 } 140 141 } 142 | Popular Tags |