Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSBase


     */
    public float getSpaceWidth()
    {
        if (fontWidthOfSpace == -1f)
        {
            COSBase toUnicode = dict.getDictionaryObject(COSName.TO_UNICODE);
            try
            {
                if (toUnicode != null)
                {
                    int spaceMapping = toUnicodeCMap.getSpaceMapping();
View Full Code Here


     * Returns the color space resource with the given name, or null if none exists.
     */
    public PDColorSpace getColorSpace(COSName name) throws IOException
    {
        // get the instance
        COSBase object = get(COSName.COLORSPACE, name);
        if (object != null)
        {
            return PDColorSpace.create(object, this);
        }
        else
View Full Code Here

    /**
     * Returns the XObject resource with the given name, or null if none exists.
     */
    public PDXObject getXObject(COSName name) throws IOException
    {
        COSBase value = get(COSName.XOBJECT, name);
        if (value == null)
        {
            return null;
        }
        else if (value instanceof COSObject)
View Full Code Here

        {
            indices = new HashMap<Integer,COSObjectable>();
            for( int i=0; i<namesArray.size(); i+=2 )
            {
                COSInteger key = (COSInteger)namesArray.getObject(i);
                COSBase cosValue = namesArray.getObject( i+1 );
                COSObjectable pdValue = convertCOSToPD( cosValue );
                indices.put( key.intValue(), pdValue );
            }
            indices = Collections.unmodifiableMap(indices);
        }
View Full Code Here

        restoreStream.flush();

        //Wrap the existing page's content in a save/restore pair (q/Q) to have a controlled
        //environment to add additional content.
        COSDictionary pageDictionary = page.getCOSObject();
        COSBase contents = pageDictionary.getDictionaryObject(COSName.CONTENTS);
        if (contents instanceof COSStream)
        {
            COSStream contentsStream = (COSStream)contents;

            COSArray array = new COSArray();
            array.add(saveGraphicsStateStream);
            array.add(contentsStream);
            array.add(restoreGraphicsStateStream);

            pageDictionary.setItem(COSName.CONTENTS, array);
        }
        else if( contents instanceof COSArray )
        {
            COSArray contentsArray = (COSArray)contents;

            contentsArray.add(0, saveGraphicsStateStream);
            contentsArray.add(restoreGraphicsStateStream);
        }
        else
        {
            throw new IOException("Contents are unknown type: " + contents.getClass().getName());
        }
    }
View Full Code Here

     *
     */
    @Override
    public COSArray getValue()
    {
        COSBase value = getDictionary().getDictionaryObject( COSName.V);
        if (value instanceof COSString)
        {
            COSArray array = new COSArray();
            array.add(value);
            return array;
View Full Code Here

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

     *
     * @param cat The document catalog that this dictionary is part of.
     */
    public PDDocumentNameDictionary( PDDocumentCatalog cat )
    {
        COSBase names = cat.getCOSObject().getDictionaryObject(COSName.NAMES);
        if (names != null)
        {
            nameDictionary = (COSDictionary)names;
        }
        else
View Full Code Here

            fontsDictionary = new COSDictionary();
            resources.setItem(COSName.FONT, fontsDictionary);
        }
        for (COSName fontName : fontsDictionary.keySet())
        {
            COSBase font = fontsDictionary.getDictionaryObject(fontName);
            // data-000174.pdf contains a font that is a COSArray, looks to be an error in the
            // PDF, we will just ignore entries that are not dictionaries.
            if (font instanceof COSDictionary)
            {
                PDFont newFont = null;
View Full Code Here

     * @param resources
     * @throws ValidationException
     */
    protected void validateExtGStates(PreflightContext context, PDResources resources) throws ValidationException
    {
        COSBase egsEntry = resources.getCOSObject().getItem(TRANPARENCY_DICTIONARY_KEY_EXTGSTATE);
        COSDocument cosDocument = context.getDocument().getDocument();
        COSDictionary extGState = COSUtils.getAsDictionary(egsEntry, cosDocument);
        if (egsEntry != null)
        {
            ContextHelper.validateElement(context, extGState, EXTGSTATE_PROCESS);
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.