Package br.net.woodstock.rockframework.io

Examples of br.net.woodstock.rockframework.io.InputOutputStream


      Assert.notNull(source, "source");
      Assert.greaterOrEqual(start, 1, "start");

      PdfReader reader = new PdfReader(source);
      Document document = new Document(reader.getPageSizeWithRotation(1));
      InputOutputStream outputStream = new InputOutputStream();
      PdfCopy writer = new PdfCopy(document, outputStream);
      int pageCount = reader.getNumberOfPages();

      Assert.lessOrEqual(start, pageCount, "start");

      int endPage = end;
      if (endPage > pageCount) {
        endPage = pageCount;
      }

      document.open();

      for (int i = start; i <= endPage; i++) {
        PdfImportedPage page = writer.getImportedPage(reader, i);
        writer.addPage(page);
      }

      document.close();
      writer.close();
      reader.close();

      return outputStream.getInputStream();
    } catch (IOException e) {
      throw new PDFException(e);
    } catch (DocumentException e) {
      throw new PDFException(e);
    }
View Full Code Here


    try {
      Assert.notNull(sources, "sources");
      Assert.notEmpty(sources, "sources");

      Document document = new Document();
      InputOutputStream outputStream = new InputOutputStream();
      PdfCopy writer = new PdfCopy(document, outputStream);

      document.open();

      for (InputStream source : sources) {
        PdfReader reader = new PdfReader(source);
        int pageCount = reader.getNumberOfPages();
        for (int i = 1; i <= pageCount; i++) {
          PdfImportedPage page = writer.getImportedPage(reader, i);
          writer.addPage(page);
        }
        reader.close();
      }

      document.close();
      writer.close();

      return outputStream.getInputStream();
    } catch (IOException e) {
      throw new PDFException(e);
    } catch (DocumentException e) {
      throw new PDFException(e);
    }
View Full Code Here

      PdfReader reader = new PdfReader(source);
      int pageCount = reader.getNumberOfPages();
      List<InputStream> list = new LinkedList<InputStream>();

      Document document = null;
      InputOutputStream outputStream = null;
      PdfCopy writer = null;
      for (int i = 1; i <= pageCount; i++) {
        if ((document == null) || ((i % size) == 0)) {
          if (document != null) {
            document.close();
            writer.close();
            list.add(outputStream.getInputStream());
          }
          document = new Document(reader.getPageSizeWithRotation(1));
          outputStream = new InputOutputStream();
          writer = new PdfCopy(document, outputStream);
        }
        PdfImportedPage page = writer.getImportedPage(reader, i);
        writer.addPage(page);
      }

      if (document != null) {
        document.close();
        writer.close();
        list.add(outputStream.getInputStream());
      }

      reader.close();

      return CollectionUtils.toArray(list, InputStream.class);
View Full Code Here

    try {
      Assert.notNull(source, "source");

      PdfReader reader = new PdfReader(source);
      Document document = new Document(reader.getPageSizeWithRotation(1));
      InputOutputStream outputStream = new InputOutputStream();
      PdfCopy writer = new PdfCopy(document, outputStream);
      int pageCount = reader.getNumberOfPages();

      Assert.lessOrEqual(start, pageCount, "start");

      int endPage = end;
      if (endPage > pageCount) {
        endPage = pageCount;
      }

      document.open();

      for (int i = start; i <= endPage; i++) {
        PdfImportedPage page = writer.getImportedPage(reader, i);
        writer.addPage(page);
      }

      document.close();
      writer.close();
      reader.close();

      return outputStream.getInputStream();
    } catch (DocumentException e) {
      throw new br.net.woodstock.rockframework.office.DocumentException(e);
    }
  }
View Full Code Here

    try {
      Assert.notNull(sources, "sources");
      Assert.notEmpty(sources, "sources");

      Document document = new Document();
      InputOutputStream outputStream = new InputOutputStream();
      PdfCopy writer = new PdfCopy(document, outputStream);

      document.open();

      for (InputStream source : sources) {
        PdfReader reader = new PdfReader(source);
        int pageCount = reader.getNumberOfPages();
        for (int i = 1; i <= pageCount; i++) {
          PdfImportedPage page = writer.getImportedPage(reader, i);
          writer.addPage(page);
        }
        reader.close();
      }

      document.close();
      writer.close();

      return outputStream.getInputStream();
    } catch (DocumentException e) {
      throw new br.net.woodstock.rockframework.office.DocumentException(e);
    }
  }
