PDF转Word功能需要系统安装LibreOffice:
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install libreoffice
CentOS/RHEL:
sudo yum install libreoffice
macOS:
brew install libreoffice
Windows: 从 LibreOffice官网 下载并安装
等待当前npm安装完成后,继续安装剩余依赖:
# 如果pdf-lib安装完成,继续安装其他依赖
npm install pdf-merger-js
npm install html-pdf-node
npm install libreoffice-convert
或者一次性安装所有依赖:
npm install pdf-lib pdf-merger-js html-pdf-node libreoffice-convert
# 检查LibreOffice是否安装成功
libreoffice --version
# 检查所有依赖是否安装成功
npm list pdf-lib pdf-merger-js html-pdf-node libreoffice-convert
文档处理服务会在系统临时目录创建文件:
/tmp/document-processing/LibreOffice未找到
# 检查安装路径
which libreoffice
依赖安装失败
# 清理缓存重试
npm cache clean --force
npm install
权限问题
# 确保有写入临时目录的权限
chmod 777 /tmp/document-processing/
安装完成后,可以通过以下步骤测试功能:
启动开发服务器:
npm run dev
上传多个Word文档进行测试
需要在Dockerfile中添加LibreOffice安装:
# 基于Ubuntu的示例
FROM ubuntu:20.04
# 安装LibreOffice
RUN apt-get update && \
apt-get install -y libreoffice && \
apt-get clean
# 其他Node.js环境配置...
如遇安装或使用问题,请参考:
docs/word-merge-feature.md