mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
add 'clean_tmp' option
This commit is contained in:
parent
63dd9b3e27
commit
29d41573ef
@ -223,6 +223,8 @@ class HTMLRenderer : public OutputDev
|
|||||||
static const std::string NECK_HTML_FILENAME;
|
static const std::string NECK_HTML_FILENAME;
|
||||||
static const std::string TAIL_HTML_FILENAME;
|
static const std::string TAIL_HTML_FILENAME;
|
||||||
static const std::string CSS_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;
|
static const std::string NULL_FILENAME;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -198,12 +198,18 @@ void HTMLRenderer::process_single_html()
|
|||||||
|
|
||||||
void HTMLRenderer::add_tmp_file(const string & fn)
|
void HTMLRenderer::add_tmp_file(const string & fn)
|
||||||
{
|
{
|
||||||
|
if(!param->clean_tmp)
|
||||||
|
return;
|
||||||
|
|
||||||
if(tmp_files.insert(fn).second && param->debug)
|
if(tmp_files.insert(fn).second && param->debug)
|
||||||
cerr << "Add new temporary file: " << fn << endl;
|
cerr << "Add new temporary file: " << fn << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HTMLRenderer::clean_tmp_files()
|
void HTMLRenderer::clean_tmp_files()
|
||||||
{
|
{
|
||||||
|
if(!param->clean_tmp)
|
||||||
|
return;
|
||||||
|
|
||||||
for(const auto & fn : tmp_files)
|
for(const auto & fn : tmp_files)
|
||||||
{
|
{
|
||||||
try
|
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::TAIL_HTML_FILENAME = "tail.html";
|
||||||
const std::string HTMLRenderer::CSS_FILENAME = "all.css";
|
const std::string HTMLRenderer::CSS_FILENAME = "all.css";
|
||||||
const std::string HTMLRenderer::NULL_FILENAME = "null";
|
const std::string HTMLRenderer::NULL_FILENAME = "null";
|
||||||
|
const std::string HTMLRenderer::FONTFORGE_SCRIPT_FILENAME = "pdf2htmlEX.pe";
|
||||||
|
@ -119,9 +119,9 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
|
|||||||
|
|
||||||
string fn = (format("f%|1$x|") % fn_id).str();
|
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);
|
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;
|
script_fout << format("Open(%1%, 1)") % (tmp_dir / (fn + suffix)) << endl;
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ struct Param
|
|||||||
double h_eps, v_eps;
|
double h_eps, v_eps;
|
||||||
|
|
||||||
int process_nontext;
|
int process_nontext;
|
||||||
|
int single_html;
|
||||||
|
|
||||||
int debug;
|
int debug;
|
||||||
|
int clean_tmp;
|
||||||
int single_html;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,9 +131,10 @@ po::variables_map parse_options (int argc, char **argv)
|
|||||||
("vdpi2", po::value<double>(¶m.v_dpi2)->default_value(144.0), "vertical DPI for non-text")
|
("vdpi2", po::value<double>(¶m.v_dpi2)->default_value(144.0), "vertical DPI for non-text")
|
||||||
("heps", po::value<double>(¶m.h_eps)->default_value(1.0), "max tolerated horizontal offset (in pixels)")
|
("heps", po::value<double>(¶m.h_eps)->default_value(1.0), "max tolerated horizontal offset (in pixels)")
|
||||||
("veps", po::value<double>(¶m.v_eps)->default_value(1.0), "max tolerated vertical offset (in pixels)")
|
("veps", po::value<double>(¶m.v_eps)->default_value(1.0), "max tolerated vertical offset (in pixels)")
|
||||||
|
("single-html", po::value<int>(¶m.single_html)->default_value(1), "combine everything into one single HTML file")
|
||||||
("process-nontext", po::value<int>(¶m.process_nontext)->default_value(1), "process nontext objects")
|
("process-nontext", po::value<int>(¶m.process_nontext)->default_value(1), "process nontext objects")
|
||||||
("debug", po::value<int>(¶m.debug)->default_value(0), "output debug information")
|
("debug", po::value<int>(¶m.debug)->default_value(0), "output debug information")
|
||||||
("single-html", po::value<int>(¶m.single_html)->default_value(1), "combine everything into one single HTML file")
|
("clean-tmp", po::value<int>(¶m.clean_tmp)->default_value(1), "clean temporary files after processing")
|
||||||
;
|
;
|
||||||
|
|
||||||
opt_hidden.add_options()
|
opt_hidden.add_options()
|
||||||
|
Loading…
Reference in New Issue
Block a user