Examples of COSStreamArray


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

        }
        else if (base instanceof COSArray)
        {
            if (((COSArray)base).size() > 0)
            {
                return new COSStreamArray((COSArray)base);
            }
        }
        return null;
    }
View Full Code Here

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

            // 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<COSName> filters = new ArrayList<COSName>();
                filters.add(COSName.FLATE_DECODE);
                contentsToAppend.setFilters(filters);
            }

            if (resetContext)
            {
                // create a new stream to encapsulate the existing stream
                PDStream saveGraphics = new PDStream(document);
                output = saveGraphics.createOutputStream();
                // save the initial/unmodified graphics context
                saveGraphicsState();
                close();
                if (compress)
                {
                    List<COSName> filters = new ArrayList<COSName>();
                    filters.add(COSName.FLATE_DECODE);
                    saveGraphics.setFilters(filters);
                }
                // insert the new stream at the beginning
                compoundStream.insertCOSStream(saveGraphics);
            }

            // Sets the compoundStream as page contents
            sourcePage.setContents(new PDStream(compoundStream));
            output = contentsToAppend.createOutputStream();
View Full Code Here

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

              retval = newArray;
              clonedVersion.put( base, retval );
          }
          else if (base instanceof COSStreamArray) // PDFBOX-2052
          {
              COSStreamArray originalStream = (COSStreamArray) base;

              if (originalStream.size() > 0)
              {
                  throw new IllegalStateException("Cannot close stream array with items next to the streams.");
              }

              COSArray array = new COSArray();
              for (int i = 0; i < originalStream.getStreamCount(); i++)
              {
                  COSBase base2 = originalStream.get(i);
                  COSBase cloneForNewDocument = cloneForNewDocument(base2);
                  array.add(cloneForNewDocument);
              }
              retval = new COSStreamArray(array);
              clonedVersion.put(base, retval);
          }
          else if( base instanceof COSStream )
          {
              COSStream originalStream = (COSStream)base;
              PDStream stream = new PDStream( destination, originalStream.getFilteredStream(), true );
              clonedVersion.put( base, stream.getStream() );
              for( Map.Entry<COSName, COSBase> entry :  originalStream.entrySet() )
              {
                  stream.getStream().setItem(
                          entry.getKey(),
                          cloneForNewDocument(entry.getValue()));
              }
View Full Code Here

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

            // 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<COSName> filters = new ArrayList<COSName>();
                filters.add(COSName.FLATE_DECODE);
                contentsToAppend.setFilters(filters);
            }

            if (resetContext)
            {
                // create a new stream to encapsulate the existing stream
                PDStream saveGraphics = new PDStream(document);
                output = saveGraphics.createOutputStream();
                // save the initial/unmodified graphics context
                saveGraphicsState();
                close();
                if (compress)
                {
                    List<COSName> filters = new ArrayList<COSName>();
                    filters.add(COSName.FLATE_DECODE);
                    saveGraphics.setFilters(filters);
                }
                // insert the new stream at the beginning
                compoundStream.insertCOSStream(saveGraphics);
            }

            // Sets the compoundStream as page contents
            sourcePage.setContents(new PDStream(compoundStream));
            output = contentsToAppend.createOutputStream();
View Full Code Here

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

           
            // 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<COSName> filters = new ArrayList<COSName>();
                filters.add( COSName.FLATE_DECODE );
                contentsToAppend.setFilters( filters );
            }

            if (resetContext)
            {
                // create a new stream to encapsulate the existing stream
                PDStream saveGraphics = new PDStream( document );
                output = saveGraphics.createOutputStream();
                // save the initial/unmodified graphics context
                saveGraphicsState();
                close();
                if( compress )
                {
                    List<COSName> filters = new ArrayList<COSName>();
                    filters.add( COSName.FLATE_DECODE );
                    saveGraphics.setFilters( filters );
                }
                // insert the new stream at the beginning
                compoundStream.insertCOSStream(saveGraphics);
            }

            // Sets the compoundStream as page contents
            sourcePage.setContents( new PDStream(compoundStream) );
            output = contentsToAppend.createOutputStream();
