Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSBase


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


                    }
                }
            }
            for (Iterator<COSObject> i = doc.getDocument().getObjects().iterator(); i.hasNext();)
            {
                COSBase base = ((COSObject) i.next()).getObject();
                if (base instanceof COSStream)
                {
                    // just kill the filters
                    COSStream cosStream = (COSStream)base;
                    cosStream.getUnfilteredStream();
View Full Code Here

    }

    @Override
    protected void checkEncoding()
    {
        COSBase encoding = ((COSDictionary) fontDictionary).getItem(COSName.ENCODING);
        if (encoding != null)
        {
            COSDocument cosDocument = context.getDocument().getDocument();
            if (COSUtils.isString(encoding, cosDocument))
            {
View Full Code Here

     * Check that the FontBBox element has the right format as declared in the
     * PDF reference document.
     */
    private void checkFontBBox()
    {
        COSBase fontBBox = fontDictionary.getItem(COSName.FONT_BBOX);

        if (!COSUtils.isArray(fontBBox, cosDocument))
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                    "The FontBBox element isn't an array"));
            return;
        }

        /*
         * check the content of the FontBBox. Should be an array with 4 numbers
         */
        COSArray bbox = COSUtils.getAsArray(fontBBox, cosDocument);
        if (bbox.size() != 4)
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                    "The FontBBox element is invalid"));
            return;
        }
       
        for (int i = 0; i < 4; i++)
        {
            COSBase elt = bbox.get(i);
            if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
            {
                this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                        "An element of FontBBox isn't a number"));
                return;
View Full Code Here

    /**
     * Check that the FontMatrix element has the right format as declared in the PDF reference document.
     */
    private void checkFontMatrix()
    {
        COSBase fontMatrix = fontDictionary.getItem(COSName.FONT_MATRIX);

        if (!COSUtils.isArray(fontMatrix, cosDocument))
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                    "The FontMatrix element isn't an array"));
            return;
        }

        /*
         * Check the content of the FontMatrix. Should be an array with 6 numbers
         */
        COSArray matrix = COSUtils.getAsArray(fontMatrix, cosDocument);
        if (matrix.size() != 6)
        {
            this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                    "The FontMatrix element is invalid"));
            return;
        }

        for (int i = 0; i < 6; i++)
        {
            COSBase elt = matrix.get(i);
            if (!(COSUtils.isFloat(elt, cosDocument) || COSUtils.isInteger(elt, cosDocument)))
            {
                this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                        "An element of FontMatrix isn't a number"));
                return;
View Full Code Here

     * kept in the {@link #encoding} attribute
     */
    @Override
    protected void checkEncoding()
    {
        COSBase fontEncoding = fontDictionary.getItem(COSName.ENCODING);
        if (COSUtils.isString(fontEncoding, cosDocument))
        {
            checkEncodingAsString(fontEncoding);
        }
        else if (COSUtils.isDictionary(fontEncoding, cosDocument))
View Full Code Here

     * If the Resources entry is present, this method check its content. Only fonts and Images are checked because this
     * resource describes glyphs.
     */
    private void checkResources() throws ValidationException
    {
        COSBase resources = this.fontDictionary.getItem(COSName.RESOURCES);
        if (resources != null)
        {

            COSDictionary dictionary = COSUtils.getAsDictionary(resources, cosDocument);
            if (dictionary == null)
            {
                this.fontContainer.push(new ValidationError(ERROR_FONTS_DICTIONARY_INVALID,
                        "The Resources element isn't a dictionary"));
                return;
            }

            // process Fonts and XObjects
            ContextHelper.validateElement(context, new PDResources(dictionary), RESOURCES_PROCESS);
            COSBase cbFont = dictionary.getItem(COSName.FONT);

            if (cbFont != null)
            {
                /*
                 * Check that all referenced object are present in the PDF file
                 */
                COSDictionary dicFonts = COSUtils.getAsDictionary(cbFont, cosDocument);
                Set<COSName> keyList = dicFonts.keySet();
                for (Object key : keyList)
                {

                    COSBase item = dicFonts.getItem((COSName) key);
                    COSDictionary xObjFont = COSUtils.getAsDictionary(item, cosDocument);

                    try
                    {
                        PDFont aFont = PDFontFactory.createFont(xObjFont);
View Full Code Here

    protected void checkCIDSystemInfo(COSBase sysinfo)
    {
        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

    // gets the decode params for a specific filter index, this is used to
    // normalise the DecodeParams entry so that it is always a dictionary
    protected COSDictionary getDecodeParams(COSDictionary dictionary, int index)
    {
        COSBase obj = dictionary.getDictionaryObject(COSName.DECODE_PARMS, COSName.DP);
        if (obj instanceof COSDictionary)
        {
            return (COSDictionary)obj;
        }
        else if (obj instanceof COSArray)
        {
            COSArray array = (COSArray)obj;
            if (index < array.size())
            {
                return (COSDictionary)array.getObject(index);
            }
        }
        else if (obj != null)
        {
            log.error("Expected DecodeParams to be an Array or Dictionary but found " +
                      obj.getClass().getName());
        }
        return new COSDictionary();
    }
View Full Code Here

        {
            fontDescriptor = null;
        }

        // ToUnicode CMap
        COSBase toUnicode = dict.getDictionaryObject(COSName.TO_UNICODE);
        if (toUnicode != null)
        {
            toUnicodeCMap = readCMap(toUnicode);
            if (toUnicodeCMap != null && !toUnicodeCMap.hasUnicodeMappings())
            {
View Full Code Here

TOP

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

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.