Language / 语言: 🇺🇸 English | 🇨🇳 中文
A powerful web-based document editing system that supports intelligent document processing with multi-language support. Features document comparison before and after modifications, and supports downloading modified documents while maintaining original formatting.
Editor in home page:
Download the modified document and review it:
Support the API:
- 🌐 Multi-language Support: Chinese and English interface with dynamic switching
- 📄 Document Processing: Support for Word documents (.docx) and text files (.txt)
- 🔄 Batch Modifications: Apply multiple text modifications at once
- 📊 Real-time Preview: Live document preview with modifications
- 📊 Document Comparison: Compare documents before and after modifications
- 📥 Format-Preserving Download: Download modified documents while maintaining original formatting
- 🌍 Remote API Access: RESTful API for programmatic access
- 📱 Responsive Design: Works on desktop and mobile devices
- 🔒 Secure File Handling: Secure upload and processing
- 🚀 Auto-load Support: Load documents and modifications from URLs
- 🐳 Docker Support: Containerized deployment ready
- Python 3.8 or higher
- pip package manager
Method 1: Docker Deployment (Recommended)
# Clone the repository
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# Run with Docker Compose
docker-compose up -d
# Custom port deployment
HOST_PORT=8080 docker-compose up -d
# Check status
docker-compose ps
# Stop services
docker-compose down
Method 2: Direct Installation
# Clone the repository
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# Install dependencies
pip install -r requirements.txt
# Run the application
python run.py
Method 3: Virtual Environment
# Clone the repository
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# Create virtual environment
python -m venv venv
# Activate virtual environment
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the application
python run.py
Method 4: Conda Environment
# Clone the repository
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# Create conda environment
conda create -n document-editor python=3.9
conda activate document-editor
# Install dependencies
pip install -r requirements.txt
# Run the application
python run.py
After successful startup, access the system via:
- Local Access: http://127.0.0.1:5000
- Network Access: http://YOUR_IP:5000
Step 1: Access Homepage
- Open your web browser
- Navigate to
http://127.0.0.1:5000
- Choose your preferred language (Chinese/English)
Step 2: Upload Document
- Click the "Upload Document" button
- Select a Word document (.docx file) from your computer
- Wait for the upload and processing to complete
- The document content will be displayed in the preview area
Step 3: Add Modifications
Option A: Manual Entry
- Click "Add Modification" button
- Fill in the modification form:
- Original Text: Text to be replaced
- New Text: Replacement text
- Reason: Reason for the modification
- Click "Add" to save the modification
Option B: CSV File Upload
- Prepare a CSV file with columns:
original_text
,new_text
,reason
- Click "Upload CSV" button
- Select your CSV file
- All modifications will be imported automatically
Step 4: Apply and Download
- Review your modifications in the list
- Click "Apply Modifications" to process the document
- Preview the modified document
- Click "Download Modified Document" to save the result
Base URL: http://127.0.0.1:5000/api
Auto-load and Process Endpoint: POST /api/auto_load
Example 1: Load from URLs with Auto-apply
curl -X POST http://127.0.0.1:5000/api/auto_load \
-H "Content-Type: application/json" \
-d '{
"document": "https://example.com/document.docx",
"modifications": "https://example.com/modifications.csv",
"language": "en",
"auto_apply": true
}'
Example 2: Load from Local Files
curl -X POST http://127.0.0.1:5000/api/auto_load \
-F "document_file=@/path/to/document.docx" \
-F "modifications_file=@/path/to/modifications.csv" \
-F "language=en" \
-F "auto_apply=true"
Example 3: JSON Modifications
curl -X POST http://127.0.0.1:5000/api/auto_load \
-H "Content-Type: application/json" \
-d '{
"document": "https://example.com/document.docx",
"modifications": [
{
"original_text": "old text",
"new_text": "new text",
"reason": "improvement"
}
],
"language": "en",
"auto_apply": true
}'
Create a .env
file in the project root:
# Server Configuration
HOST=0.0.0.0
PORT=5000
DEBUG=True
# Upload Configuration
MAX_CONTENT_LENGTH=16777216 # 16MB
UPLOAD_FOLDER=uploads
TEMP_FOLDER=temp
# Security
SECRET_KEY=your-secret-key-here
# Language Settings
DEFAULT_LANGUAGE=en
SUPPORTED_LANGUAGES=en,zh
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Sawyer Shi
- GitHub: @sawyer-shi
- Project Link: https://github.com/sawyer-shi/document-preview-editor
- Flask Web Framework
- Python-docx Library
- All contributors and users
一个强大的基于Web的文档编辑系统,支持智能文档处理和多语言支持。支持修改前后的文档对比,支持对修改后的文件下载并且格式保持不变。
首页编辑效果:
下载修改后的文档,自动带上了修改批注:
支持API调用:
- 🌐 多语言支持: 中文和英文界面,支持动态切换
- 📄 文档处理: 支持Word文档(.docx)和文本文件(.txt)
- 🔄 批量修改: 一次性应用多个文本修改
- 📊 实时预览: 实时显示文档修改效果
- 📊 文档对比: 支持修改前后的文档对比
- 📥 格式保持下载: 下载修改后文档,保持原有格式
- 🌍 远程API访问: 提供RESTful API接口
- 📱 响应式设计: 支持桌面端和移动端
- 🔒 安全文件处理: 安全的文件上传和处理
- 🚀 自动加载支持: 从URL加载文档和修改内容
- 🐳 Docker支持: 支持容器化部署
- Python 3.8 或更高版本
- pip 包管理器
方式一:Docker容器部署(推荐)
# 克隆项目
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# 使用Docker Compose运行
docker-compose up -d
# 自定义端口运行
HOST_PORT=8080 docker-compose up -d
# 查看运行状态
docker-compose ps
# 停止服务
docker-compose down
方式二:源码直接安装
# 克隆项目
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# 安装依赖
pip install -r requirements.txt
# 运行项目
python run.py
方式三:虚拟环境安装
# 克隆项目
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# 创建虚拟环境
python -m venv venv
# 激活虚拟环境
# Windows:
venv\Scripts\activate
# Linux/macOS:
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
# 运行项目
python run.py
方式四:Conda环境安装
# 克隆项目
git clone https://github.com/sawyer-shi/document-preview-editor.git
cd document-preview-editor
# 创建conda环境
conda create -n document-editor python=3.9
conda activate document-editor
# 安装依赖
pip install -r requirements.txt
# 运行项目
python run.py
启动成功后,通过以下URL访问系统:
- 本地访问: http://127.0.0.1:5000
- 网络访问: http://YOUR_IP:5000
步骤1:访问首页
- 打开网页浏览器
- 导航到
http://127.0.0.1:5000
- 选择您的首选语言(中文/英文)
步骤2:上传文档
- 点击**"上传文档"**按钮
- 从计算机中选择Word文档(.docx文件)
- 等待上传和处理完成
- 文档内容将显示在预览区域
步骤3:添加修改条目
选项A:手动输入
- 点击**"添加修改条目"**按钮
- 填写修改表单:
- 原始文本: 要替换的文本
- 新文本: 替换后的文本
- 原因: 修改原因
- 点击**"添加"**保存修改条目
选项B:CSV文件上传
- 准备包含
original_text
,new_text
,reason
列的CSV文件 - 点击**"上传CSV"**按钮
- 选择您的CSV文件
- 所有修改条目将自动导入
步骤4:应用和下载
- 在列表中查看您的修改条目
- 点击**"应用修改"**处理文档
- 预览修改后的文档
- 点击**"下载修改后的文档"**保存结果
基础URL: http://127.0.0.1:5000/api
自动加载和处理端点: POST /api/auto_load
示例1:从URL加载并自动应用
curl -X POST http://127.0.0.1:5000/api/auto_load \
-H "Content-Type: application/json" \
-d '{
"document": "https://example.com/document.docx",
"modifications": "https://example.com/modifications.csv",
"language": "zh",
"auto_apply": true
}'
示例2:从本地文件加载
curl -X POST http://127.0.0.1:5000/api/auto_load \
-F "document_file=@/path/to/document.docx" \
-F "modifications_file=@/path/to/modifications.csv" \
-F "language=zh" \
-F "auto_apply=true"
示例3:JSON格式修改条目
curl -X POST http://127.0.0.1:5000/api/auto_load \
-H "Content-Type: application/json" \
-d '{
"document": "https://example.com/document.docx",
"modifications": [
{
"original_text": "旧文本",
"new_text": "新文本",
"reason": "改进"
}
],
"language": "zh",
"auto_apply": true
}'
在项目根目录创建 .env
文件:
# 服务器配置
HOST=0.0.0.0
PORT=5000
DEBUG=True
# 上传配置
MAX_CONTENT_LENGTH=16777216 # 16MB
UPLOAD_FOLDER=uploads
TEMP_FOLDER=temp
# 安全配置
SECRET_KEY=你的密钥
# 语言设置
DEFAULT_LANGUAGE=zh
SUPPORTED_LANGUAGES=en,zh
- Fork 本仓库
- 创建您的功能分支 (
git checkout -b feature/AmazingFeature
) - 提交您的更改 (
git commit -m 'Add some AmazingFeature'
) - 推送到分支 (
git push origin feature/AmazingFeature
) - 打开Pull Request
本项目基于Apache License 2.0许可证 - 查看 LICENSE 文件了解详情。
Sawyer Shi
- Flask Web框架
- Python-docx库
- 所有贡献者和用户