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

add the 'dest-dir' option

This commit is contained in:
Lu Wang 2012-08-14 18:12:58 +08:00
parent 0182ea303b
commit ed130cee60
4 changed files with 19 additions and 5 deletions

View File

@ -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();

View File

@ -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);
}

View File

@ -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;

View File

@ -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<string>(&param.owner_password)->default_value(""), "owner password (for encrypted files)")
("user-password,u", po::value<string>(&param.user_password)->default_value(""), "user password (for encrypted files)")
("dest-dir", po::value<string>(&param.dest_dir)->default_value("."), "destination directory")
("tmp-dir", po::value<string>(&param.tmp_dir)->default_value("/tmp/pdf2htmlEX"), "temporary directory")
("hdpi", po::value<double>(&param.h_dpi)->default_value(72.0), "horizontal DPI for text")
("vdpi", po::value<double>(&param.v_dpi)->default_value(72.0), "vertical DPI for text")
("hdpi2", po::value<double>(&param.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();