Package org.apache.pdfbox.pdmodel.common

Examples of org.apache.pdfbox.pdmodel.common.PDStream


        TrueTypeFont ttfFont = null;
        boolean fontIsDamaged = false;
        if (getFontDescriptor() != null)
        {
            PDFontDescriptor fd = super.getFontDescriptor();
            PDStream ff2Stream = fd.getFontFile2();
            if (ff2Stream != null)
            {
                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


        PDFontDescriptor fd = getFontDescriptor();
        byte[] bytes = null;
        if (fd != null)
        {
            PDStream ff3Stream = fd.getFontFile3();
            if (ff3Stream != null)
            {
                bytes = IOUtils.toByteArray(ff3Stream.createInputStream());
            }
        }

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

                    return false;
                }

                // Appearance stream is a XObjectForm, check it.
                ContextHelper.validateElement(ctx, new PDFormXObject(
                        new PDStream(COSUtils.getAsStream(apn, cosDocument)), "N"),
                        GRAPHIC_PROCESS);
            }
        } // else ok, nothing to check,this field is optional
        return true;
    }
View Full Code Here

        PDPage importedPage = new PDPage(new COSDictionary(page.getCOSObject()));
        InputStream is = null;
        OutputStream os = null;
        try
        {
            PDStream src = page.getStream();
            if (src != null)
            {
                PDStream dest = new PDStream(document.createCOSStream());
                importedPage.setContents(dest);
                os = dest.createOutputStream();

                byte[] buf = new byte[10240];
                int amountRead;
                is = src.createInputStream();
                while ((amountRead = is.read(buf, 0, 10240)) > -1)
View Full Code Here

     */
    public PDICCBased(PDDocument doc)
    {
        array = new COSArray();
        array.add(COSName.ICCBASED);
        array.add(new PDStream(doc));
    }
View Full Code Here

     * @param iccArray the ICC stream object
     */
    public PDICCBased(COSArray iccArray) throws IOException
    {
        array = iccArray;
        stream = new PDStream((COSStream)iccArray.getObject(1));
        loadICCProfile();
    }
View Full Code Here

            {
                lookupData = ((COSString) lookupTable).getBytes();
            }
            else if (lookupTable instanceof COSStream)
            {
                lookupData = new PDStream((COSStream)lookupTable).getByteArray();
            }
            else if (lookupTable == null)
            {
                lookupData = new byte[0];
            }
View Full Code Here

     */
    public void validPageContentStream() throws ValidationException
    {
        try
        {
            PDStream pstream = this.processeedPage.getStream();
            if (pstream != null)
            {
                processPage(this.processeedPage);
            }
        }
View Full Code Here

    PDTrueTypeFontEmbedder(PDDocument document, COSDictionary dict, InputStream ttfStream)
            throws IOException
    {
        dict.setItem(COSName.SUBTYPE, COSName.TRUE_TYPE);

        PDStream stream = new PDStream(document, ttfStream, false);
        stream.getStream().setInt(COSName.LENGTH1, stream.getByteArray().length); // todo: wrong?
        stream.addCompression();

        // only support winansi encoding right now, should really
        // just use Identity-H with unicode mapping
        Encoding encoding = new WinAnsiEncoding(); // fixme: read encoding from TTF

        this.fontEncoding = encoding;
        dict.setItem(COSName.ENCODING, encoding.getCOSObject());

        // 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

            ValidationError error = new ValidationError(PreflightConstants.ERROR_SYNTAX_STREAM_INVALID_FILTER,
                    "Filter specified in metadata dictionnary");
            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

TOP

Related Classes of org.apache.pdfbox.pdmodel.common.PDStream

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.