我正在尝试使用unoconv转换xlsx。当我在主机上运行它时,它会创建一个54页的pdf文件,这是正确的。当我在Docker容器中运行它时,它会创建83页pdf,基本上打破了一些列。我确保unoconv,libreoffice和python的版本在两种环境中都相同。这是配置:
主机
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.4 LTS
Release: 18.04
Codename: bionic
$ libreoffice --version
LibreOffice 6.0.7.3 00m0(Build:3)
$ unoconv --version
unoconv 0.7
Written by Dag Wieers <dag@wieers.com>
Homepage at http://dag.wieers.com/home-made/unoconv/
platform posix/linux
python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0]
LibreOffice 6.0.7.3
$ UNO_PATH=/usr/lib/libreoffice unoconv -vvv -f pdf -o test5.pdf {file_path}
Verbosity set to level 3
Using office base path: /usr/lib/libreoffice
Using office binary path: /usr/lib/libreoffice/program
DEBUG: Connection type: socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext
Input file: {file_path)
Selected output format: Portable Document Format [.pdf]
Selected office filter: calc_pdf_Export
Used doctype: spreadsheet
Output file: file:///home/ravi/test5.pdf
$ qpdf --show-npages test5.pdf
54
Docker容器
root@938b1dbdc4cd:/code# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
root@938b1dbdc4cd:/code# libreoffice --version
LibreOffice 6.0.7.3 00m0(Build:3)
root@938b1dbdc4cd:/code# unoconv --version
unoconv 0.7
Written by Dag Wieers <dag@wieers.com>
Homepage at http://dag.wieers.com/home-made/unoconv/
platform posix/linux
python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0]
LibreOffice 6.0.7.3
root@938b1dbdc4cd:/code# UNO_PATH=/usr/lib/libreoffice unoconv -vvv -f pdf -o test5.pdf {file_path}
Verbosity set to level 3
Using office base path: /usr/lib/libreoffice
Using office binary path: /usr/lib/libreoffice/program
DEBUG: Connection type: socket,host=127.0.0.1,port=2002,tcpNoDelay=1;urp;StarOffice.ComponentContext
DEBUG: Existing listener not found.
DEBUG: Launching our own listener using /usr/lib/libreoffice/program/soffice.bin.
LibreOffice listener successfully started. (pid=1260)
Input file: {file_path}
func=xmlSecCheckVersionExt:file=xmlsec.c:line=188:obj=unknown:subj=unknown:error=19:invalid version:mode=abi compatible;expected minor version=2;real minor version=2;expected subminor version=25;real subminor version=26
Selected output format: Portable Document Format [.pdf]
Selected office filter: calc_pdf_Export
Used doctype: spreadsheet
Output file: file:///code/test5.pdf
DEBUG: Terminating LibreOffice instance.
DEBUG: Waiting for LibreOffice instance to exit.
root@938b1dbdc4cd:/code# qpdf --show-npages test5.pdf
83
另外,当我使用openoffice而不是libreoffice时,两个命令都创建100页的文件。文件是相同的,但是没有正确解析,因此我需要使用libreoffice。请让我知道我可以使用其他版本是否缺少其他依赖项。
我还应该添加以确保我在同一文件上运行,并且在运行之前将文件从Docker容器内部复制到主机。