Package com.itextpdf.text.pdf.parser

Examples of com.itextpdf.text.pdf.parser.TextExtractionStrategy


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

      PdfReader reader = new PdfReader(source);
      PdfReaderContentParser parser = new PdfReaderContentParser(reader);
      TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
      int pageCount = reader.getNumberOfPages();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      PrintWriter writer = new PrintWriter(outputStream);

      for (int i = 1; i <= pageCount; i++) {
        TextExtractionStrategy result = parser.processContent(i, strategy);
        String pageText = result.getResultantText();
        writer.println(pageText);
      }

      reader.close();
      writer.close();
View Full Code Here


  public String getText(final InputStream source) throws IOException {
    Assert.notNull(source, "source");

    PdfReader reader = new PdfReader(source);
    PdfReaderContentParser parser = new PdfReaderContentParser(reader);
    TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
    int pageCount = reader.getNumberOfPages();
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    PrintWriter writer = new PrintWriter(outputStream);

    for (int i = 1; i <= pageCount; i++) {
      TextExtractionStrategy result = parser.processContent(i, strategy);
      String pageText = result.getResultantText();
      writer.println(pageText);
    }

    reader.close();
    writer.close();
View Full Code Here

    }
   
    public String extractPageText(PdfReader documentReader, int pageNum){
        String content ="";
        PdfReaderContentParser parser = new PdfReaderContentParser(documentReader);
        TextExtractionStrategy strat;
        try {
            strat = parser.processContent(pageNum, new SimpleTextExtractionStrategy());
            content = strat.getResultantText();
           
        } catch (IOException e) {
            LOGGER.log(Level.WARNING, "Failed to parse pdf text in "
                    + Thread.currentThread().getName(), e);
        }
View Full Code Here

        throw new DocumentException("Parameter 'source' + must be set");
      }

      PdfReader reader = IText.read(source);
      PdfReaderContentParser parser = new PdfReaderContentParser(reader);
      TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
      int pageCount = reader.getNumberOfPages();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      PrintWriter writer = new PrintWriter(outputStream);

      for (int i = 1; i <= pageCount; i++) {
        TextExtractionStrategy result = parser.processContent(i, strategy);
        String pageText = result.getResultantText();
        writer.println(pageText);
      }

      reader.close();
      writer.close();
View Full Code Here

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

      PdfReader reader = new PdfReader(source);
      PdfReaderContentParser parser = new PdfReaderContentParser(reader);
      TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
      int pageCount = reader.getNumberOfPages();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      PrintWriter writer = new PrintWriter(outputStream);

      for (int i = 1; i <= pageCount; i++) {
        TextExtractionStrategy result = parser.processContent(i, strategy);
        String pageText = result.getResultantText();
        writer.println(pageText);
      }

      reader.close();
      writer.close();
View Full Code Here

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

      PdfReader reader = new PdfReader(source);
      PdfReaderContentParser parser = new PdfReaderContentParser(reader);
      TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
      int pageCount = reader.getNumberOfPages();
      ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
      PrintWriter writer = new PrintWriter(outputStream);

      for (int i = 1; i <= pageCount; i++) {
        TextExtractionStrategy result = parser.processContent(i, strategy);
        String pageText = result.getResultantText();
        writer.println(pageText);
      }

      reader.close();
      writer.close();
View Full Code Here

TOP

Related Classes of com.itextpdf.text.pdf.parser.TextExtractionStrategy

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.