Package org.apache.pdfbox.cos

Examples of org.apache.pdfbox.cos.COSStream


     * @return The metadata for this object.
     */
    public PDMetadata getMetadata()
    {
        PDMetadata retval = null;
        COSStream stream = (COSStream) page.getDictionaryObject(COSName.METADATA);
        if (stream != null)
        {
            retval = new PDMetadata(stream);
        }
        return retval;
View Full Code Here


                // TODO support more than one appearance stream
                PDAppearanceStream appearanceStream =
                        normalAppearance.isStream() ? normalAppearance.getAppearanceStream() : null;
                if (appearanceStream == null)
                {
                    COSStream cosStream = acroForm.getDocument().getDocument().createCOSStream();
                    appearanceStream = new PDAppearanceStream(cosStream);
                    appearanceStream.setBBox(widget.getRectangle()
                            .createRetranslatedRectangle());
                    appearance.setNormalAppearance(appearanceStream);
                }
View Full Code Here

    {
        PDStream ff3 = fontDescriptor.getFontFile3();
        if (ff3 != null)
        {
            // Stream validation should be done by the StreamValidateHelper. Process font specific check
            COSStream stream = ff3.getStream();
            if (stream == null)
            {
                this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is missing for "
                        + fontDescriptor.getFontName()));
                this.fContainer.notEmbedded();
            }
            else
            {
                // Length1/2/3 aren't mandatory for this type of font
                // But the Subtype is a mandatory field with specific values
                String st = stream.getNameAsString(COSName.SUBTYPE);
                if (!(FONT_DICTIONARY_VALUE_TYPE0C.equals(st) || FONT_DICTIONARY_VALUE_TYPE1C.equals(st)))
                {
                    this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID,
                            "The FontFile3 stream doesn't have the right Subtype for " + fontDescriptor.getFontName()));
                }
View Full Code Here

        PDStream ff1 = fontDescriptor.getFontFile();
        PDStream ff3 = fontDescriptor.getFontFile3();

        if (ff1 != null)
        {
            COSStream stream = ff1.getStream();
            if (stream == null)
            {
                this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is missing for "
                        + fontDescriptor.getFontName()));
                this.fContainer.notEmbedded();
                return null;
            }

            boolean hasLength1 = stream.getInt(COSName.LENGTH1) > 0;
            boolean hasLength2 = stream.getInt(COSName.getPDFName(FONT_DICTIONARY_KEY_LENGTH2)) > 0;
            boolean hasLength3 = stream.getInt(COSName.getPDFName(FONT_DICTIONARY_KEY_LENGTH3)) >= 0;
            if (!(hasLength1 && hasLength2 && hasLength3))
            {
                this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is invalid for "
                        + fontDescriptor.getFontName()));
                return null;
View Full Code Here

    {
        PDStream ff2 = fontDescriptor.getFontFile2();
        if (ff2 != null)
        {
            // Stream validation should be done by the StreamValidateHelper. Process font specific check
            COSStream stream = ff2.getStream();
            if (stream == null)
            {
                this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile is missing for "
                        + fontDescriptor.getFontName()));
                this.fContainer.notEmbedded();
View Full Code Here

    @Override
    public PDStream extractFontFile(PDFontDescriptor fontDescriptor)
    {
        PDStream fontFile = fontDescriptor.getFontFile2();
        COSStream stream = (fontFile == null ? null : fontFile.getStream());
        if (stream == null)
        {
            this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID, "The FontFile2 is missing for "
                    + fontDescriptor.getFontName()));
            this.fContainer.notEmbedded();
            return null;
        }

        if (stream.getInt(COSName.LENGTH1) <= 0)
        {
            this.fContainer.push(new ValidationError(ERROR_FONTS_FONT_FILEX_INVALID,
                    "The FontFile entry /Length1 is invalid for " + fontDescriptor.getFontName()));
            return null;
        }
View Full Code Here

        }
        else if( selectedNode instanceof COSStream )
        {
            try
            {
                COSStream stream = (COSStream)selectedNode;
                InputStream ioStream = stream.getUnfilteredStream();
                ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
                byte[] buffer = new byte[1024];
                int amountRead = 0;
                while( (amountRead = ioStream.read( buffer, 0, buffer.length ) ) != -1 )
                {
View Full Code Here

        PDDocument doc = null;
        try {
            doc = PDDocument.load(inputFilename);
            for(COSObject objStream : doc.getDocument().getObjectsByType(COSName.OBJ_STM)) {
                COSStream stream = (COSStream)objStream.getObject();
                PDFObjectStreamParser sp = new PDFObjectStreamParser(stream, doc.getDocument());
                sp.parse();
                for(COSObject next : sp.getObjects()) {
                    COSObjectKey key = new COSObjectKey(next);
                    COSObject obj = doc.getDocument().getObjectFromPool(key);
View Full Code Here

            {
                COSBase base = ((COSObject) i.next()).getObject();
                if (base instanceof COSStream)
                {
                    // just kill the filters
                    COSStream cosStream = (COSStream)base;
                    cosStream.getUnfilteredStream();
                    cosStream.setFilters(null);
                }
            }
            doc.getDocumentCatalog();
            doc.save( out );
        }
View Full Code Here

        }
        else if (COSUtils.isStream(ctog, cosDocument))
        {
            try
            {
                COSStream stream = COSUtils.getAsStream(ctog, cosDocument);

                // todo: check the map's content? (won't pdfbox do this?)
                InputStream is = stream.getUnfilteredStream();
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                byte[] map = os.toByteArray();
            }
            catch (IOException e)
            {
View Full Code Here

TOP

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

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.