pdf2htmlEx学习笔记之ubuntu编译

按照官方文档的描述【https://github.com/coolwanglu/pdf2htmlEX/wiki/Building】,使用如下代码编译:

git clone git://github.com/coolwanglu/pdf2htmlEX.git
cd pdf2htmlEX
cmake . && make && sudo make install

执行cmake时报错,找不到poppler和libfontforge两个库。
poppler这个好解决,直接去官网下载源码编译安装即可:

 wget https://poppler.freedesktop.org/poppler-0.25.0.tar.xz
 tar -xf poppler-0.25.0.tar.xz 
 cd poppler-0.25.0/
./configure --enable-poppler-glib
sudo make install

libfontforge先后试了:

sudo apt-get install lfontforge
sudo apt-get install libfontforge1
sudo apt-get install libfontforge-dev

都没用。
后来百度了半天,发现原来这个库好像是作者自己搞出来的。

```bash
git clone https://github.com/coolwanglu/fontforge.git fontforge.git
git checkout pdf2htmlEX
./autogen.sh
./configure
make
sudo make install

再执行行cmake .

taohongtao@sz-android-server:~/pdf2htmlEX$ cmake .
Trying to locate cairo-svg...
-- Checking for module 'libfontforge>=2.0.0'
--   Found libfontforge, version 2.0.20140101
-- Configuring done
-- Generating done
-- Build files have been written to: /data/taohongtao/pdf2htmlEX

cmake终于通过了。下面make:
taohongtao@sz-android-server:~/pdf2htmlEX$ make

Scanning dependencies of target pdf2htmlEX
[  2%] Building CXX object CMakeFiles/pdf2htmlEX.dir/3rdparty/poppler/git/CairoFontEngine.cc.o
/data/taohongtao/pdf2htmlEX/3rdparty/poppler/git/CairoFontEngine.cc:36:28: fatal error: poppler-config.h: 没有那个文件或目录
 #include 
                            ^
compilation terminated.
make[2]: *** [CMakeFiles/pdf2htmlEX.dir/3rdparty/poppler/git/CairoFontEngine.cc.o] 错误 1
make[1]: *** [CMakeFiles/pdf2htmlEX.dir/all] 错误 2
make: *** [all] 错误 2

fuck! fuck! fuck!为什么找不到 poppler-config.h?刚才不是安装了吗?又查了半天,参考了文章【https://blog.csdn.net/hbxf_xs/article/details/86574450】。原来安装poppler的时候需要指定-enable-xpdf-headers标志。好吧,重新弄一下吧。

cd poppler-0.25.0/
./configure -enable-xpdf-headers
sudo make install

再make:

taohongtao@sz-android-server:~/pdf2htmlEX$ make
[ 94%] Built target pdf2htmlEX
[ 97%] Generating share/base.min.css, share/fancy.min.css
/bin/sh: 0: Illegal option -
make[2]: *** [share/base.min.css] 错误 2
make[1]: *** [CMakeFiles/pdf2htmlEX_resources.dir/all] 错误 2
make: *** [all] 错误 2

这又是什么鬼?可能是因为我的代码是从windows上clone下来的,之后又拷贝到ubuntu上的,所以才出了这个问题。因为我运行了git status命令以后,发现好多文件都被修改了。

git checkout -- \*

再make,终于通过了,幸福来得就是这么突然,有时候编译也要看运气,哈哈!

下面测试一下:

taohongtao@sz-android-server:~$ pdf2htmlEX --zoom 1.3 kotlin-docs.pdf 
pdf2htmlEX: error while loading shared libraries: libfontforge.so.2: cannot open shared object file: No such file or directory

高兴的太早了,咋又找不到libfontforge.so.2了呢?

taohongtao@sz-android-server:/usr/local/lib$ ls -l /usr/local/lib|grep libf
-rw-r--r-- 1 root root  24324104  3月 20 13:21 libfontforge.a
-rw-r--r-- 1 root root     23900  3月 20 13:21 libfontforgeexe.a
-rwxr-xr-x 1 root root      1338  3月 20 13:21 libfontforgeexe.la
lrwxrwxrwx 1 root root        24  3月 20 13:21 libfontforgeexe.so -> libfontforgeexe.so.2.0.0
lrwxrwxrwx 1 root root        24  3月 20 13:21 libfontforgeexe.so.2 -> libfontforgeexe.so.2.0.0
-rwxr-xr-x 1 root root     22035  3月 20 13:21 libfontforgeexe.so.2.0.0
-rwxr-xr-x 1 root root      1286  3月 20 13:21 libfontforge.la
lrwxrwxrwx 1 root root        21  3月 20 13:21 libfontforge.so -> libfontforge.so.2.0.0
lrwxrwxrwx 1 root root        21  3月 20 13:21 libfontforge.so.2 -> libfontforge.so.2.0.0
-rwxr-xr-x 1 root root  13266104  3月 20 13:21 libfontforge.so.2.0.0

这明明有呀,咋会找不到呢?又百度了一下,原来需要运行一下sudo ldconfig,长姿势了。
Linux中error while loading shared libraries错误解决办法

试了一下转换的效果,确实厉害!

taohongtao@sz-android-server:~$ pdf2htmlEX kotlin-docs.pdf 
Preprocessing: 196/196
Working: 196/196

taohongtao@sz-android-server:~$ pdf2htmlEX [设计心理学].()唐纳德?A?诺曼.扫描版
-bash: 未预期的符号 `(' 附近有语法错误
taohongtao@sz-android-server:~$ pdf2htmlEX '[设计心理学].()唐纳德?A?诺曼.扫描版.pdf' 
Preprocessing: 244/244
Working: 244/244

taohongtao@sz-android-server:~$ pdf2htmlEX geneve_1564.pdf 
Preprocessing: 2/2
ToUnicode CMap is not valid and got dropped for font: 1
ToUnicode CMap is not valid and got dropped for font: 2
Working: 2/2

你可能感兴趣的:(pdf2htmlEx学习笔记之ubuntu编译)