Package br.net.woodstock.rockframework.document

Examples of br.net.woodstock.rockframework.document.DocumentException


    } else if (value instanceof InputStream) {
      bytes = IO.toByteArray((InputStream) value);
    }

    if (bytes == null) {
      throw new DocumentException("Invalid PDF source type");
    }

    PdfReader reader = new PdfReader(bytes);
    return reader;
  }
View Full Code Here


    Assert.notNull(input, "input");
    try {
      Object source = input.getParameter(GetTextProcessor.SOURCE_PARAMETER);

      if (source == null) {
        throw new DocumentException("Parameter 'source' + must be set");
      }

      PdfReader reader = IText.read(source);
      PdfReaderContentParser parser = new PdfReaderContentParser(reader);
      TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
View Full Code Here

    try {
      Object source = input.getParameter(ToImageProcessor.SOURCE_PARAMETER);
      Object type = input.getParameter(ToImageProcessor.TYPE_PARAMETER);

      if (source == null) {
        throw new DocumentException("Parameter 'source' + must be set");
      }

      if (type == null) {
        throw new DocumentException("Parameter 'type' must be set");
      }

      String strType = null;

      if (type instanceof ImageType) {
View Full Code Here

    } else if (value instanceof InputStream) {
      inputStream = (InputStream) value;
    }

    if (inputStream == null) {
      throw new DocumentException("Invalid PDF source type");
    }

    PDFParser reader = new PDFParser(inputStream);
    return reader;
  }
View Full Code Here

    } else if (value instanceof InputStream) {
      inputStream = (InputStream) value;
    }

    if (inputStream == null) {
      throw new DocumentException("Invalid PDF source type");
    }

    PDDocument document = PDDocument.load(inputStream);
    return document;
  }
View Full Code Here

      Object source = input.getParameter(CutProcessor.SOURCE_PARAMETER);
      Integer start = input.getParameter(CutProcessor.START_PARAMETER);
      Integer end = input.getParameter(CutProcessor.END_PARAMETER);

      if (source == null) {
        throw new DocumentException("Parameter 'source' + must be set");
      }

      if (start == null) {
        throw new DocumentException("Parameter 'start' must be set");
      }

      if (end == null) {
        end = Integer.valueOf(0);
      }

      PDFParser parser = PDFBox.read(source);
      parser.parse();

      PDDocument document = parser.getPDDocument();

      Splitter splitter = new Splitter();
      splitter.setSplitAtPage(1);

      List<PDDocument> list = splitter.split(document);
      int pageCount = list.size();

      int startPage = start.intValue();
      if (startPage < 1) {
        startPage = 1;
      }
      startPage = startPage - 1;

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

      PDDocument destination = list.get(startPage);

      PDFMergerUtility merger = new PDFMergerUtility();
      for (int i = startPage + 1; i < endPage; i++) {
        PDDocument tmpDocument = list.get(i);
        merger.appendDocument(destination, tmpDocument);
      }

      ByteArrayOutputStream bos = new ByteArrayOutputStream();

      COSWriter writer = new COSWriter(bos);
      writer.write(destination);

      for (PDDocument doc : list) {
        doc.close();
      }

      document.close();
      destination.close();

      ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());

      return new DocumentOutput(bis);
    } catch (IOException e) {
      throw new PDFException(e);
    } catch (COSVisitorException e) {
      throw new DocumentException(e);
    }
  }
View Full Code Here

    Assert.notNull(input, "input");
    try {
      Object source = input.getParameter(GetTextProcessor.SOURCE_PARAMETER);

      if (source == null) {
        throw new DocumentException("Parameter 'source' + must be set");
      }

      PDFParser parser = PDFBox.read(source);
      parser.parse();
View Full Code Here

      Object sources = input.getParameter(MergeProcessor.SOURCES_PARAMETER);

      Collection<Object> collection = null;

      if (sources == null) {
        throw new DocumentException("Parameter 'sources' + must be set");
      }

      if (Arrays.isArray(sources)) {
        collection = Arrays.toList(sources);
      } else if (sources instanceof Collection) {
View Full Code Here

    try {
      Object source = input.getParameter(SplitProcessor.SOURCE_PARAMETER);
      Integer size = input.getParameter(SplitProcessor.SIZE_PARAMETER);

      if (source == null) {
        throw new DocumentException("Parameter 'source' + must be set");
      }

      if (size == null) {
        throw new DocumentException("Parameter 'size' must be set");
      }

      PDFParser parser = PDFBox.read(source);
      parser.parse();
View Full Code Here

TOP

Related Classes of br.net.woodstock.rockframework.document.DocumentException

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.