Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.interactive.annotation » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one or more
    3    * contributor license agreements.  See the NOTICE file distributed with
    4    * this work for additional information regarding copyright ownership.
    5    * The ASF licenses this file to You under the Apache License, Version 2.0
    6    * (the "License"); you may not use this file except in compliance with
    7    * the License.  You may obtain a copy of the License at
    8    *
    9    *      http://www.apache.org/licenses/LICENSE-2.0
   10    *
   11    * Unless required by applicable law or agreed to in writing, software
   12    * distributed under the License is distributed on an "AS IS" BASIS,
   13    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    * See the License for the specific language governing permissions and
   15    * limitations under the License.
   16    */
   17   package org.apache.pdfbox.pdmodel.interactive.annotation;
   18   
   19   import java.io.IOException;
   20   
   21   import org.apache.pdfbox.cos.COSDictionary;
   22   import org.apache.pdfbox.cos.COSName;
   23   import org.apache.pdfbox.pdmodel.common.filespecification.PDFileSpecification;
   24   
   25   /**
   26    * This is the class that represents a file attachement.
   27    *
   28    * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
   29    * @version $Revision: 1.2 $
   30    */
   31   public class PDAnnotationFileAttachment extends PDAnnotationMarkup
   32   {
   33       /**
   34        * See get/setAttachmentName.
   35        */
   36       public static final String ATTACHMENT_NAME_PUSH_PIN = "PushPin";
   37       /**
   38        * See get/setAttachmentName.
   39        */
   40       public static final String ATTACHMENT_NAME_GRAPH = "Graph";
   41       /**
   42        * See get/setAttachmentName.
   43        */
   44       public static final String ATTACHMENT_NAME_PAPERCLIP = "Paperclip";
   45       /**
   46        * See get/setAttachmentName.
   47        */
   48       public static final String ATTACHMENT_NAME_TAG = "Tag";
   49   
   50       /**
   51        * The type of annotation.
   52        */
   53       public static final String SUB_TYPE = "FileAttachment";
   54   
   55       /**
   56        * Constructor.
   57        */
   58       public PDAnnotationFileAttachment()
   59       {
   60           super();
   61           getDictionary().setItem( COSName.SUBTYPE, COSName.getPDFName( SUB_TYPE ) );
   62       }
   63   
   64       /**
   65        * Creates a Link annotation from a COSDictionary, expected to be
   66        * a correct object definition.
   67        *
   68        * @param field the PDF objet to represent as a field.
   69        */
   70       public PDAnnotationFileAttachment(COSDictionary field)
   71       {
   72           super( field );
   73       }
   74   
   75       /**
   76        * Return the attached file.
   77        *
   78        * @return The attached file.
   79        *
   80        * @throws IOException If there is an error creating the file spec.
   81        */
   82       public PDFileSpecification getFile() throws IOException
   83       {
   84           return PDFileSpecification.createFS( getDictionary().getDictionaryObject( "FS" ) );
   85       }
   86   
   87       /**
   88        * Set the attached file.
   89        *
   90        * @param file The file that is attached.
   91        */
   92       public void setFile( PDFileSpecification file )
   93       {
   94           getDictionary().setItem( "FS", file );
   95       }
   96   
   97       /**
   98        * This is the name used to draw the type of attachment.
   99        * See the ATTACHMENT_NAME_XXX constants.
  100        *
  101        * @return The name that describes the visual cue for the attachment.
  102        */
  103       public String getAttachmentName()
  104       {
  105           return getDictionary().getNameAsString( "Name", ATTACHMENT_NAME_PUSH_PIN );
  106       }
  107   
  108       /**
  109        * Set the name used to draw the attachement icon.
  110        * See the ATTACHMENT_NAME_XXX constants.
  111        *
  112        * @param name The name of the visual icon to draw.
  113        */
  114       public void setAttachementName( String name )
  115       {
  116           getDictionary().setName( "Name", name );
  117       }
  118   }

Home » pdfbox-1.1.0-src » org.apache.pdfbox.pdmodel.interactive.annotation » [javadoc | source]