From de4c76d2eca62b38b0d84e3292a3fd343ff378ca Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Fri, 25 Mar 2016 11:13:52 +0000 Subject: Add Javadoc matching README.md --- .../org/zwobble/mammoth/DocumentConverter.java | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (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 e11ec8b..557adc6 100644 --- a/src/main/java/org/zwobble/mammoth/DocumentConverter.java +++ b/src/main/java/org/zwobble/mammoth/DocumentConverter.java @@ -41,23 +41,43 @@ public class DocumentConverter { return new DocumentConverter(options.idPrefix(idPrefix)); } + /** + * By default, empty paragraphs are ignored. + * Call this to preserve empty paragraphs in the output. + */ public DocumentConverter preserveEmptyParagraphs() { return new DocumentConverter(options.preserveEmptyParagraphs()); } + /** + * Add a style map to specify the mapping of Word styles to HTML. + * The most recently added style map has the greatest precedence. + */ public DocumentConverter addStyleMap(String styleMap) { return new DocumentConverter(options.addStyleMap(styleMap)); } + /** + * By default, any added style maps are combined with the default style map. + * Call this to stop using the default style map altogether. + */ public DocumentConverter disableDefaultStyleMap() { return new DocumentConverter(options.disableDefaultStyleMap()); } + /** + * Converts {@code stream} into an HTML string. + * Note that using this method instead of {@link #convertToHtml(File file)} + * means that relative paths to other files, such as images, cannot be resolved. + */ public Result convertToHtml(InputStream stream) throws IOException { return withDocxFile(stream, zipFile -> convertToHtml(Optional.empty(), zipFile)); } + /** + * Converts {@code file} into an HTML string. + */ public Result convertToHtml(File file) throws IOException { return withDocxFile(file, zipFile -> convertToHtml(Optional.of(file.toPath()), zipFile)); @@ -71,6 +91,11 @@ 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(File file) throws IOException { return withDocxFile(file, zipFile -> readDocument(Optional.of(file.toPath()), zipFile) -- cgit v1.2.3