@@ -0,0 +1,2421 @@
+package pl.edu.icm.cermine;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.InputStream;%0Aimport java.io.InputStreamReader;%0A%0Aimport pl.edu.icm.cermine.exception.AnalysisException;%0Aimport pl.edu.icm.cermine.structure.CharacterExtractor;%0Aimport pl.edu.icm.cermine.structure.DocstrumSegmenter;%0Aimport pl.edu.icm.cermine.structure.DocumentSegmenter;%0Aimport pl.edu.icm.cermine.structure.HierarchicalReadingOrderResolver;%0Aimport pl.edu.icm.cermine.structure.ITextCharacterExtractor;%0Aimport pl.edu.icm.cermine.structure.ReadingOrderResolver;%0Aimport pl.edu.icm.cermine.structure.ZoneClassifier;%0Aimport pl.edu.icm.cermine.structure.model.BxDocument;%0Aimport pl.edu.icm.cermine.structure.tools.BxModelUtils;%0A%0Apublic class PdfTextExtractor %7B%0A    /** individual character extractor */%0A    private CharacterExtractor characterExtractor;%0A    %0A    /** document object segmenter */%0A    private DocumentSegmenter documentSegmenter;%0A    %0A    /** reading order resolver */%0A    private ReadingOrderResolver roResolver;%0A    %0A    public PdfTextExtractor() throws AnalysisException %7B%0A        characterExtractor = new ITextCharacterExtractor();%0A        documentSegmenter = new DocstrumSegmenter();%0A        roResolver = new HierarchicalReadingOrderResolver();%0A    %7D%0A    %0A    public PdfTextExtractor(CharacterExtractor glyphExtractor, DocumentSegmenter pageSegmenter, %0A            ReadingOrderResolver roResolver, ZoneClassifier initialClassifier) %7B%0A        this.characterExtractor = glyphExtractor;%0A        this.documentSegmenter = pageSegmenter;%0A        this.roResolver = roResolver;%0A    %7D%0A    %0A    /*%0A     * Extracts content of a pdf to a plain text.%0A     * %0A     * @param stream%0A     * @return pdf's content as plain text%0A     * @throws AnalysisException %0A     */%0A    public String extractText(InputStream stream) throws AnalysisException %7B%0A        BxDocument doc = characterExtractor.extractCharacters(stream);%0A        doc = documentSegmenter.segmentDocument(doc);%0A        BxModelUtils.setParents(doc);%0A        doc = roResolver.resolve(doc);%0A        return doc.toText();%0A    %7D%0A%0A    public void setGlyphExtractor(CharacterExtractor glyphExtractor) %7B%0A        this.characterExtractor = glyphExtractor;%0A    %7D%0A%0A    public void setPageSegmenter(DocumentSegmenter pageSegmenter) %7B%0A        this.documentSegmenter = pageSegmenter;%0A    %7D%0A%0A    public void setRoResolver(ReadingOrderResolver roResolver) %7B%0A        this.roResolver = roResolver;%0A    %7D%0A    %0A%7D%0A

add plain text extractor