Skip to content

Latest commit

 

History

History
69 lines (57 loc) · 3 KB

File metadata and controls

69 lines (57 loc) · 3 KB

GroupDocs Editor – Edit DOCX In‑Memory Showcase

Overview

This showcase project demonstrates how to edit a DOCX document completely in memory using GroupDocs.Editor for Java 26.1. The example loads a DOCX file, replaces a piece of text (HelloHi) and saves the edited document without ever persisting intermediate data to disk.

Project Structure

project-root/
├─ pom.xml
├─ src/
│  └─ main/java/com/groupdocs/editor/examples/EditDocxInMemoryExample.java
├─ resources/
│  ├─ input/
│  │   └─ sample.docx   (replace with your own DOCX) 
│  └─ output/           (generated files will appear here)
└─ GroupDocs.Editor.lic (optional – place your license file here)

Prerequisites

  • Java 8 (or higher)
  • Maven 3.6+
  • Internet access for Maven to download the GroupDocs repository

License

GroupDocs library requires a license. You can obtain a free 30‑day temporary license:

Without a license the library runs in evaluation mode, adding watermarks and some usage limitations.

Setup & Execution

  1. Clone / download the project
    git clone https://github.com/your-repo/groupdocs-editor-java-edit-docx-in-memory.git
    cd groupdocs-editor-java-edit-docx-in-memory
  2. Add your license file (optional but recommended) – copy GroupDocs.Editor.lic into the project root.
  3. Place a DOCX file you want to edit into resources/input/ and rename it to sample.docx (or replace the existing placeholder).
  4. Build the project
    mvn clean compile
  5. Run the example
    mvn exec:java

What the Example Does

  • Loads resources/input/sample.docx via an InputStream.
  • Creates a Editor instance with default LoadOptions.
  • Performs an in‑memory text replacement (HelloHi).
  • Saves the edited document to resources/output/edited_sample.docx using an OutputStream.
  • All operations stay in memory; only the final file is written to disk.

Customising the Demo

  • Change the text to replace – modify the TextReplacer parameters in EditDocxInMemoryExample.java.
  • Add more complex edits – explore other editing elements offered by GroupDocs.Editor such as ParagraphReplacer, ImageReplacer, etc.
  • Work with other formats – GroupDocs.Editor supports DOC, DOCX, ODT, RTF, and more. Adjust the input file accordingly.

Notes

  • The sample sample.docx included in the repository is only a placeholder. Replace it with a real DOCX to see the actual editing effect.
  • Ensure the resources/output/ directory is writable; the code will create it automatically if missing.
  • This project is intended purely as a showcase. For production use, add robust error handling, logging, and resource management as required.

Happy coding with GroupDocs!