Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSName


    private Object convertToTreeObject( Object nodeValue )
    {
        if( nodeValue instanceof MapEntry)
        {
            MapEntry entry = (MapEntry)nodeValue;
            COSName key = (COSName)entry.getKey();
            COSBase value = (COSBase)entry.getValue();
            nodeValue = key.getName() + ":" + convertToTreeObject( value );
        }
        else if( nodeValue instanceof COSFloat )
        {
            nodeValue = "" + ((COSFloat)nodeValue).floatValue();
        }
        else if( nodeValue instanceof COSInteger )
        {
            nodeValue = "" + ((COSInteger)nodeValue).intValue();
        }
        else if( nodeValue instanceof COSString )
        {
            nodeValue = ((COSString)nodeValue).getString();
        }
        else if( nodeValue instanceof COSName )
        {
            nodeValue = ((COSName)nodeValue).getName();
        }
        else if( nodeValue instanceof ArrayEntry)
        {
            ArrayEntry entry = (ArrayEntry)nodeValue;
            nodeValue = "[" + entry.getIndex() + "]" + convertToTreeObject( entry.getValue() );
        }
        else if( nodeValue instanceof COSNull )
        {
            nodeValue = "null";
        }
        else if( nodeValue instanceof COSDictionary )
        {
            COSDictionary dict = (COSDictionary)nodeValue;
            if( nodeValue instanceof COSStream )
            {
                nodeValue = "Stream";
            }
            else
            {
                nodeValue = "Dictionary";
            }

            COSName type = (COSName)dict.getDictionaryObject( COSName.TYPE );
            if( type != null )
            {
                nodeValue = nodeValue + "(" + type.getName();
                COSName subType = (COSName)dict.getDictionaryObject( COSName.SUBTYPE );
                if( subType != null )
                {
                    nodeValue = nodeValue + ":" + subType.getName();
                }

                nodeValue = nodeValue + ")";
            }
        }
View Full Code Here


{
    @Override
    public final DecodeResult decode(InputStream encoded, OutputStream decoded,
                                         COSDictionary parameters, int index) throws IOException
    {
        COSName encryptionName = (COSName) parameters.getDictionaryObject(COSName.NAME);
        if(encryptionName == null || encryptionName.equals(COSName.IDENTITY))
        {
            // currently the only supported implementation is the Identity crypt filter
            Filter identityFilter = new IdentityFilter();
            identityFilter.decode(encoded, decoded, parameters, index);
            return new DecodeResult(parameters);
        }
        else
        {
            throw new IOException("Unsupported crypt filter " + encryptionName.getName());
        }
    }
View Full Code Here

    @Override
    protected final void encode(InputStream input, OutputStream encoded, COSDictionary parameters)
            throws IOException
    {
        COSName encryptionName = (COSName) parameters.getDictionaryObject(COSName.NAME);
        if(encryptionName == null || encryptionName.equals(COSName.IDENTITY))
        {
            // currently the only supported implementation is the Identity crypt filter
            Filter identityFilter = new IdentityFilter();
            identityFilter.encode(input, encoded, parameters);
        }
        else
        {
            throw new IOException("Unsupported crypt filter " + encryptionName.getName());
        }
    }
View Full Code Here

        }*/

        //Find first free resource name with the pattern "MC<index>"
        int index = 0;
        PDOptionalContentGroup ocg;
        COSName resourceName;
        do
        {
            resourceName = COSName.getPDFName("MC" + index);
            index++;
        } while (resources.getProperties(resourceName) != null);
View Full Code Here

    private void transferDict(COSDictionary orgDict, COSDictionary targetDict,
            Set<String> filter, boolean inclusive) throws IOException
    {
        for (Map.Entry<COSName, COSBase> entry : orgDict.entrySet())
        {
            COSName key = entry.getKey();
            if (inclusive && !filter.contains(key.getName()))
            {
                continue;
            }
            else if (!inclusive && filter.contains(key.getName()))
            {
                continue;
            }
            targetDict.setItem(key,
                    cloner.cloneForNewDocument(entry.getValue()));
View Full Code Here

        {
            return dict.getKeyForValue(object.getCOSObject());
        }

        // add the item with a new key
        COSName name = createKey(kind, prefix);
        put(kind, name, object);
        return name;
    }
View Full Code Here

    @Override
    public void insertInnerFormToHolerResources(PDFormXObject innerForm,
                                                PDResources holderFormResources)
    {
        COSName name = holderFormResources.add(innerForm, "FRM");
        pdfStructure.setInnerFormName(name);
        log.info("Alerady inserted inner form  inside holder form");
    }
View Full Code Here

        // imageForm.getResources().addFont(font);
        // imageForm.getResources().setFonts(fonts);

        imageFormResources.getCOSObject().setDirect(true);
        COSName imageFormName = innerFormResource.add(imageForm, "n");
        COSName imageName = imageFormResources.add(img, "img");
        pdfStructure.setImageForm(imageForm);
        pdfStructure.setImageFormName(imageFormName);
        pdfStructure.setImageName(imageName);
        log.info("Created image form");
    }
View Full Code Here

     * PDFont loads embedded fonts in its constructor so we have to handle IOExceptions
     * from PDFont and translate them into validation errors.
     */
    private void addFontError(COSDictionary dictionary, PreflightContext context)
    {
        COSName type = dictionary.getCOSName(COSName.TYPE, COSName.FONT);
        if (!COSName.FONT.equals(type))
        {
            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_UNKNOWN_FONT_TYPE,
                    "Expected 'Font' dictionary but found '" + type.getName() + "'"));
        }

        String fontName = "Unknown";
        if (dictionary.containsKey(COSName.BASE_FONT))
        {
            fontName = dictionary.getNameAsString(COSName.BASE_FONT);
        }

        COSName subType = dictionary.getCOSName(COSName.SUBTYPE);
        if (COSName.TYPE1.equals(subType))
        {
            addValidationError(context, new ValidationError(PreflightConstants.ERROR_FONTS_TYPE1_DAMAGED,
                    "The FontFile can't be read for " + fontName));
        }
View Full Code Here

     */
    public boolean isChecked()
    {
        boolean retval = false;
        String onValue = getOnValue();
        COSName radioValue = (COSName)getDictionary().getDictionaryObject( COSName.AS );
        if( radioValue != null && value != null && radioValue.getName().equals( onValue ) )
        {
            retval = true;
        }

        return retval;
View Full Code Here

TOP

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

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.