1 31 package org.pdfbox.pdmodel.interactive.annotation; 32 33 import java.io.IOException ; 34 35 import org.pdfbox.cos.COSArray; 36 import org.pdfbox.cos.COSBase; 37 import org.pdfbox.cos.COSDictionary; 38 import org.pdfbox.cos.COSName; 39 import org.pdfbox.pdmodel.interactive.action.type.PDActionURI; 40 import org.pdfbox.pdmodel.interactive.documentnavigation.destination.PDDestination; 41 42 49 public class PDAnnotationLink extends PDAnnotation 50 { 51 52 53 56 public static final String HIGHLIGHT_MODE_NONE = "N"; 57 60 public static final String HIGHLIGHT_MODE_INVERT = "I"; 61 64 public static final String HIGHLIGHT_MODE_OUTLINE = "O"; 65 68 public static final String HIGHLIGHT_MODE_PUSH = "P"; 69 70 71 74 public static final String SUB_TYPE = "Link"; 75 76 79 public PDAnnotationLink() 80 { 81 super(); 82 getDictionary().setItem( COSName.SUBTYPE, COSName.getPDFName( SUB_TYPE ) ); 83 } 84 85 91 public PDAnnotationLink(COSDictionary field) 92 { 93 super( field ); 94 } 95 96 104 public PDDestination getDestination() throws IOException 105 { 106 COSBase base = getDictionary().getDictionaryObject( COSName.DEST ); 107 PDDestination retval = PDDestination.create( base ); 108 109 return retval; 110 } 111 112 117 public void setDestination( PDDestination dest ) 118 { 119 getDictionary().setItem( COSName.DEST, dest ); 120 } 121 122 128 public String getHighlightMode() 129 { 130 return getDictionary().getNameAsString( COSName.H, HIGHLIGHT_MODE_INVERT ); 131 } 132 133 138 public void setHighlightMode( String mode ) 139 { 140 getDictionary().setName( COSName.H, mode ); 141 } 142 143 149 public void setPreviousURI( PDActionURI pa ) 150 { 151 getDictionary().setItem( "PA", pa ); 152 } 153 154 160 public PDActionURI getPreviousURI() 161 { 162 COSDictionary pa = (COSDictionary) getDictionary().getDictionaryObject("PA"); 163 if ( pa != null ) 164 { 165 return new PDActionURI( pa ); 166 } 167 else 168 { 169 return null; 170 } 171 } 172 173 180 public void setQuadPoints( float[] quadPoints ) 181 { 182 COSArray newQuadPoints = new COSArray(); 183 newQuadPoints.setFloatArray( quadPoints ); 184 getDictionary().setItem( "QuadPoints", newQuadPoints ); 185 } 186 187 193 public float[] getQuadPoints() 194 { 195 COSArray quadPoints = (COSArray) getDictionary().getDictionaryObject( "QuadPoints" ); 196 if (quadPoints != null) 197 { 198 return quadPoints.toFloatArray(); 199 } 200 else 201 { 202 return null; } 204 } 205 } | Popular Tags |