1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

add 'clean_tmp' option

This commit is contained in:
Lu Wang 2012-08-15 15:43:49 +08:00
parent 63dd9b3e27
commit 29d41573ef
5 changed files with 15 additions and 5 deletions

View File

@ -223,6 +223,8 @@ class HTMLRenderer : public OutputDev
static const std::string NECK_HTML_FILENAME;
static const std::string TAIL_HTML_FILENAME;
static const std::string CSS_FILENAME;
static const std::string FONTFORGE_SCRIPT_FILENAME;
// for cross-platform purpose, use a "null" file instead of /dev/null
static const std::string NULL_FILENAME;
};

View File

@ -198,12 +198,18 @@ void HTMLRenderer::process_single_html()
void HTMLRenderer::add_tmp_file(const string & fn)
{
if(!param->clean_tmp)
return;
if(tmp_files.insert(fn).second && param->debug)
cerr << "Add new temporary file: " << fn << endl;
}
void HTMLRenderer::clean_tmp_files()
{
if(!param->clean_tmp)
return;
for(const auto & fn : tmp_files)
{
try
@ -230,3 +236,4 @@ const std::string HTMLRenderer::NECK_HTML_FILENAME = "neck.html";
const std::string HTMLRenderer::TAIL_HTML_FILENAME = "tail.html";
const std::string HTMLRenderer::CSS_FILENAME = "all.css";
const std::string HTMLRenderer::NULL_FILENAME = "null";
const std::string HTMLRenderer::FONTFORGE_SCRIPT_FILENAME = "pdf2htmlEX.pe";

View File

@ -119,9 +119,9 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
string fn = (format("f%|1$x|") % fn_id).str();
path script_path = tmp_dir / "pdf2htmlEX.pe";
path script_path = tmp_dir / FONTFORGE_SCRIPT_FILENAME;
ofstream script_fout(script_path, ofstream::binary);
add_tmp_file("pdf2htmlEX.pe");
add_tmp_file(FONTFORGE_SCRIPT_FILENAME);
script_fout << format("Open(%1%, 1)") % (tmp_dir / (fn + suffix)) << endl;

View File

@ -25,10 +25,10 @@ struct Param
double h_eps, v_eps;
int process_nontext;
int single_html;
int debug;
int single_html;
int clean_tmp;
};

View File

@ -131,9 +131,10 @@ po::variables_map parse_options (int argc, char **argv)
("vdpi2", po::value<double>(&param.v_dpi2)->default_value(144.0), "vertical DPI for non-text")
("heps", po::value<double>(&param.h_eps)->default_value(1.0), "max tolerated horizontal offset (in pixels)")
("veps", po::value<double>(&param.v_eps)->default_value(1.0), "max tolerated vertical offset (in pixels)")
("single-html", po::value<int>(&param.single_html)->default_value(1), "combine everything into one single HTML file")
("process-nontext", po::value<int>(&param.process_nontext)->default_value(1), "process nontext objects")
("debug", po::value<int>(&param.debug)->default_value(0), "output debug information")
("single-html", po::value<int>(&param.single_html)->default_value(1), "combine everything into one single HTML file")
("clean-tmp", po::value<int>(&param.clean_tmp)->default_value(1), "clean temporary files after processing")
;
opt_hidden.add_options()