diff --git a/CMakeLists.txt b/CMakeLists.txt
index 39700f3..4ade8bc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -14,10 +14,10 @@ SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
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")
+#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)
+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)
diff --git a/README.md b/README.md
index 479b1a6..ec17348 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ GPLv3
We would like to acknowledge the following projects that have been consulted while writing this program:
* pdftops & pdftohtml from poppler
+* MuPDF
* PDF.js
* Crocodoc
* Google Doc
diff --git a/bin/pdf2htmlEX b/bin/pdf2htmlEX
index ffd80e8..a345164 100755
--- a/bin/pdf2htmlEX
+++ b/bin/pdf2htmlEX
@@ -1,6 +1,12 @@
#!/bin/bash
set -e
+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
@@ -8,13 +14,13 @@ SCRIPT_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"/
# Execute
${SCRIPT_DIR}/pdftohtmlEX $*
-if [ -f convert.pe ]; then
+if [ -f $TMPDIR/convert.pe ]; then
echo -n "Converting fonts: "
- fontforge -script convert.pe 2>/dev/null
+ fontforge -script $TMPDIR/convert.pe 2>/dev/null
echo "."
- rm convert.pe
fi
-rm *.encoding 2>/dev/null
+#clean
+#rm -f $TMPDIR/* 2>/dev/null
echo "Done."
diff --git a/src/Consts.cc b/src/Consts.cc
new file mode 100644
index 0000000..07abc62
--- /dev/null
+++ b/src/Consts.cc
@@ -0,0 +1,89 @@
+/*
+ * Constants
+ *
+ * by WangLu
+ * 2012.08.10
+ */
+
+#include "Consts.h"
+
+const double EPS = 1e-6;
+
+const std::string HTML_HEAD = "\n\
+
\
+\
+\
+\
+";
+
+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 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"},\
+});
+
+
diff --git a/src/Consts.h b/src/Consts.h
index e39b67e..dec0420 100644
--- a/src/Consts.h
+++ b/src/Consts.h
@@ -9,72 +9,19 @@
#define CONSTS_H__
#include
#include