1 31 package org.pdfbox.pdmodel.interactive.documentnavigation.destination; 32 33 import java.io.IOException ; 34 35 import org.pdfbox.cos.COSArray; 36 import org.pdfbox.cos.COSBase; 37 import org.pdfbox.cos.COSName; 38 import org.pdfbox.cos.COSString; 39 40 import org.pdfbox.pdmodel.common.PDDestinationOrAction; 41 42 48 public abstract class PDDestination implements PDDestinationOrAction 49 { 50 51 61 public static PDDestination create( COSBase base ) throws IOException 62 { 63 PDDestination retval = null; 64 if( base == null ) 65 { 66 } 68 else if( base instanceof COSArray && ((COSArray)base).size() > 0 ) 69 { 70 COSArray array = (COSArray)base; 71 COSName type = (COSName)array.getObject( 1 ); 72 String typeString = type.getName(); 73 if( typeString.equals( PDPageFitDestination.TYPE ) || 74 typeString.equals( PDPageFitDestination.TYPE_BOUNDED )) 75 { 76 retval = new PDPageFitDestination( array ); 77 } 78 else if( typeString.equals( PDPageFitHeightDestination.TYPE ) || 79 typeString.equals( PDPageFitHeightDestination.TYPE_BOUNDED )) 80 { 81 retval = new PDPageFitHeightDestination( array ); 82 } 83 else if( typeString.equals( PDPageFitRectangleDestination.TYPE ) ) 84 { 85 retval = new PDPageFitRectangleDestination( array ); 86 } 87 else if( typeString.equals( PDPageFitWidthDestination.TYPE ) || 88 typeString.equals( PDPageFitWidthDestination.TYPE_BOUNDED )) 89 { 90 retval = new PDPageFitWidthDestination( array ); 91 } 92 else if( typeString.equals( PDPageXYZDestination.TYPE ) ) 93 { 94 retval = new PDPageXYZDestination( array ); 95 } 96 else 97 { 98 throw new IOException ( "Unknown destination type:" + type ); 99 } 100 } 101 else if( base instanceof COSString ) 102 { 103 retval = new PDNamedDestination( (COSString)base ); 104 } 105 else if( base instanceof COSName ) 106 { 107 retval = new PDNamedDestination( (COSName)base ); 108 } 109 else 110 { 111 throw new IOException ( "Error: can't convert to Destination " + base ); 112 } 113 return retval; 114 } 115 116 121 public String toString() 122 { 123 return super.toString(); 124 } 125 } 126 | Popular Tags |