Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSName


        encoding = fontEncoding;

        Encoding base = null;
        if (encoding.containsKey(COSName.BASE_ENCODING))
        {
            COSName name = encoding.getCOSName(COSName.BASE_ENCODING);
            base = Encoding.getInstance(name); // may be null
        }

        if (base == null)
        {
            if (isNonSymbolic)
            {
                // Otherwise, for a nonsymbolic font, it is StandardEncoding
                base = StandardEncoding.INSTANCE;
            }
            else
            {
                // and for a symbolic font, it is the font's built-in encoding.
                if (builtIn != null)
                {
                    base = builtIn;
                }
                else
                {
                    base = StandardEncoding.INSTANCE;
                    LOG.warn("Built-in encoding required for symbolic font, using standard encoding");
                    //FIXME, see PDFBOX-2299, happens with Type3 fonts of the isartor test suite
                    // throw new IllegalArgumentException("Built-in Encoding required for symbolic font");
                }
            }
        }
        baseEncoding = base;

        codeToName.putAll( baseEncoding.codeToName );
        names.addAll( baseEncoding.names );

        // now replace with the differences
        COSArray differences = (COSArray)encoding.getDictionaryObject( COSName.DIFFERENCES );
        int currentIndex = -1;
        for( int i=0; differences != null && i<differences.size(); i++ )
        {
            COSBase next = differences.getObject( i );
            if( next instanceof COSNumber )
            {
                currentIndex = ((COSNumber)next).intValue();
            }
            else if( next instanceof COSName )
            {
                COSName name = (COSName)next;
                add(currentIndex, name.getName());
                this.differences.put(currentIndex, name.getName());
                currentIndex++;
            }
        }
    }
View Full Code Here


                        if( cert != null )
                        {
                            System.out.println( "Certificate found" );
                            System.out.println( "Name=" + cert.getDictionaryObject( COSName.NAME ) );
                            System.out.println( "Modified=" + cert.getDictionaryObject( COSName.getPDFName( "M" ) ) );
                            COSName subFilter = (COSName)cert.getDictionaryObject( COSName.getPDFName( "SubFilter" ) );
                            if( subFilter != null )
                            {
                                if( subFilter.getName().equals( "adbe.x509.rsa_sha1" ) )
                                {
                                    COSString certString = (COSString)cert.getDictionaryObject(
                                        COSName.getPDFName( "Cert" ) );
                                    byte[] certData = certString.getBytes();
                                    CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
                                    ByteArrayInputStream certStream = new ByteArrayInputStream( certData );
                                    Collection certs = factory.generateCertificates( certStream );
                                    System.out.println( "certs=" + certs );
                                }
                                else if( subFilter.getName().equals( "adbe.pkcs7.sha1" ) )
                                {
                                    COSString certString = (COSString)cert.getDictionaryObject(
                                        COSName.CONTENTS );
                                    byte[] certData = certString.getBytes();
                                    CertificateFactory factory = CertificateFactory.getInstance( "X.509" );
View Full Code Here

      
        // now inject procSetArray
        pdfBuilder.injectProcSetArray(innerForm, page, innerFormResource, imageFormResources,
                holderFormResources, pdfStructure.getProcSet());

        COSName imgFormName = pdfStructure.getImageFormName();
        COSName imgName = pdfStructure.getImageName();
        COSName innerFormName = pdfStructure.getInnerFormName();

        // now create Streams of AP
        pdfBuilder.injectAppearanceStreams(holderFormStream, imageFormStream, imageFormStream,
                imgFormName, imgName, innerFormName, properties);
        pdfBuilder.createVisualSignature(template);
View Full Code Here

            // use put() if you want a specific name
            resources.put(COSName.getPDFName("shax"), axialShading);
           
            // use add() if you want PDFBox to decide the name for you
            COSName radialShadingName = resources.add(radialShading);

            // invoke shading from content stream
            // the raw command is "/name sh"
            // replace "name" with the name of the shading
            // compress parameter is set to false so that you can see the stream in a text editor
            PDPageContentStream contentStream = new PDPageContentStream(document, page, true, false);
            contentStream.appendRawCommands("/shax sh\n");
            contentStream.appendRawCommands("/" + radialShadingName.getName() + " sh\n");
            contentStream.close();
           
            document.save(file);
            document.close();
           
View Full Code Here

        }
        else
        {
            xObjectPrefix = "Form";
        }
        COSName objMapping = resources.add(xobject, xObjectPrefix);
        saveGraphicsState();
        appendRawCommands(SPACE);
        concatenate2CTM(transform);
        appendRawCommands(SPACE);
        appendCOSName(objMapping);
View Full Code Here

        appendRawCommands(SET_NON_STROKING_COLORSPACE);
    }

    private void writeColorSpace(PDColorSpace colorSpace) throws IOException
    {
        COSName key = null;
        if (colorSpace instanceof PDDeviceGray || colorSpace instanceof PDDeviceRGB
                || colorSpace instanceof PDDeviceCMYK)
        {
            key = COSName.getPDFName(colorSpace.getName());
        }
        else
        {
            COSDictionary colorSpaces = (COSDictionary) resources.getCOSObject().getDictionaryObject(
                    COSName.COLORSPACE);
            if (colorSpaces == null)
            {
                colorSpaces = new COSDictionary();
                resources.getCOSObject().setItem(COSName.COLORSPACE, colorSpaces);
            }
            key = colorSpaces.getKeyForValue(colorSpace.getCOSObject());

            if (key == null)
            {
                int counter = 0;
                String csName = "CS";
                while (colorSpaces.containsValue(csName + counter))
                {
                    counter++;
                }
                key = COSName.getPDFName(csName + counter);
                colorSpaces.setItem(key, colorSpace);
            }
        }
        key.writePDF(output);
        appendRawCommands(SPACE);
    }
View Full Code Here

        if (extGStates != null)
        {
            for (Object object : extGStates.keySet())
            {
                COSName key = (COSName) object;
                if (key.getName().matches(TRANPARENCY_DICTIONARY_KEY_EXTGSTATE_ENTRY_REGEX))
                {
                    COSBase gsBase = extGStates.getItem(key);
                    COSDictionary gsDict = COSUtils.getAsDictionary(gsBase, cosDocument);
                    if (gsDict == null)
                    {
View Full Code Here

    /**
     * Call {@link BaseParser#parseCOSName()} and check the length of the name
     */
    protected COSName parseCOSName() throws IOException
    {
        COSName result = super.parseCOSName();
        if (result != null && result.getName().getBytes().length > MAX_NAME_SIZE)
        {
            addValidationError(new ValidationError(ERROR_SYNTAX_NAME_TOO_LONG, "Name too long"));
        }
        return result;
    }
View Full Code Here

          {
              COSDictionary dic = (COSDictionary)base;
              clonedVersion.put( base, retval );
              for( Map.Entry<COSName, COSBase> entry : dic.entrySet() )
              {
                  COSName key = entry.getKey();
                  COSBase value = entry.getValue();
                  if (((COSDictionary)target).getItem(key) != null)
                  {
                      cloneMerge(value, ((COSDictionary)target).getItem(key));
                  }
View Full Code Here

        if (encoding != null)
        {
            if (encoding instanceof COSName)
            {
                // predefined CMap
                COSName encodingName = (COSName)encoding;
                cMap = CMapManager.getPredefinedCMap(encodingName.getName());
                if (cMap != null)
                {
                    isCMapPredefined = true;
                    return;
                }
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.