View Full Code Here

      PdfReader reader = new PdfReader(source);
      int pageCount = reader.getNumberOfPages();
      List<InputStream> list = new LinkedList<InputStream>();

      Document document = null;
      InputOutputStream outputStream = null;
      PdfCopy writer = null;
      for (int i = 1; i <= pageCount; i++) {
        if ((document == null) || (i % size == 0)) {
          if (document != null) {
            document.close();
            writer.close();
            list.add(outputStream.getInputStream());
          }
          document = new Document(reader.getPageSizeWithRotation(1));
          outputStream = new InputOutputStream();
          writer = new PdfCopy(document, outputStream);
        }
        PdfImportedPage page = writer.getImportedPage(reader, i);
        writer.addPage(page);
      }

      if (document != null) {
        document.close();
        writer.close();
        list.add(outputStream.getInputStream());
      }

      reader.close();

      return list.toArray(new InputStream[list.size()]);
View Full Code Here

    try {
      Assert.notNull(source, "source");

      PdfReader reader = new PdfReader(source);
      Document document = new Document(reader.getPageSizeWithRotation(1));
      InputOutputStream outputStream = new InputOutputStream();
      PdfCopy writer = new PdfCopy(document, outputStream);
      int pageCount = reader.getNumberOfPages();

      Assert.lessOrEqual(start, pageCount, "start");

      int endPage = end;
      if (endPage > pageCount) {
        endPage = pageCount;
      }

      document.open();

      for (int i = start; i <= endPage; i++) {
        PdfImportedPage page = writer.getImportedPage(reader, i);
        writer.addPage(page);
      }

      document.close();
      writer.close();
      reader.close();

      return outputStream.getInputStream();
    } catch (DocumentException e) {
      throw new br.net.woodstock.rockframework.office.DocumentException(e);
    }
  }
View Full Code Here

    try {
      Assert.notNull(sources, "sources");
      Assert.notEmpty(sources, "sources");

      Document document = new Document();
      InputOutputStream outputStream = new InputOutputStream();
      PdfCopy writer = new PdfCopy(document, outputStream);

      document.open();

      for (InputStream source : sources) {
        PdfReader reader = new PdfReader(source);
        int pageCount = reader.getNumberOfPages();
        for (int i = 1; i <= pageCount; i++) {
          PdfImportedPage page = writer.getImportedPage(reader, i);
          writer.addPage(page);
        }
        reader.close();
      }

      document.close();
      writer.close();

      return outputStream.getInputStream();
    } catch (DocumentException e) {
      throw new br.net.woodstock.rockframework.office.DocumentException(e);
    }
  }
View Full Code Here

      PdfReader reader = new PdfReader(source);
      int pageCount = reader.getNumberOfPages();
      List<InputStream> list = new LinkedList<InputStream>();

      Document document = null;
      InputOutputStream outputStream = null;
      PdfCopy writer = null;
      for (int i = 1; i <= pageCount; i++) {
        if ((document == null) || (i % size == 0)) {
          if (document != null) {
            document.close();
            writer.close();
            list.add(outputStream.getInputStream());
          }
          document = new Document(reader.getPageSizeWithRotation(1));
          outputStream = new InputOutputStream();
          writer = new PdfCopy(document, outputStream);
        }
        PdfImportedPage page = writer.getImportedPage(reader, i);
        writer.addPage(page);
      }

      if (document != null) {
        document.close();
        writer.close();
        list.add(outputStream.getInputStream());
      }

      reader.close();

      return list.toArray(new InputStream[list.size()]);
View Full Code Here

    return IOUtils.gzip(new ByteArrayInputStream(bytes));
  }

  public static InputStream gzip(final InputStream inputStream) throws IOException {
    Assert.notNull(inputStream, "inputStream");
    InputOutputStream inputOutputStream = new InputOutputStream();
    GZIPOutputStream gzipOutputStream = new GZIPOutputStream(inputOutputStream);
    IOUtils.copy(inputStream, gzipOutputStream);

    gzipOutputStream.close();
    return inputOutputStream.getInputStream();
  }
View Full Code Here

TOP

Related Classes of br.net.woodstock.rockframework.io.InputOutputStream

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.