Examples of PDStream


Examples of org.pdfbox.pdmodel.common.PDStream

        images = resources.getImages();
        // If request specifies the need to append to the document
        if(appendContent)
        {
            // Get the pdstream from the source page instead of creating a new one
            PDStream contents = sourcePage.getContents();
           
            // Create a pdstream to append new content
            PDStream contentsToAppend = new PDStream( document );
           
            // This will be the resulting COSStreamArray after existing and new streams are merged
            COSStreamArray compoundStream = null;
           
            // If contents is already an array, a new stream is simply appended to it
            if(contents.getStream() instanceof COSStreamArray)
            {
                compoundStream = (COSStreamArray)contents.getStream();
                compoundStream.appendStream( contentsToAppend.getStream());
            }
            else
            {
                // Creates the COSStreamArray and adds the current stream plus a new one to it
                COSArray newArray = new COSArray();
                newArray.add(contents.getCOSObject());
                newArray.add(contentsToAppend.getCOSObject());
                compoundStream = new COSStreamArray(newArray);               
            }
           
            if( compress )
            {
                List filters = new ArrayList();
                filters.add( COSName.FLATE_DECODE );
                contentsToAppend.setFilters( filters );
            }
           
            // Sets the compoundStream as page contents
            sourcePage.setContents( new PDStream(compoundStream) );
            output = contentsToAppend.createOutputStream();
        }
        else
        {       
            PDStream contents = new PDStream( document );
            if( compress )
            {
                List filters = new ArrayList();
                filters.add( COSName.FLATE_DECODE );
                contents.setFilters( filters );
            }
            sourcePage.setContents( contents );
            output = contents.createOutputStream();           
        }
        formatDecimal.setMaximumFractionDigits( 10 );
        formatDecimal.setGroupingUsed( false );
    }
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

        COSName metadata = COSName.getPDFName( "Metadata" );
        COSStream destMetadata = (COSStream)destCatalog.getCOSDictionary().getDictionaryObject( metadata );
        COSStream srcMetadata = (COSStream)srcCatalog.getCOSDictionary().getDictionaryObject( metadata );
        if( destMetadata == null && srcMetadata != null )
        {
            PDStream newStream = new PDStream( destination, srcMetadata.getUnfilteredStream(), false );
            newStream.getStream().mergeInto( srcMetadata );
            newStream.addCompression();
            destCatalog.getCOSDictionary().setItem( metadata, newStream );
        }

        //finally append the pages
        List pages = source.getDocumentCatalog().getAllPages();
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

        }
        else if( base instanceof COSStream )
        {
            COSStream originalStream = (COSStream)base;
            List keys = originalStream.keyList();
            PDStream stream = new PDStream( destination, originalStream.getFilteredStream(), true );
            clonedVersion.put( base, stream.getStream() );
            for( int i=0; i<keys.size(); i++ )
            {
                COSName key = (COSName)keys.get( i );
                stream.getStream().setItem( key, cloneForNewDocument(destination,originalStream.getItem(key)));
            }
            retval = stream.getStream();
        }
        else if( base instanceof COSDictionary )
        {
            COSDictionary dic = (COSDictionary)base;
            List keys = dic.keyList();
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

     * @param is The stream that contains the jpeg data.
     * @throws IOException If there is an error reading the jpeg data.
     */
    public PDJpeg( PDDocument doc, InputStream is ) throws IOException
    {
        super( new PDStream( doc, is, true ), "jpg" );
        COSDictionary dic = getCOSStream();
        dic.setItem( COSName.FILTER, COSName.DCT_DECODE );
        dic.setItem( COSName.SUBTYPE, COSName.IMAGE);
        dic.setItem( COSName.TYPE, COSName.getPDFName( "XObject" ) );
       
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

     * @param bi The image to convert to a jpeg
     * @throws IOException If there is an error processing the jpeg data.
     */
    public PDJpeg( PDDocument doc, BufferedImage bi ) throws IOException
    {
        super( new PDStream( doc ), "jpg" );
       
        java.io.OutputStream os = getCOSStream().createFilteredStream();
        try
        {
           
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

     * @throws IOException If there is an error reading the tiff data.
     */
   
    public PDCcitt( PDDocument doc, RandomAccess raf ) throws IOException
    {
        super( new PDStream(doc),"tiff");
        // super( new PDStream( doc, null, true ), "tiff" );
       
        COSDictionary decodeParms = new COSDictionary();
       
        COSDictionary dic = getCOSStream();
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

     *
     * @param xobj The XObject dictionary.
     */
    public PDXObject(COSStream xobj)
    {
        xobject = new PDStream( xobj );
    }
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

     *
     * @param doc The doc to store the object contents.
     */
    public PDXObject(PDDocument doc)
    {
        xobject = new PDStream(doc);
        xobject.getStream().setName( COSName.TYPE, "XObject" );
    }
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

        {
            COSStream xstream = (COSStream)xobject;
            String subtype = xstream.getNameAsString( "Subtype" );
            if( subtype.equals( PDXObjectImage.SUB_TYPE ) )
            {
                PDStream image = new PDStream( xstream );
                // See if filters are DCT or JPX otherwise treat as Bitmap-like
                // There might be a problem with several filters, but that's ToDo until
                // I find an example
                List filters = image.getFilters();
                if( filters != null && filters.contains( COSName.DCT_DECODE.getName() ) )
                {
                    return new PDJpeg(image);
                }
                else if ( filters != null && filters.contains( COSName.CCITTFAX_DECODE.getName() ) )
View Full Code Here

Examples of org.pdfbox.pdmodel.common.PDStream

            int functionType =  funcDic.getInt( "FunctionType" );
            if( function instanceof COSStream )
            {
                if( functionType == 0 )
                {
                    retval = new PDFunctionType0(new PDStream((COSStream)function));
                }
                else if( functionType == 4 )
                {
                    retval = new PDFunctionType4(new PDStream((COSStream)function));
                }
                else
                {
                    throw new IOException( "Error: Unknown stream function type " + functionType );
                }
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.