001: /**
002: * Copyright (c) 2005, www.pdfbox.org
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions are met:
007: *
008: * 1. Redistributions of source code must retain the above copyright notice,
009: * this list of conditions and the following disclaimer.
010: * 2. Redistributions in binary form must reproduce the above copyright notice,
011: * this list of conditions and the following disclaimer in the documentation
012: * and/or other materials provided with the distribution.
013: * 3. Neither the name of pdfbox; nor the names of its
014: * contributors may be used to endorse or promote products derived from this
015: * software without specific prior written permission.
016: *
017: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
018: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
019: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
020: * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
021: * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
022: * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
023: * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
024: * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
025: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
026: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
027: *
028: * http://www.pdfbox.org
029: *
030: */package org.pdfbox.pdmodel.graphics.xobject;
031:
032: import org.pdfbox.cos.COSDictionary;
033: import org.pdfbox.cos.COSName;
034: import org.pdfbox.cos.COSStream;
035:
036: import org.pdfbox.pdmodel.PDResources;
037: import org.pdfbox.pdmodel.common.PDStream;
038:
039: /**
040: * A form xobject.
041: *
042: * @author <a href="mailto:ben@benlitchfield.com">Ben Litchfield</a>
043: * @version $Revision: 1.5 $
044: */
045: public class PDXObjectForm extends PDXObject {
046: /**
047: * The XObject subtype.
048: */
049: public static final String SUB_TYPE = "Form";
050:
051: /**
052: * Standard constuctor.
053: *
054: * @param formStream The XObject is passed as a COSStream.
055: */
056: public PDXObjectForm(PDStream formStream) {
057: super (formStream);
058: }
059:
060: /**
061: * Standard constuctor.
062: *
063: * @param formStream The XObject is passed as a COSStream.
064: */
065: public PDXObjectForm(COSStream formStream) {
066: super (formStream);
067: }
068:
069: /**
070: * This will get the form type, currently 1 is the only form type.
071: *
072: * @return The form type.
073: */
074: public int getFormType() {
075: return getCOSStream().getInt("FormType", 1);
076: }
077:
078: /**
079: * Set the form type.
080: *
081: * @param formType The new form type.
082: */
083: public void setFormType(int formType) {
084: getCOSStream().setInt("FormType", formType);
085: }
086:
087: /**
088: * This will get the resources at this page and not look up the hierarchy.
089: * This attribute is inheritable, and findResources() should probably used.
090: * This will return null if no resources are available at this level.
091: *
092: * @return The resources at this level in the hierarchy.
093: */
094: public PDResources getResources() {
095: PDResources retval = null;
096: COSDictionary resources = (COSDictionary) getCOSStream()
097: .getDictionaryObject(COSName.RESOURCES);
098: if (resources != null) {
099: retval = new PDResources(resources);
100: }
101: return retval;
102: }
103:
104: /**
105: * This will set the resources for this page.
106: *
107: * @param resources The new resources for this page.
108: */
109: public void setResources(PDResources resources) {
110: getCOSStream().setItem(COSName.RESOURCES, resources);
111: }
112: }
|