diff --git a/CMakeLists.txt b/CMakeLists.txt
index c517eb4..da4b351 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,16 +9,30 @@ find_package(Boost REQUIRED COMPONENTS program_options)
include_directories(${Boost_INCLUDE_DIRS})
link_directories ( ${Boost_LIBRARY_DIRS} )
-set(PDFTOHTMLEX_VERSION "0.1")
-SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
+set(PDF2HTMLEX_VERSION "0.1")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wunused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
-add_executable(pdftohtmlEX src/pdftohtmlEX.cc src/HTMLRenderer.cc src/HTMLRenderer.h src/BackgroundRenderer.cc src/BackgroundRenderer.h src/Consts.h src/Consts.cc src/util.h)
-target_link_libraries(pdftohtmlEX poppler boost_program_options)
+configure_file (bin/pdf2htmlEX.in bin/pdf2htmlEX)
+configure_file (src/config.h.in src/config.h)
-install (TARGETS pdftohtmlEX DESTINATION bin)
+add_executable(pdf2htmlEX
+ src/pdf2htmlEX.cc
+ src/HTMLRenderer.h
+ src/HTMLRenderer.cc
+ src/BackgroundRenderer.h
+ src/BackgroundRenderer.cc
+ src/Consts.h
+ src/Consts.cc
+ src/util.h
+ src/config.h)
+
+target_link_libraries(pdf2htmlEX poppler boost_program_options boost_filesystem)
+
+install (TARGETS pdf2htmlEX DESTINATION lib/pdf2htmlEX)
install (PROGRAMS "bin/pdf2htmlEX" DESTINATION bin)
+file (GLOB libfiles lib/*)
+install (FILES ${libfiles} DESTINATION lib/pdf2htmlEX)
diff --git a/bin/pdf2htmlEX b/bin/pdf2htmlEX.in
similarity index 60%
rename from bin/pdf2htmlEX
rename to bin/pdf2htmlEX.in
index a345164..204ecb1 100755
--- a/bin/pdf2htmlEX
+++ b/bin/pdf2htmlEX.in
@@ -1,18 +1,14 @@
#!/bin/bash
set -e
+LIBDIR=@CMAKE_INSTALL_PREFIX@/lib/pdf2htmlEX
TMPDIR=/tmp/pdf2htmlEX
# prepare the temporary directory
test -d $TMPDIR || mkdir -p $TMPDIR
rm -f $TMPDIR/* 2>/dev/null
-# Get directory of the script
-SOURCE="${BASH_SOURCE[0]}"
-while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
-SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"/
-# Execute
-${SCRIPT_DIR}/pdftohtmlEX $*
+$LIBDIR/pdf2htmlEX $*
if [ -f $TMPDIR/convert.pe ]; then
echo -n "Converting fonts: "
diff --git a/lib/head.html b/lib/head.html
new file mode 100644
index 0000000..c96ff9c
--- /dev/null
+++ b/lib/head.html
@@ -0,0 +1,66 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/lib/tail.html b/lib/tail.html
new file mode 100644
index 0000000..499f4da
--- /dev/null
+++ b/lib/tail.html
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/src/Consts.cc b/src/Consts.cc
index f894937..dcb1b1f 100644
--- a/src/Consts.cc
+++ b/src/Consts.cc
@@ -9,87 +9,24 @@
const double EPS = 1e-6;
-// The style "-webkit-text-stroke-width:0.2px;" is used in #pdf-main to
-// improve some font of small size, which looks really bad in Chrome & Safari
-const std::string HTML_HEAD = "\n\
-\
- \
- \
-\
-";
+const std::string TMP_DIR="/tmp/pdf2htmlEX";
-const std::string HTML_TAIL = "
";
-
-const std::string TMP_DIR = "/tmp/pdf2htmlEX";
-
-const std::map BASE_14_FONT_CSS_FONT_MAP({\
- { "Courier", "Courier,monospace" },\
- { "Helvetica", "Helvetica,Arial,\"Nimbus Sans L\",sans-serif" },\
- { "Times", "Times,\"Time New Roman\",\"Nimbus Roman No9 L\",serif" },\
- { "Symbol", "Symbol,\"Standard Symbols L\"" },\
- { "ZapfDingbats", "ZapfDingbats,\"Dingbats\"" },\
+const std::map BASE_14_FONT_CSS_FONT_MAP({
+ { "Courier", "Courier,monospace" },
+ { "Helvetica", "Helvetica,Arial,\"Nimbus Sans L\",sans-serif" },
+ { "Times", "Times,\"Time New Roman\",\"Nimbus Roman No9 L\",serif" },
+ { "Symbol", "Symbol,\"Standard Symbols L\"" },
+ { "ZapfDingbats", "ZapfDingbats,\"Dingbats\"" },
});
const double id_matrix[6] = {1.0, 0.0, 0.0, 1.0, 0.0, 0.0};
-const std::map GB_ENCODED_FONT_NAME_MAP({\
- {"\xCB\xCE\xCC\xE5", "SimSun"},\
- {"\xBA\xDA\xCC\xE5", "SimHei"},\
- {"\xBF\xAC\xCC\xE5_GB2312", "SimKai"},\
- {"\xB7\xC2\xCB\xCE_GB2312", "SimFang"},\
- {"\xC1\xA5\xCA\xE9", "SimLi"},\
+const std::map GB_ENCODED_FONT_NAME_MAP({
+ {"\xCB\xCE\xCC\xE5", "SimSun"},
+ {"\xBA\xDA\xCC\xE5", "SimHei"},
+ {"\xBF\xAC\xCC\xE5_GB2312", "SimKai"},
+ {"\xB7\xC2\xCB\xCE_GB2312", "SimFang"},
+ {"\xC1\xA5\xCA\xE9", "SimLi"},
});
diff --git a/src/HTMLRenderer.cc b/src/HTMLRenderer.cc
index 6051cde..e9b67c7 100644
--- a/src/HTMLRenderer.cc
+++ b/src/HTMLRenderer.cc
@@ -17,6 +17,7 @@
#include
#include
+#include
// for gil bug
const int *int_p_NULL = nullptr;
#include
@@ -32,6 +33,7 @@ const int *int_p_NULL = nullptr;
#include "BackgroundRenderer.h"
#include "Consts.h"
#include "util.h"
+#include "config.h"
/*
* CSS classes
@@ -120,12 +122,12 @@ void HTMLRenderer::process(PDFDoc *doc)
void HTMLRenderer::write_html_head()
{
- html_fout << HTML_HEAD << endl;
+ html_fout << boost::filesystem::ifstream(PDF2HTMLEX_LIB_PATH / "head.html", ifstream::binary).rdbuf();
}
void HTMLRenderer::write_html_tail()
{
- html_fout << HTML_TAIL << endl;
+ html_fout << boost::filesystem::ifstream(PDF2HTMLEX_LIB_PATH / "tail.html", ifstream::binary).rdbuf();
}
void HTMLRenderer::startPage(int pageNum, GfxState *state)
diff --git a/src/config.h.in b/src/config.h.in
new file mode 100644
index 0000000..d02324a
--- /dev/null
+++ b/src/config.h.in
@@ -0,0 +1,20 @@
+/*
+ * config.h
+ * Compile time constants
+ *
+ * by WangLu
+ */
+
+
+#ifndef CONFIG_H__
+#define CONFIG_H__
+
+#include
+#include
+
+static const std::string PDF2HTMLEX_VERSION = "@PDF2HTMLEX_VERSION@";
+static const std::string PDF2HTMLEX_PREFIX = "@CMAKE_INSTALL_PREFIX@";
+static const boost::filesystem::path PDF2HTMLEX_LIB_PATH = boost::filesystem::path(PDF2HTMLEX_PREFIX) / "lib" / "pdf2htmlEX";
+
+
+#endif //CONFIG_H__
diff --git a/src/pdftohtmlEX.cc b/src/pdf2htmlEX.cc
similarity index 98%
rename from src/pdftohtmlEX.cc
rename to src/pdf2htmlEX.cc
index b8e6dd3..84b15a4 100644
--- a/src/pdftohtmlEX.cc
+++ b/src/pdf2htmlEX.cc
@@ -27,8 +27,7 @@
#include "HTMLRenderer.h"
#include "Param.h"
-
-#define PDFTOHTMLEX_VERSION "0.1"
+#include "config.h"
namespace po = boost::program_options;
using namespace std;
@@ -102,7 +101,7 @@ static GooString* getInfoDate(Dict *infoDict, char *key) {
void show_usage(void)
{
- cerr << "pdftohtmlEX version " << PDFTOHTMLEX_VERSION << endl;
+ cerr << "pdftohtmlEX version " << PDF2HTMLEX_VERSION << endl;
cerr << endl;
cerr << "Copyright 2011 Hongliang Tian (tatetian@gmail.com)" << endl;
cerr << "Copyright 2012 Lu Wang (coolwanglugmail.com)" << endl;