diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc
index 3fa0117..d0b9a96 100644
--- a/src/HTMLRenderer/general.cc
+++ b/src/HTMLRenderer/general.cc
@@ -78,7 +78,7 @@ void HTMLRenderer::process(PDFDoc *doc)
doc->displayPage(bg_renderer, i, param->h_dpi2, param->v_dpi2,
0, true, false, false,
nullptr, nullptr, nullptr, nullptr);
- bg_renderer->getBitmap()->writeImgFile(splashFormatPng, (char*)(format("p%|1$x|.png")%i).str().c_str(), param->h_dpi2, param->v_dpi2);
+ bg_renderer->getBitmap()->writeImgFile(splashFormatPng, (char*)(dest_dir / (format("p%|1$x|.png")%i).str()).c_str(), param->h_dpi2, param->v_dpi2);
cerr << ".";
cerr.flush();
diff --git a/src/HTMLRenderer/install.cc b/src/HTMLRenderer/install.cc
index 5b4c695..42f59a8 100644
--- a/src/HTMLRenderer/install.cc
+++ b/src/HTMLRenderer/install.cc
@@ -119,7 +119,7 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
string fn = (format("f%|1$x|") % fn_id).str();
- fontscript_fout << format("Open(\"%1%\", 1)") % (tmp_dir / (fn + suffix)) << endl;
+ fontscript_fout << format("Open(%1%, 1)") % (tmp_dir / (fn + suffix)) << endl;
auto ctu = font->getToUnicode();
int * code2GID = nullptr;
@@ -169,7 +169,7 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
if(cnt > 0)
{
- fontscript_fout << format("LoadEncodingFile(\"%1%\", \"%2%\")") % (tmp_dir / (fn+".encoding")) % fn << endl;
+ fontscript_fout << format("LoadEncodingFile(%1%, \"%2%\")") % (tmp_dir / (fn+".encoding")) % fn << endl;
fontscript_fout << format("Reencode(\"%1%\", 1)") % fn << endl;
}
}
@@ -177,7 +177,7 @@ void HTMLRenderer::install_embedded_font(GfxFont * font, const string & suffix,
ctu->decRefCnt();
}
- fontscript_fout << format("Generate(\"%1%.ttf\")") % (dest_dir / fn) << endl;
+ fontscript_fout << format("Generate(%1%)") % (dest_dir / (fn+".ttf")) << endl;
export_remote_font(fn_id, ".ttf", "truetype", font);
}
diff --git a/src/Param.h b/src/Param.h
index ffeda91..b304da1 100644
--- a/src/Param.h
+++ b/src/Param.h
@@ -16,7 +16,7 @@ struct Param
std::string owner_password, user_password;
std::string input_filename, output_filename;
- std::string dest_dir;
+ std::string dest_dir, tmp_dir;
int first_page, last_page;
diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc
index f697c0d..35b8079 100644
--- a/src/pdf2htmlEX.cc
+++ b/src/pdf2htmlEX.cc
@@ -31,6 +31,7 @@
namespace po = boost::program_options;
using namespace std;
+using namespace boost::filesystem;
Param param;
@@ -122,6 +123,7 @@ po::variables_map parse_options (int argc, char **argv)
("owner-password,o", po::value(¶m.owner_password)->default_value(""), "owner password (for encrypted files)")
("user-password,u", po::value(¶m.user_password)->default_value(""), "user password (for encrypted files)")
("dest-dir", po::value(¶m.dest_dir)->default_value("."), "destination directory")
+ ("tmp-dir", po::value(¶m.tmp_dir)->default_value("/tmp/pdf2htmlEX"), "temporary directory")
("hdpi", po::value(¶m.h_dpi)->default_value(72.0), "horizontal DPI for text")
("vdpi", po::value(¶m.v_dpi)->default_value(72.0), "vertical DPI for text")
("hdpi2", po::value(¶m.h_dpi2)->default_value(144.0), "horizontal DPI for non-text")
@@ -165,6 +167,18 @@ int main(int argc, char **argv)
return -1;
}
+ //prepare the directories
+ try
+ {
+ create_directories(param.dest_dir);
+ create_directories(param.tmp_dir);
+ }
+ catch (const filesystem_error& err)
+ {
+ cerr << err.what() << endl;
+ return -1;
+ }
+
// read config file
globalParams = new GlobalParams();