Aspose.Words FOSS for Java is an MIT-licensed Java library for creating, editing and converting Word documents. Document holds a whole document and DocumentBuilder writes content into it. DOCX, DOCM, DOTX, DOTM, four Flat OPC variants, Markdown and plain text can be loaded and saved, and no copy of Microsoft Word is needed.
The library builds documents from code, including headings, paragraphs and tables. It replaces text with Range.replace, appends one document to another with appendDocument, and accepts tracked changes with acceptAllRevisions. The API reference lists 634 public types.
This is the open-source edition. It uses the package name com.aspose.words of the commercial Aspose.Words for Java but reads and writes a smaller set of formats: saving as PDF, XPS, HTML, MHTML, EPUB, RTF, DOC, ODT, WordML or images is rejected, and so is loading HTML, ODT or RTF. It installs with a single Maven dependency (org.aspose:aspose-words-foss:26.3.0) and needs Java 8 or later.
For the enterprise product family, see Aspose.Words — Enterprise Product Family.
Document creates a blank document, or opens an existing file when you pass a file name.DocumentBuilder keeps a cursor in the document and writeln inserts a line of text.StyleIdentifier.HEADING_1 on the paragraph format before writing a heading.getText returns the text of a document.startTable, insertCell, endRow and endTable on DocumentBuilder build a table cell by cell.Range.replace replaces all occurrences of a string and returns the number of replacements.Document constructor and save it with the file extension of the target format.UnsupportedOperationException whose message starts with FOSS.acceptAllRevisions accepts every tracked change in a document.appendDocument appends one document to another, and ImportFormatMode chooses how formatting is handled.Create a document with a heading and a paragraph, save it as DOCX, then open an existing document and save it as Markdown.
<dependency>
<groupId>org.aspose</groupId>
<artifactId>aspose-words-foss</artifactId>
<version>26.3.0</version>
</dependency>import com.aspose.words.*;
// Create a document from scratch.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
builder.writeln("Hello from Aspose.Words FOSS!");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.BODY_TEXT);
builder.writeln("This document was created entirely in code, no Word installed.");
doc.save("Hello.docx");
// Convert an existing document to Markdown.
Document report = new Document("Report.docx");
report.save("Report.md");
Pass the Markdown file name to the Document constructor and save the document with a .docx file name.
import com.aspose.words.*;
Document doc = new Document("notes.md");
doc.save("notes.docx");
Open a reviewed document, accept all tracked changes and save the final version.
import com.aspose.words.*;
Document doc = new Document("reviewed.docx");
doc.acceptAllRevisions();
doc.save("final.docx");
Append a second document to the first and keep the source formatting.
import com.aspose.words.*;
Document main = new Document("main.docx");
Document appendix = new Document("appendix.docx");
main.appendDocument(appendix, ImportFormatMode.KEEP_SOURCE_FORMATTING);
main.save("combined.docx");
Aspose.Words FOSS for Java is open-source software released under the MIT license.
No. It is a reduced edition that uses the same package name, com.aspose.words, but reads and writes a smaller set of formats. The commercial product is separate and has its own license.
Add org.aspose:aspose-words-foss:26.3.0 to your Maven build. The library needs Java 8 or later and was run on Java 8, 17 and 21. Microsoft Word is not needed.
DOCX, DOCM, DOTX, DOTM, four Flat OPC variants, Markdown and plain text were loaded and saved in both directions.
Saving as PDF, XPS, HTML, MHTML, EPUB, RTF, DOC, ODT, WordML, PNG, SVG or TIFF throws an UnsupportedOperationException whose message starts with FOSS. Loading HTML, ODT or RTF does the same.
No. DigitalSignatureUtil.sign throws an UnsupportedOperationException whose message starts with FOSS.