2 * Licensed to the Apache Software Foundation (ASF) under one or more
\r
3 * contributor license agreements. See the NOTICE file distributed with
\r
4 * this work for additional information regarding copyright ownership.
\r
5 * The ASF licenses this file to You under the Apache License, Version 2.0
\r
6 * (the "License"); you may not use this file except in compliance with
\r
7 * the License. You may obtain a copy of the License at
\r
9 * http://www.apache.org/licenses/LICENSE-2.0
\r
11 * Unless required by applicable law or agreed to in writing, software
\r
12 * distributed under the License is distributed on an "AS IS" BASIS,
\r
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
14 * See the License for the specific language governing permissions and
\r
15 * limitations under the License.
\r
17 package org.apache.pdfbox.pdmodel.interactive.annotation;
\r
19 import java.io.IOException;
\r
21 import org.apache.pdfbox.cos.COSDictionary;
\r
22 import org.apache.pdfbox.cos.COSName;
\r
23 import org.apache.pdfbox.pdmodel.common.filespecification.PDFileSpecification;
\r
26 * This is the class that represents a file attachement.
\r
28 * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
\r
29 * @version $Revision: 1.2 $
\r
31 public class PDAnnotationFileAttachment extends PDAnnotationMarkup
\r
34 * See get/setAttachmentName.
\r
36 public static final String ATTACHMENT_NAME_PUSH_PIN = "PushPin";
\r
38 * See get/setAttachmentName.
\r
40 public static final String ATTACHMENT_NAME_GRAPH = "Graph";
\r
42 * See get/setAttachmentName.
\r
44 public static final String ATTACHMENT_NAME_PAPERCLIP = "Paperclip";
\r
46 * See get/setAttachmentName.
\r
48 public static final String ATTACHMENT_NAME_TAG = "Tag";
\r
51 * The type of annotation.
\r
53 public static final String SUB_TYPE = "FileAttachment";
\r
58 public PDAnnotationFileAttachment()
\r
61 getDictionary().setItem( COSName.SUBTYPE, COSName.getPDFName( SUB_TYPE ) );
\r
65 * Creates a Link annotation from a COSDictionary, expected to be
\r
66 * a correct object definition.
\r
68 * @param field the PDF objet to represent as a field.
\r
70 public PDAnnotationFileAttachment(COSDictionary field)
\r
76 * Return the attached file.
\r
78 * @return The attached file.
\r
80 * @throws IOException If there is an error creating the file spec.
\r
82 public PDFileSpecification getFile() throws IOException
\r
84 return PDFileSpecification.createFS( getDictionary().getDictionaryObject( "FS" ) );
\r
88 * Set the attached file.
\r
90 * @param file The file that is attached.
\r
92 public void setFile( PDFileSpecification file )
\r
94 getDictionary().setItem( "FS", file );
\r
98 * This is the name used to draw the type of attachment.
\r
99 * See the ATTACHMENT_NAME_XXX constants.
\r
101 * @return The name that describes the visual cue for the attachment.
\r
103 public String getAttachmentName()
\r
105 return getDictionary().getNameAsString( "Name", ATTACHMENT_NAME_PUSH_PIN );
\r
109 * Set the name used to draw the attachement icon.
\r
110 * See the ATTACHMENT_NAME_XXX constants.
\r
112 * @param name The name of the visual icon to draw.
\r
114 public void setAttachementName( String name )
\r
116 getDictionary().setName( "Name", name );
\r