背景
最近项目需要实现ceb文件在线预览,之前并没见过这格式的文件,一搜发现果然不简单,这破东西还不太好弄在线预览,经过查找发现只有windows版本的cebToPdf.exe程序可以转换成pdf再进行预览,但是我们服务器是centos(内网)啊,所以就有了该篇文章。
cebToPdf.exe程序及其测试文件下载地址:https://download.csdn.net/download/baikunlong/86782073
wine我用的6.0,下载地址:https://download.csdn.net/download/baikunlong/86782559
1 外网机器操作
不想操作的可直接下我整理好的:https://download.csdn.net/download/baikunlong/86782582
# 安装工具包,里面包含了repotrack(用于下载各种依赖)
yum -y install yum-utils
使用 repotrack 下载所需依赖
repotrack -p rpms libX11-devel freetype-devel zlib-devel libxcb-devel alsa-lib-devel.i686 libsndfile-devel.i686 readline-devel.i686 glib2.i686 glibc-devel.i686 libgcc.i686 libstdc++-devel.i686 pulseaudio-libs-devel.i686 cmake audiofile-devel.i686 freeglut-devel.i686 lcms-devel.i686 libieee1284-devel.i686 openldap-devel.i686 unixODBC-devel.i686 sane-backends-devel.i686 fontforge libgphoto2-devel.i686 isdn4k-utils-devel.i686 mesa-libGL-devel.i686 mesa-libGLU-devel.i686 libXxf86dga-devel.i686 libXxf86vm-devel.i686 giflib-devel.i686 cups-devel.i686 gsm-devel.i686 libv4l-devel.i686 fontpackages-devel ImageMagick-devel.i686 libX11-devel.i686 docbook-utils-pdf libtextcat tex-cm-lgc alsa-lib-devel audiofile-devel.i686 audiofile-devel cups-devel.i686 cups-devel dbus-devel.i686 dbus-devel fontconfig-devel.i686 fontconfig-devel freetype.i686 freetype-devel.i686 freetype-devel giflib-devel.i686 giflib-devel lcms-devel.i686 lcms-devel libICE-devel.i686 libICE-devel libjpeg-turbo-devel.i686 libjpeg-turbo-devel libpng-devel.i686 libpng-devel libSM-devel.i686 libSM-devel libusb-devel.i686 libusb-devel libX11-devel.i686 libX11-devel libXau-devel.i686 libXau-devel libXcomposite-devel.i686 libXcomposite-devel libXcursor-devel.i686 libXcursor-devel libXext-devel.i686 libXext-devel libXi-devel.i686 libXi-devel libXinerama-devel.i686 libXinerama-devel libxml2-devel.i686 libxml2-devel libXrandr-devel.i686 libXrandr-devel libXrender-devel.i686 libXrender-devel libxslt-devel.i686 libxslt-devel libXt-devel.i686 libXt-devel libXv-devel.i686 libXv-devel libXxf86vm-devel.i686 libXxf86vm-devel mesa-libGL-devel.i686 mesa-libGL-devel mesa-libGLU-devel.i686 mesa-libGLU-devel ncurses-devel.i686 ncurses-devel openldap-devel.i686 openldap-devel openssl-devel.i686 openssl-devel zlib-devel.i686 pkgconfig sane-backends-devel.i686 sane-backends-devel xorg-x11-proto-devel glibc-devel.i686 prelink fontforge flex bison libstdc++-devel.i686 pulseaudio-libs-devel.i686 gnutls-devel.i686 libgphoto2-devel.i686 isdn4k-utils-devel.i686 gsm-devel.i686 samba-winbind libv4l-devel.i686 cups-devel.i686 libtiff-devel.i686 gstreamer-devel.i686 gstreamer-plugins-base-devel.i686 gettext-devel.i686
-p rpms意思为下载的依赖全部放在当前目录下的rpms目录下,如没有rpms目录会自动创建
其中lcms-devel.i686用了阿里和网易的yum源都没找到,索性不管了,没有影响后续使用。
这里说个下载可能会遇到的网络问题,虚拟机的网络明明很畅通,但是死活就总是超时,然后重新执行命令,下好几个又超时,虽然在坚持不懈的努力下还是下完了,但是途中我在自己的阿里云服务器上面去下,嗖嗖嗖的就下完了。。。
最后虚拟机下完了有951个文件,阿里云服务器下完后918个文件,不过因为阿里云的先下完,我就直接用的918这个,附件地址:https://download.csdn.net/download/baikunlong/86782582
2 内网离线安装wine
把下载好的wine压缩包,rpm依赖包,传到内网服务器
所有rpm进行安装:
tar -zxf wine-rpms.tgz
cd wine/
rpm -ivh *.rpm --force --nodeps
wine安装:
xz -d wine-6.0.tar.xz
tar -xf wine-6.0
cd wine-6.0
mkdir wine32
cd wine32
../configure --enable-win32 # 这里一定是32位
make && make install
3 运行测试 && 报错解决
安装完成后,我们可以直接执行下面命令查看版本
wine --version
然后开始转换ceb文件测试。如果你之前安装过wine,那么很可能会不幸运和我一样遇到如下报错:
wine: '/root/.wine' is a 64-bit installation, it cannot be used with a 32-bit
这时我们要清理一下该文件:
rm -rf ~/.wine
然后再次执行:
可以看到已经转换成功了,该pdf也是打开正常的。
在最后说一下为啥要安装32位的wine和为啥安装了32位wine后我却用的64文件夹下的exe。
1 为啥要安装32位的wine
因为两个ceb2pdf.exe都是32位的:
所以之前只要你是在线yum install wine的,肯定报错wine : Z:\xxx EXE格式无效,对比两个文件夹,就dll大小不一样,exe其实是一样的。
2 为啥安装了32位wine后我却用的64文件夹下的exe
因为执行32下的exe报dll找不到。。。
结尾
别看没多少内容,但是花了两天踩坑。。。