Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSArray


     * @return A list of templates.
     */
    public List<FDFTemplate> getTemplates()
    {
        List<FDFTemplate> retval = null;
        COSArray array = (COSArray)page.getDictionaryObject( COSName.TEMPLATES );
        if( array != null )
        {
            List<FDFTemplate> objects = new ArrayList<FDFTemplate>();
            for( int i=0; i<array.size(); i++ )
            {
                objects.add( new FDFTemplate( (COSDictionary)array.getObject( i ) ) );
            }
            retval = new COSArrayList<FDFTemplate>( objects, array );
        }
        return retval;
    }
View Full Code Here


    // returns the "Opt" index for the given string
    private int getSelectedIndex(String optionValue)
    {
        int indexSelected = -1;
        COSArray options = getOptions();
        // YXJ: Changed the order of the loops. Acrobat produces PDF's
        // where sometimes there is 1 string and the rest arrays.
        // This code works either way.
        for (int i = 0; i < options.size() && indexSelected == -1; i++)
        {
            COSBase option = options.getObject(i);
            if (option instanceof COSArray)
            {
                COSArray keyValuePair = (COSArray) option;
                COSString key = (COSString) keyValuePair.getObject(0);
                COSString value = (COSString) keyValuePair.getObject(1);
                if (optionValue.equals(key.getString()) || optionValue.equals(value.getString()))
                {
                    indexSelected = i;
                }
            }
View Full Code Here

    }

    @Override
    public void createProcSetArray()
    {
        COSArray procSetArr = new COSArray();
        procSetArr.add(COSName.getPDFName("PDF"));
        procSetArr.add(COSName.getPDFName("Text"));
        procSetArr.add(COSName.getPDFName("ImageB"));
        procSetArr.add(COSName.getPDFName("ImageC"));
        procSetArr.add(COSName.getPDFName("ImageI"));
        pdfStructure.setProcSet(procSetArr);
        log.info("ProcSet array has been created");
    }
View Full Code Here

    }

    // implements "MultiSelect"
    private void selectMultiple(int selectedIndex)
    {
        COSArray indexArray = getSelectedOptions();
        if (indexArray != null)
        {
            indexArray.clear();
            indexArray.add(COSInteger.get(selectedIndex));
        }
    }
View Full Code Here

     * @return The fractional space to allocate.
     */
    public PDRange getFractionalSpaceToAllocate()
    {
        PDRange retval = null;
        COSArray array = (COSArray)fit.getDictionaryObject( COSName.A );
        if( array == null )
        {
            retval = new PDRange();
            retval.setMin( .5f );
            retval.setMax( .5f );
View Full Code Here

    /**
     * Default constructor.
     */
    public COSArrayList()
    {
        array = new COSArray();
        actual = new ArrayList<E>();
    }
View Full Code Here

     * @param dictionary The dictionary that holds the item, and will hold the array if an item is added.
     * @param dictionaryKey The key into the dictionary to set the item.
     */
    public COSArrayList( E actualObject, COSBase item, COSDictionary dictionary, COSName dictionaryKey )
    {
        array = new COSArray();
        array.add( item );
        actual = new ArrayList<E>();
        actual.add( actualObject );

        parentDict = dictionary;
View Full Code Here

     *
     * @return An array of COSName objects
     */
    public static COSArray convertStringListToCOSNameCOSArray( List<String> strings )
    {
        COSArray retval = new COSArray();
        for (String string : strings)
        {
            retval.add(COSName.getPDFName(string));
        }
        return retval;
    }
View Full Code Here

     *
     * @return An array of COSName objects
     */
    public static COSArray convertStringListToCOSStringCOSArray( List<String> strings )
    {
        COSArray retval = new COSArray();
        for (String string : strings)
        {
            retval.add(new COSString(string));
        }
        return retval;
    }
View Full Code Here

     *
     * @return A list of COSBase.
     */
    public static COSArray converterToCOSArray( List<?> cosObjectableList )
    {
        COSArray array = null;
        if( cosObjectableList != null )
        {
            if( cosObjectableList instanceof COSArrayList )
            {
                //if it is already a COSArrayList then we don't want to recreate the array, we want to reuse it.
                array = ((COSArrayList<?>)cosObjectableList).array;
            }
            else
            {
                array = new COSArray();
                Iterator<?> iter = cosObjectableList.iterator();
                while( iter.hasNext() )
                {
                    Object next = iter.next();
                    if( next instanceof String )
                    {
                        array.add( new COSString( (String)next ) );
                    }
                    else if( next instanceof Integer || next instanceof Long )
                    {
                        array.add( COSInteger.get( ((Number)next).longValue() ) );
                    }
                    else if( next instanceof Float || next instanceof Double )
                    {
                        array.add( new COSFloat( ((Number)next).floatValue() ) );
                    }
                    else if( next instanceof COSObjectable )
                    {
                        COSObjectable object = (COSObjectable)next;
                        array.add( object.getCOSObject() );
                    }
                    else if( next instanceof DualCOSObjectable )
                    {
                        DualCOSObjectable object = (DualCOSObjectable)next;
                        array.add( object.getFirstCOSObject() );
                        array.add( object.getSecondCOSObject() );
                    }
                    else if( next == null )
                    {
                        array.add( COSNull.NULL );
                    }
                    else
                    {
                        throw new RuntimeException( "Error: Don't know how to convert type to COSBase '" +
                        next.getClass().getName() + "'" );
View Full Code Here

TOP

Related Classes of org.apache.pdfbox.cos.COSArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.