2012-08-10 13:30:41 +00:00
|
|
|
/*
|
|
|
|
* Constants
|
|
|
|
*
|
|
|
|
* by WangLu
|
|
|
|
* 2012.08.10
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Consts.h"
|
|
|
|
|
|
|
|
const double EPS = 1e-6;
|
|
|
|
|
2012-08-10 13:41:24 +00:00
|
|
|
const std::string HTML_HEAD = "<!DOCTYPE html>\n\
|
2012-08-10 13:30:41 +00:00
|
|
|
<html><head>\
|
|
|
|
<meta charset=\"utf-8\">\
|
|
|
|
<style type=\"text/css\">\
|
|
|
|
#pdf-main {\
|
|
|
|
font-family: sans-serif;\
|
|
|
|
position:absolute;\
|
|
|
|
top:0;\
|
|
|
|
left:0;\
|
|
|
|
bottom:0;\
|
|
|
|
right:0;\
|
|
|
|
overflow:auto;\
|
|
|
|
background-color:grey;\
|
|
|
|
}\
|
|
|
|
#pdf-main > .p {\
|
|
|
|
position:relative;\
|
|
|
|
margin:13px auto;\
|
|
|
|
background-color:white;\
|
|
|
|
overflow:hidden;\
|
|
|
|
display:none;\
|
|
|
|
}\
|
2012-08-12 12:36:56 +00:00
|
|
|
.p > .l {\
|
|
|
|
position:absolute;\
|
2012-08-10 13:30:41 +00:00
|
|
|
white-space:pre;\
|
|
|
|
}\
|
|
|
|
.l > .w {\
|
|
|
|
display:inline-block;\
|
2012-08-13 13:05:14 +00:00
|
|
|
font-family: monospace;\
|
2012-08-10 13:30:41 +00:00
|
|
|
}\
|
|
|
|
::selection{\
|
|
|
|
background: rgba(168,209,255,0.5);\
|
|
|
|
}\
|
|
|
|
::-moz-selection{\
|
|
|
|
background: rgba(168,209,255,0.5);\
|
|
|
|
}\
|
2012-08-12 12:36:56 +00:00
|
|
|
.p > .i {\
|
|
|
|
position:absolute;\
|
|
|
|
}\
|
2012-08-10 13:30:41 +00:00
|
|
|
</style><link rel=\"stylesheet\" type=\"text/css\" href=\"all.css\" />\
|
|
|
|
<script type=\"text/javascript\">\
|
|
|
|
function show_pages()\
|
|
|
|
{\
|
2012-08-13 11:06:41 +00:00
|
|
|
var pages = document.getElementById('pdf-main').childNodes;\
|
|
|
|
var idx = 0;\
|
|
|
|
var f = function(){\
|
|
|
|
if (idx < pages.length) {\
|
|
|
|
try{\
|
|
|
|
pages[idx].style.display='block';\
|
|
|
|
}catch(e){}\
|
|
|
|
++idx;\
|
|
|
|
setTimeout(f,100);\
|
|
|
|
}\
|
|
|
|
};\
|
|
|
|
f();\
|
2012-08-10 13:30:41 +00:00
|
|
|
};\
|
|
|
|
</script>\
|
|
|
|
</head><body onload=\"show_pages();\"><div id=\"pdf-main\">";
|
|
|
|
|
2012-08-10 13:41:24 +00:00
|
|
|
const std::string HTML_TAIL = "</div></body></html>";
|
|
|
|
|
|
|
|
const std::string TMP_DIR = "/tmp/pdf2htmlEX";
|
2012-08-10 13:30:41 +00:00
|
|
|
|
|
|
|
const std::map<std::string, std::string> 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<std::string, std::string> 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"},\
|
|
|
|
});
|
2012-08-10 13:41:24 +00:00
|
|
|
|
|
|
|
|