Package org.apache.pdfbox.pdmodel.common

Examples of org.apache.pdfbox.pdmodel.common.PDStream.createInputStream()


        if (fd != null)
        {
            PDStream ff3Stream = fd.getFontFile3();
            if (ff3Stream != null)
            {
                bytes = IOUtils.toByteArray(ff3Stream.createInputStream());
            }
        }

        boolean fontIsDamaged = false;
        CFFType1Font cffEmbedded = null;
View Full Code Here


            PDStream ff2Stream = fd.getFontFile2();
            if (ff2Stream != null)
            {
                System.out.println("Writing font:" + name);
                FileOutputStream fos = new FileOutputStream(new File(name + ".ttf"));
                IOUtils.copy(ff2Stream.createInputStream(), fos);
                fos.close();
            }
        }
    }
View Full Code Here

        {
            try
            {
                // embedded
                OTFParser otfParser = new OTFParser(true);
                OpenTypeFont otf = otfParser.parse(ff3Stream.createInputStream());
                ttfFont = otf;

                if (otf.isPostScript())
                {
                    // todo: we need more abstraction to support CFF fonts here
View Full Code Here

            {
                try
                {
                    // embedded
                    TTFParser ttfParser = new TTFParser(true);
                    ttfFont = ttfParser.parse(ff2Stream.createInputStream());
                }
                catch (NullPointerException e) // TTF parser is buggy
                {
                    LOG.warn("Could not read embedded TTF for font " + getBaseFont(), e);
                    fontIsDamaged = true;
View Full Code Here

        if (fd != null)
        {
            PDStream ff3Stream = fd.getFontFile3();
            if (ff3Stream != null)
            {
                bytes = IOUtils.toByteArray(ff3Stream.createInputStream());
            }
        }

        if (bytes != null)
        {
View Full Code Here

        // as the stream was close within the PDStream constructor, we have to recreate it
        InputStream stream2 = null;
        PDFontDescriptor fd;
        try
        {
            stream2 = stream.createInputStream();
            ttf = new TTFParser().parse(stream2);
            fd = createFontDescriptor(dict, ttf);
        }
        finally
        {
View Full Code Here

            throw new XpacketParsingException("Failed while retrieving xpacket", error);
        }

        PDStream stream = PDStream.createFromCOS(metadataDictionnary);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InputStream is = stream.createInputStream();
        IOUtils.copy(is, bos);
        is.close();
        bos.close();
        return bos.toByteArray();
    }
View Full Code Here

            throw new XpacketParsingException("Failed while retrieving xpacket", error);
        }

        PDStream stream = PDStream.createFromCOS(metadataDictionnary);
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        InputStream is = stream.createInputStream();
        IOUtils.copy(is, bos);
        is.close();
        bos.close();
        return bos.toByteArray();
    }
View Full Code Here

            if( ff2Stream != null )
            {
                try
                {
                    // create a font with the embedded data
                    awtFont = Font.createFont( Font.TRUETYPE_FONT, ff2Stream.createInputStream() );
                }
                catch( FontFormatException f )
                {
                    try
                    {
View Full Code Here

                catch( FontFormatException f )
                {
                    try
                    {
                        // as a workaround we try to rebuild the embedded subsfont
                        byte[] fontData = rebuildTTF(fd, ff2Stream.createInputStream());
                        if (fontData != null)
                        {
                            ByteArrayInputStream bais = new ByteArrayInputStream(fontData);
                            awtFont = Font.createFont( Font.TRUETYPE_FONT,bais);
                        }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.