All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.genexus.search.PdfHandler Maven / Gradle / Ivy

Go to download

Core classes for the runtime used by Java and Android apps generated with GeneXus

The newest version!
package com.genexus.search;

import java.io.IOException;

import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.parser.PdfTextExtractor;


public class PdfHandler implements IDocumentHandler {
    public String getText(String filename) {
        StringBuffer buffer = new StringBuffer();
        try {
            PdfReader reader = new PdfReader(filename);
            PdfTextExtractor parser = new PdfTextExtractor(reader);
            int totalPages = reader.getNumberOfPages();

            for (int i = 1; i <= totalPages; i++) {
                buffer.append(parser.getTextFromPage(i));
            }
        } catch (IOException e) {
            // TODO Auto-generated catch block
            System.out.println(e.getMessage());
        }
        return buffer.toString();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy