Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSDictionary


     * This methods extracts from the Font dictionary all mandatory fields. If a mandatory field is missing, the list of
     * ValidationError in the FontContainer is updated.
     */
    protected void checkMandatoryFields()
    {
        COSDictionary fontDictionary = (COSDictionary) font.getCOSObject();
        boolean areFieldsPResent = fontDictionary.containsKey(COSName.TYPE);
        areFieldsPResent &= fontDictionary.containsKey(COSName.SUBTYPE);
        areFieldsPResent &= fontDictionary.containsKey(COSName.BASE_FONT);
        areFieldsPResent &= fontDictionary.containsKey(COSName.DESCENDANT_FONTS);
        areFieldsPResent &= fontDictionary.containsKey(COSName.ENCODING);

        if (!areFieldsPResent)
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                    "Some keys are missing from composite font dictionary"));
View Full Code Here


     * Extract the single CIDFont from the Descendant array. Create a FontValidator for this CODFont and launch its
     * validation.
     */
    protected void processDescendantFont() throws ValidationException
    {
        COSDictionary fontDictionary = (COSDictionary) font.getCOSObject();
        // a CIDFont is contained in the DescendantFonts array
        COSArray array = COSUtils.getAsArray(fontDictionary.getItem(COSName.DESCENDANT_FONTS), cosDocument);
        if (array == null || array.size() != 1)
        {
            /*
             * in PDF 1.4, this array must contain only one element, because of a PDF/A should be a PDF 1.4, this method
             * returns an error if the array has more than one element.
             */
            this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_INVALID,
                    "CIDFont is missing from the DescendantFonts array or the size of array is greater than 1"));
            return;
        }

        COSDictionary cidFont = COSUtils.getAsDictionary(array.get(0), cosDocument);
        if (cidFont == null)
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_INVALID,
                    "The DescendantFonts array should have one element with is a dictionary."));
            return;
View Full Code Here

        catch (IOException e)
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_CID_CMAP_DAMAGED, "The CMap type is damaged"));
        }

        COSDictionary cmapUsed = (COSDictionary) aCMap.getDictionaryObject(COSName
                .getPDFName(FONT_DICTIONARY_KEY_CMAP_USECMAP));
        if (cmapUsed != null)
        {
            checkCMapEncoding(cmapUsed);
        }
View Full Code Here

     * @return the validation result.
     */
    protected boolean checkCIDSystemInfo(COSBase sysinfo)
    {
        boolean result = true;
        COSDictionary cidSysInfo = COSUtils.getAsDictionary(sysinfo, cosDocument);

        if (cidSysInfo != null)
        {
            COSBase reg = cidSysInfo.getItem(COSName.REGISTRY);
            COSBase ord = cidSysInfo.getItem(COSName.ORDERING);
            COSBase sup = cidSysInfo.getItem(COSName.SUPPLEMENT);

            if (!(COSUtils.isString(reg, cosDocument) && COSUtils.isString(ord, cosDocument) && COSUtils.isInteger(sup,
                    cosDocument)))
            {
                this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_SYSINFO));
View Full Code Here

     *
     * @param cmap
     */
    private void compareCIDSystemInfo(COSDictionary cmap)
    {
        COSDictionary fontDictionary = (COSDictionary) font.getCOSObject();
        COSArray array = COSUtils.getAsArray(fontDictionary.getItem(COSName.DESCENDANT_FONTS), cosDocument);

        if (array != null && array.size() > 0)
        {
            COSDictionary cidFont = COSUtils.getAsDictionary(array.get(0), cosDocument);
            COSDictionary cmsi = COSUtils.getAsDictionary(cmap.getItem(COSName.CIDSYSTEMINFO), cosDocument);
            COSDictionary cfsi = COSUtils.getAsDictionary(cidFont.getItem(COSName.CIDSYSTEMINFO), cosDocument);

            String regCM = COSUtils.getAsString(cmsi.getItem(COSName.REGISTRY), cosDocument);
            String ordCM = COSUtils.getAsString(cmsi.getItem(COSName.ORDERING), cosDocument);
            String regCF = COSUtils.getAsString(cfsi.getItem(COSName.REGISTRY), cosDocument);
            String ordCF = COSUtils.getAsString(cfsi.getItem(COSName.ORDERING), cosDocument);

            if (!regCF.equals(regCM) || !ordCF.equals(ordCM))
            {
                this.fontContainer.push(new ValidationError(ERROR_FONTS_CIDKEYED_SYSINFO,
                        "The CIDSystemInfo is inconsistent"));
View Full Code Here

            entry.setValue( ((COSArray)parent).getObject( index ) );
            retval = entry;
        }
        else if( parent instanceof COSDictionary )
        {
            COSDictionary dict = ((COSDictionary)parent);
            List<COSName> keys = new ArrayList<COSName>(dict.keySet());
            Collections.sort( keys );
            Object key = keys.get( index );
            Object value = dict.getDictionaryObject( (COSName)key );
            MapEntry entry = new MapEntry();
            entry.setKey( key );
            entry.setValue( value );
            retval = entry;
        }
View Full Code Here

                }
            }
            else if( parent instanceof COSDictionary )
            {
                MapEntry entry = (MapEntry)child;
                COSDictionary dict = (COSDictionary)parent;
                List<COSName> keys = new ArrayList<COSName>(dict.keySet());
                Collections.sort( keys );
                for( int i=0; retval == -1 && i<keys.size(); i++ )
                {
                    if( keys.get( i ).equals( entry.getKey() ) )
                    {
View Full Code Here

        {
            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();
                }
View Full Code Here

     *
     * @param fontEncoding
     */
    private void checkEncodingAsDictionary(COSBase fontEncoding)
    {
        COSDictionary encodingDictionary = COSUtils.getAsDictionary(fontEncoding, cosDocument);
        this.encoding = new DictionaryEncoding(encodingDictionary, false, null);
    }
View Full Code Here

            this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                    "The Witdhs array is unreachable"));
            return;
        }

        COSDictionary charProcs = COSUtils.getAsDictionary(fontDictionary.getItem(COSName.CHAR_PROCS), cosDocument);
        if (charProcs == null)
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                    "The CharProcs element isn't a dictionary"));
            return;
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.