Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSDictionary


    /**
     * Constructor.
     */
    public PDFont()
    {
        font = new COSDictionary();
        font.setItem( COSName.TYPE, COSName.FONT );
    }
View Full Code Here


                            {
                                COSArray descendantFontArray =
                                    (COSArray)font.getDictionaryObject( COSName.DESCENDANT_FONTS );
                                if (descendantFontArray != null)
                                {
                                    COSDictionary descendantFontDictionary =
                                        (COSDictionary)descendantFontArray.getObject( 0 );
                                    PDFont descendentFont = PDFontFactory.createFont( descendantFontDictionary );
                                    COSDictionary cidsysteminfo =
                                        (COSDictionary)descendentFont.font.getDictionaryObject(COSName.CIDSYSTEMINFO);
                                    if (cidsysteminfo != null)
                                    {
                                        String ordering = cidsysteminfo.getString(COSName.ORDERING);
                                        String registry = cidsysteminfo.getString(COSName.REGISTRY);
                                        cmapName = registry + "-" + ordering+"-UCS2";
                                    }
                                }
                            }
                            else
                            {
                                cmapName = CMapSubstitution.substituteCMap( cmapName );
                            }

                            String resourceRoot = "org/apache/pdfbox/resources/cmap/";
                            String resourceName = resourceRoot + cmapName;
                            parseCmap( resourceRoot, ResourceLoader.loadResource( resourceName ), encodingName );
                            if( cmap == null && !encodingName.getName().equals( COSName.IDENTITY_H.getName() ) )
                            {
                                throw new IOException( "Error: Could not find predefined " +
                                "CMAP file for '" + encodingName.getName() + "'" );
                            }
                        }
                    }
                    else if( encoding instanceof COSName ||
                             encoding instanceof COSDictionary )
                    {
                        Encoding currentFontEncoding = getEncoding();
                        if( currentFontEncoding != null )
                        {
                            retval = currentFontEncoding.getCharacter( getCodeFromArray( c, offset, length ) );
                        }
                    }
                    else
                    {
                        COSDictionary fontDescriptor =
                            (COSDictionary)font.getDictionaryObject( COSName.FONT_DESC );
                        if( isTrueTypeFont() && fontDescriptor != null &&
                            (fontDescriptor.getDictionaryObject( COSName.FONT_FILE )!= null ||
                             fontDescriptor.getDictionaryObject( COSName.FONT_FILE2 ) != null ||
                             fontDescriptor.getDictionaryObject( COSName.FONT_FILE3 ) != null ) )
                        {
                            //If we are using an embedded font then there is not much we can do besides
                            //return the same character codes.
                            //retval = new String( c,offset, length );
                            retval = getStringFromArray( c, offset, length );
View Full Code Here

             * case one : The value associated with /Encoding is a reference to a dictionary.
             * This dictionary is represented by an instance of DictionaryEncoding class
             */
            else if( encoding instanceof COSDictionary )
            {
                COSDictionary encodingDic = (COSDictionary)encoding;
                //Let's see if the encoding dictionary has a base encoding
                //If it does not then we will attempt to get it from the font
                //file
                COSName baseEncodingName = (COSName) encodingDic.getDictionaryObject(
                    COSName.BASE_ENCODING);
                //on ajoute une entr�e /BaseEncoding dans /Encoding uniquement si elle en est absente
                //if not find in Encoding dictinary target, we try to find it from else where
                if( baseEncodingName == null)
                {
                    COSName fontEncodingFromFile = getEncodingFromFont();
                    encodingDic.setItem(
                        COSName.BASE_ENCODING,
                        fontEncodingFromFile );
                }
                fontEncoding = new DictionaryEncoding( encodingDic );
            }
View Full Code Here

        //dans le flux r�f�renc� par � la cl� FileFont lui m�me situ� dans
        //le dictionnaire associ� � /FontDescriptor du dictionnaire de type /Font courrant
        //get the font program in the stream which should be located in
         //the /FileFont Stream object himself in the /FontDescriptior of the current
        //font dictionary
        COSDictionary fontDescriptor = (COSDictionary) font.getDictionaryObject(
            COSName.FONT_DESC);
        if( fontDescriptor != null )
        {
            COSStream fontFile = (COSStream) fontDescriptor.getDictionaryObject(
                COSName.FONT_FILE);
            if( fontFile != null )
            {
                BufferedReader in =
                        new BufferedReader(new InputStreamReader(fontFile.getUnfilteredStream()));
View Full Code Here

    /**
     * creates a new empty encryption dictionary.
     */
    public PDEncryption()
    {
        dictionary = new COSDictionary();
    }
View Full Code Here

     *
     * @return the crypt filter with the given name if available
     */
    public PDCryptFilterDictionary getCryptFilterDictionary(COSName cryptFilterName)
    {
        COSDictionary cryptFilterDictionary = (COSDictionary) dictionary.getDictionaryObject( COSName.CF );
        if (cryptFilterDictionary != null)
        {
            COSDictionary stdCryptFilterDictionary = (COSDictionary)cryptFilterDictionary.getDictionaryObject(cryptFilterName);
            if (stdCryptFilterDictionary != null)
            {
                return new PDCryptFilterDictionary(stdCryptFilterDictionary);
            }
        }
View Full Code Here

     * @param cryptFilterName the name of the crypt filter
     * @param cryptFilterDictionary the crypt filter to set
     */
    public void setCryptFilterDictionary(COSName cryptFilterName, PDCryptFilterDictionary cryptFilterDictionary)
    {
        COSDictionary cfDictionary = (COSDictionary)dictionary.getDictionaryObject( COSName.CF );
        if (cfDictionary == null)
        {
            cfDictionary = new COSDictionary();
            dictionary.setItem(COSName.CF, cfDictionary);
        }
       
        cfDictionary.setItem(cryptFilterName, cryptFilterDictionary.getCOSDictionary());
    }
View Full Code Here

     * Creates a new Lab color space.
     */
    public PDLab()
    {
        array = new COSArray();
        dictionary = new COSDictionary();
        array.add(COSName.LAB);
        array.add(dictionary);
    }
View Full Code Here

    /**
     * creates a new empty crypt filter dictionary.
     */
    public PDCryptFilterDictionary()
    {
        cryptFilterDictionary = new COSDictionary();
    }
View Full Code Here

     * @throws IOException If there is an error in the decryption.
     */
    protected void proceedDecryption() throws IOException
    {

        COSDictionary trailer = document.getDocument().getTrailer();
        COSArray fields = (COSArray) trailer.getObjectFromPath("Root/AcroForm/Fields");

        // We need to collect all the signature dictionaries, for some
        // reason the 'Contents' entry of signatures is not really encrypted
        if (fields != null)
        {
            for (int i = 0; i < fields.size(); i++)
            {
                COSDictionary field = (COSDictionary) fields.getObject(i);
                if (field != null)
                {
                    addDictionaryAndSubDictionary(potentialSignatures, field);
                }
                else
                {
                    throw new IOException("Could not decypt document, object not found.");
                }
            }
        }

        List<COSObject> allObjects = document.getDocument().getObjects();
        Iterator<COSObject> objectIter = allObjects.iterator();
        COSDictionary encryptionDict = document.getEncryption().getCOSDictionary();
        while (objectIter.hasNext())
        {
            COSObject nextObj = objectIter.next();
            if (nextObj.getObject() != encryptionDict)
            {
View Full Code Here

TOP

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

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.