mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
use tmp dir
This commit is contained in:
parent
5a4eccc632
commit
548e7efbbc
@ -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."
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
const double EPS = 1e-6;
|
||||
|
||||
const char * HTML_HEAD = "<!DOCTYPE html>\n\
|
||||
const std::string HTML_HEAD = "<!DOCTYPE html>\n\
|
||||
<html><head>\
|
||||
<meta charset=\"utf-8\">\
|
||||
<style type=\"text/css\">\
|
||||
@ -64,7 +64,9 @@ function show_pages()\
|
||||
</script>\
|
||||
</head><body onload=\"show_pages();\"><div id=\"pdf-main\">";
|
||||
|
||||
const char * HTML_TAIL = "</div></body></html>";
|
||||
const std::string HTML_TAIL = "</div></body></html>";
|
||||
|
||||
const std::string TMP_DIR = "/tmp/pdf2htmlEX";
|
||||
|
||||
const std::map<std::string, std::string> BASE_14_FONT_CSS_FONT_MAP({\
|
||||
{ "Courier", "Courier,monospace" },\
|
||||
@ -83,3 +85,5 @@ const std::map<std::string, std::string> GB_ENCODED_FONT_NAME_MAP({\
|
||||
{"\xB7\xC2\xCB\xCE_GB2312", "SimFang"},\
|
||||
{"\xC1\xA5\xCA\xE9", "SimLi"},\
|
||||
});
|
||||
|
||||
|
||||
|
@ -13,8 +13,10 @@
|
||||
|
||||
extern const double EPS;
|
||||
|
||||
extern const char * HTML_HEAD;
|
||||
extern const char * HTML_TAIL;
|
||||
extern const std::string HTML_HEAD;
|
||||
extern const std::string HTML_TAIL;
|
||||
|
||||
extern const std::string TMP_DIR;
|
||||
|
||||
extern const std::map<std::string, std::string> BASE_14_FONT_CSS_FONT_MAP;
|
||||
|
||||
|
@ -50,7 +50,7 @@ HTMLRenderer::HTMLRenderer(const Param * param)
|
||||
:line_opened(false)
|
||||
,html_fout(param->output_filename.c_str(), ofstream::binary)
|
||||
,allcss_fout("all.css")
|
||||
,fontscript_fout("convert.pe")
|
||||
,fontscript_fout(TMP_DIR+"/convert.pe")
|
||||
,param(param)
|
||||
{
|
||||
// install default font & size
|
||||
@ -438,7 +438,7 @@ void HTMLRenderer::install_embedded_font (GfxFont * font, long long fn_id)
|
||||
{
|
||||
auto ctg = dynamic_cast<Gfx8BitFont*>(font)->getCodeToGIDMap(ttf);
|
||||
auto ctu = font->getToUnicode();
|
||||
ofstream map_fout((boost::format("f%|1$x|.encoding") % fn_id).str().c_str());
|
||||
ofstream map_fout((boost::format("%2%/f%|1$x|.encoding") % fn_id % TMP_DIR).str().c_str());
|
||||
|
||||
for(int i = 0; i < 256; ++i)
|
||||
{
|
||||
@ -455,7 +455,7 @@ void HTMLRenderer::install_embedded_font (GfxFont * font, long long fn_id)
|
||||
}
|
||||
}
|
||||
|
||||
fontscript_fout << boost::format("LoadEncodingFile(\"f%|1$x|.encoding\", \"f%|1$x|\")") % fn_id << endl;
|
||||
fontscript_fout << boost::format("LoadEncodingFile(\"%2%/f%|1$x|.encoding\", \"f%|1$x|\")") % fn_id % TMP_DIR<< endl;
|
||||
fontscript_fout << boost::format("Reencode(\"f%|1$x|\", 1)") % fn_id << endl;
|
||||
|
||||
ctu->decRefCnt();
|
||||
|
Loading…
Reference in New Issue
Block a user