View Full Code Here

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

            // 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<COSName> filters = new ArrayList<COSName>();
                filters.add(COSName.FLATE_DECODE);
                contentsToAppend.setFilters(filters);
            }

            if (resetContext)
            {
                // create a new stream to encapsulate the existing stream
                PDStream saveGraphics = new PDStream(document);
                output = saveGraphics.createOutputStream();
                // save the initial/unmodified graphics context
                saveGraphicsState();
                close();
                if (compress)
                {
                    List<COSName> filters = new ArrayList<COSName>();
                    filters.add(COSName.FLATE_DECODE);
                    saveGraphics.setFilters(filters);
                }
                // insert the new stream at the beginning
                compoundStream.insertCOSStream(saveGraphics);
            }

            // Sets the compoundStream as page contents
            sourcePage.setContents(new PDStream(compoundStream));
            output = contentsToAppend.createOutputStream();
View Full Code Here

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

              retval = newArray;
              clonedVersion.put( base, retval );
          }
          else if (base instanceof COSStreamArray) // PDFBOX-2052
          {
              COSStreamArray originalStream = (COSStreamArray) base;

              if (originalStream.size() > 0)
              {
                  throw new IllegalStateException("Cannot close stream array with items next to the streams.");
              }

              COSArray array = new COSArray();
              for (int i = 0; i < originalStream.getStreamCount(); i++)
              {
                  COSBase base2 = originalStream.get(i);
                  COSBase cloneForNewDocument = cloneForNewDocument(base2);
                  array.add(cloneForNewDocument);
              }
              retval = new COSStreamArray(array);
              clonedVersion.put(base, retval);
          }
          else if( base instanceof COSStream )
          {
              COSStream originalStream = (COSStream)base;
              PDStream stream = new PDStream( destination, originalStream.getFilteredStream(), true );
              clonedVersion.put( base, stream.getStream() );
              for( Map.Entry<COSName, COSBase> entry :  originalStream.entrySet() )
              {
                  stream.getStream().setItem(
                          entry.getKey(),
                          cloneForNewDocument(entry.getValue()));
              }
View Full Code Here

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

            // 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<COSName> filters = new ArrayList<COSName>();
                filters.add(COSName.FLATE_DECODE);
                contentsToAppend.setFilters(filters);
            }

            if (resetContext)
            {
                // create a new stream to encapsulate the existing stream
                PDStream saveGraphics = new PDStream(document);
                output = saveGraphics.createOutputStream();
                // save the initial/unmodified graphics context
                saveGraphicsState();
                close();
                if (compress)
                {
                    List<COSName> filters = new ArrayList<COSName>();
                    filters.add(COSName.FLATE_DECODE);
                    saveGraphics.setFilters(filters);
                }
                // insert the new stream at the beginning
                compoundStream.insertCOSStream(saveGraphics);
            }

            // Sets the compoundStream as page contents
            sourcePage.setContents(new PDStream(compoundStream));
            output = contentsToAppend.createOutputStream();
View Full Code Here

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

           
            // 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<COSName> filters = new ArrayList<COSName>();
                filters.add( COSName.FLATE_DECODE );
                contentsToAppend.setFilters( filters );
            }

            if (resetContext)
            {
                // create a new stream to encapsulate the existing stream
                PDStream saveGraphics = new PDStream( document );
                output = saveGraphics.createOutputStream();
                // save the initial/unmodified graphics context
                saveGraphicsState();
                close();
                if( compress )
                {
                    List<COSName> filters = new ArrayList<COSName>();
                    filters.add( COSName.FLATE_DECODE );
                    saveGraphics.setFilters( filters );
                }
                // insert the new stream at the beginning
                compoundStream.insertCOSStream(saveGraphics);
            }

            // Sets the compoundStream as page contents
            sourcePage.setContents( new PDStream(compoundStream) );
            output = contentsToAppend.createOutputStream();
View Full Code Here

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

            // 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();
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.