/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.pdfbox.pdmodel.interactive.form;
import org.apache.pdfbox.cos.COSDictionary;
import org.apache.pdfbox.cos.COSName;
import org.apache.pdfbox.cos.COSString;
import java.io.IOException;
/**
* A class for handling the PDF field as a PDPushButton.
*
* @author sug
* @version $Revision: 1.3 $
*/
public class PDPushButton extends PDField
{
/**
* @see org.apache.pdfbox.pdmodel.field.PDField#COSField(org.apache.pdfbox.cos.COSDictionary)
*
* @param theAcroForm The acroForm for this field.
* @param field The field for this push button.
*/
public PDPushButton( PDAcroForm theAcroForm, COSDictionary field)
{
super(theAcroForm, field);
}
/**
* @see as.interactive.pdf.form.cos.COSField#setValue(java.lang.String)
*
* @param value The new value for the field.
*
* @throws IOException If there is an error creating the appearance stream.
*/
public void setValue(String value) throws IOException
{
COSString fieldValue = new COSString(value);
getDictionary().setItem( COSName.getPDFName( "V" ), fieldValue );
getDictionary().setItem( COSName.getPDFName( "DV" ), fieldValue );
}
/**
* getValue gets the fields value to as a string.
*
* @return The string value of this field.
*
* @throws IOException If there is an error getting the value.
*/
public String getValue() throws IOException
{
return getDictionary().getString( "V" );
}
}