Skip to content

canghailan/doconv

Repository files navigation

文档格式转换服务

字体

字体安装

mkdir -p /usr/share/fonts/truetype /usr/share/fonts/opentype
apt-get -y install fontconfig
fc-cache -fv

字体参考资料

免费中文字体

官方仓库中版本过低,下载安装最新版本

apt-get install -y openjdk-8-jre-headless libglu1-mesa libxinerama1 libdbus-glib-1-2 libcairo2 libsm6
curl -OL 'http://download.documentfoundation.org/libreoffice/stable/6.0.2/deb/x86_64/LibreOffice_6.0.2_Linux_x86-64_deb.tar.gz'
dpkg -i LibreOffice*/DEBS/*.deb

官方仓库中版本过低,下载安装最新版本

curl -OL 'https://raw.githubusercontent.com/dagwieers/unoconv/0.8.2/unoconv'

官方仓库中版本过低,下载安装最新版本

curl -OL 'https://github.com/jgm/pandoc/releases/download/2.1.2/pandoc-2.1.2-1-amd64.deb'

TODO

DEBIAN_FRONTEND=noninteractive
apt-get install -yq texlive

启用静态文件、CGI

  • Apache
  • unoconv

使用方法

POST http://localhost/cgi-bin/worker.cgi
Content-Type: text/plain;charset=utf-8

mkdir -p /workspace/1/ \
&& cd /workspace/1/ \
&& curl -o a.ppt -O http://localhost/1.pptx \
&& unoconv -f pdf a.ppt \
&& convert a.pdf a.jpg

TODO

  • 字体配置待优化
  • 镜像大小待优化
  • CGI脚本待优化,目前未考虑安全及易用性问题
  • 文档待完善

附录:阿里云Docker镜像

sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -y update
sudo apt-get -y install docker-ce

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": [""]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker