From b9ccb58ba0e6c0557d18f45a52a6a216177dbd56 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 25 Mar 2016 11:18:02 +0000 Subject: Add extractRawText for streams, as documented --- .../java/org/zwobble/mammoth/DocumentConverter.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/org/zwobble/mammoth/DocumentConverter.java b/src/main/java/org/zwobble/mammoth/DocumentConverter.java index 557adc6..94fb09c 100644 --- a/src/main/java/org/zwobble/mammoth/DocumentConverter.java +++ b/src/main/java/org/zwobble/mammoth/DocumentConverter.java @@ -91,6 +91,16 @@ public class DocumentConverter { .map(Html::write); } + /** + * Extract the raw text of the document. + * This will ignore all formatting in the document. + * Each paragraph is followed by two newlines. + */ + public Result extractRawText(InputStream stream) throws IOException { + return withDocxFile(stream, zipFile -> + extractRawText(Optional.empty(), zipFile)); + } + /** * Extract the raw text of the document. * This will ignore all formatting in the document. @@ -98,8 +108,12 @@ public class DocumentConverter { */ public Result extractRawText(File file) throws IOException { return withDocxFile(file, zipFile -> - readDocument(Optional.of(file.toPath()), zipFile) - .map(DocumentConverter::extractRawTextOfChildren)); + extractRawText(Optional.of(file.toPath()), zipFile)); + } + + private InternalResult extractRawText(Optional path, DocxFile zipFile) { + return readDocument(path, zipFile) + .map(DocumentConverter::extractRawTextOfChildren); } private static T withDocxFile(File file, Function function) throws IOException { -- cgit v1.2.3