mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
data directory under Windows is located unde data in pdf2htmlEX.exe path by default
This commit is contained in:
parent
8c65a2826b
commit
d4d86ca3fe
@ -41,9 +41,11 @@ using namespace pdf2htmlEX;
|
|||||||
|
|
||||||
Param param;
|
Param param;
|
||||||
ArgParser argparser;
|
ArgParser argparser;
|
||||||
|
string data_dir;
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#ifdef _WIN32
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <libgen.h>
|
||||||
char *mkdtemp(char *tempbuf) {
|
char *mkdtemp(char *tempbuf) {
|
||||||
int rand_value = 0;
|
int rand_value = 0;
|
||||||
char* tempbase = NULL;
|
char* tempbase = NULL;
|
||||||
@ -65,6 +67,7 @@ char *mkdtemp(char *tempbuf) {
|
|||||||
::CreateDirectory(tempbuf, NULL);
|
::CreateDirectory(tempbuf, NULL);
|
||||||
return tempbuf;
|
return tempbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void deprecated_font_suffix(const char * dummy = nullptr)
|
void deprecated_font_suffix(const char * dummy = nullptr)
|
||||||
@ -90,7 +93,11 @@ void show_version_and_exit(const char * dummy = nullptr)
|
|||||||
#if ENABLE_SVG
|
#if ENABLE_SVG
|
||||||
cerr << " cairo " << cairo_version_string() << endl;
|
cerr << " cairo " << cairo_version_string() << endl;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef _WIN32
|
||||||
|
cerr << "Default data-dir: " << data_dir << endl;
|
||||||
|
#else
|
||||||
cerr << "Default data-dir: " << PDF2HTMLEX_DATA_PATH << endl;
|
cerr << "Default data-dir: " << PDF2HTMLEX_DATA_PATH << endl;
|
||||||
|
#endif
|
||||||
cerr << "Supported image format:";
|
cerr << "Supported image format:";
|
||||||
#ifdef ENABLE_LIBPNG
|
#ifdef ENABLE_LIBPNG
|
||||||
cerr << " png";
|
cerr << " png";
|
||||||
@ -137,15 +144,15 @@ void parse_options (int argc, char **argv)
|
|||||||
// pages
|
// pages
|
||||||
.add("first-page,f", ¶m.first_page, 1, "first page to convert")
|
.add("first-page,f", ¶m.first_page, 1, "first page to convert")
|
||||||
.add("last-page,l", ¶m.last_page, numeric_limits<int>::max(), "last page to convert")
|
.add("last-page,l", ¶m.last_page, numeric_limits<int>::max(), "last page to convert")
|
||||||
|
|
||||||
// dimensions
|
// dimensions
|
||||||
.add("zoom", ¶m.zoom, 0, "zoom ratio", true)
|
.add("zoom", ¶m.zoom, 0, "zoom ratio", true)
|
||||||
.add("fit-width", ¶m.fit_width, 0, "fit width to <fp> pixels", true)
|
.add("fit-width", ¶m.fit_width, 0, "fit width to <fp> pixels", true)
|
||||||
.add("fit-height", ¶m.fit_height, 0, "fit height to <fp> pixels", true)
|
.add("fit-height", ¶m.fit_height, 0, "fit height to <fp> pixels", true)
|
||||||
.add("use-cropbox", ¶m.use_cropbox, 1, "use CropBox instead of MediaBox")
|
.add("use-cropbox", ¶m.use_cropbox, 1, "use CropBox instead of MediaBox")
|
||||||
.add("hdpi", ¶m.h_dpi, 144.0, "horizontal resolution for graphics in DPI")
|
.add("hdpi", ¶m.h_dpi, 144.0, "horizontal resolution for graphics in DPI")
|
||||||
.add("vdpi", ¶m.v_dpi, 144.0, "vertical resolution for graphics in DPI")
|
.add("vdpi", ¶m.v_dpi, 144.0, "vertical resolution for graphics in DPI")
|
||||||
|
|
||||||
// output files
|
// output files
|
||||||
.add("embed", "specify which elements should be embedded into output", embed_parser, true)
|
.add("embed", "specify which elements should be embedded into output", embed_parser, true)
|
||||||
.add("embed-css", ¶m.embed_css, 1, "embed CSS files into output")
|
.add("embed-css", ¶m.embed_css, 1, "embed CSS files into output")
|
||||||
@ -162,7 +169,7 @@ void parse_options (int argc, char **argv)
|
|||||||
.add("process-outline", ¶m.process_outline, 1, "show outline in HTML")
|
.add("process-outline", ¶m.process_outline, 1, "show outline in HTML")
|
||||||
.add("printing", ¶m.printing, 1, "enable printing support")
|
.add("printing", ¶m.printing, 1, "enable printing support")
|
||||||
.add("fallback", ¶m.fallback, 0, "output in fallback mode")
|
.add("fallback", ¶m.fallback, 0, "output in fallback mode")
|
||||||
|
|
||||||
// fonts
|
// fonts
|
||||||
.add("embed-external-font", ¶m.embed_external_font, 1, "embed local match for external fonts")
|
.add("embed-external-font", ¶m.embed_external_font, 1, "embed local match for external fonts")
|
||||||
.add("font-format", ¶m.font_format, "woff", "suffix for embedded font files (ttf,otf,woff,svg)")
|
.add("font-format", ¶m.font_format, "woff", "suffix for embedded font files (ttf,otf,woff,svg)")
|
||||||
@ -173,7 +180,7 @@ void parse_options (int argc, char **argv)
|
|||||||
.add("squeeze-wide-glyph", ¶m.squeeze_wide_glyph, 1, "shrink wide glyphs instead of truncating them")
|
.add("squeeze-wide-glyph", ¶m.squeeze_wide_glyph, 1, "shrink wide glyphs instead of truncating them")
|
||||||
.add("override-fstype", ¶m.override_fstype, 0, "clear the fstype bits in TTF/OTF fonts")
|
.add("override-fstype", ¶m.override_fstype, 0, "clear the fstype bits in TTF/OTF fonts")
|
||||||
.add("process-type3", ¶m.process_type3, 0, "convert Type 3 fonts for web (experimental)")
|
.add("process-type3", ¶m.process_type3, 0, "convert Type 3 fonts for web (experimental)")
|
||||||
|
|
||||||
// text
|
// text
|
||||||
.add("heps", ¶m.h_eps, 1.0, "horizontal threshold for merging text, in pixels")
|
.add("heps", ¶m.h_eps, 1.0, "horizontal threshold for merging text, in pixels")
|
||||||
.add("veps", ¶m.v_eps, 1.0, "vertical threshold for merging text, in pixels")
|
.add("veps", ¶m.v_eps, 1.0, "vertical threshold for merging text, in pixels")
|
||||||
@ -185,19 +192,23 @@ void parse_options (int argc, char **argv)
|
|||||||
|
|
||||||
// background image
|
// background image
|
||||||
.add("bg-format", ¶m.bg_format, "png", "specify background image format")
|
.add("bg-format", ¶m.bg_format, "png", "specify background image format")
|
||||||
|
|
||||||
// encryption
|
// encryption
|
||||||
.add("owner-password,o", ¶m.owner_password, "", "owner password (for encrypted files)", true)
|
.add("owner-password,o", ¶m.owner_password, "", "owner password (for encrypted files)", true)
|
||||||
.add("user-password,u", ¶m.user_password, "", "user password (for encrypted files)", true)
|
.add("user-password,u", ¶m.user_password, "", "user password (for encrypted files)", true)
|
||||||
.add("no-drm", ¶m.no_drm, 0, "override document DRM settings")
|
.add("no-drm", ¶m.no_drm, 0, "override document DRM settings")
|
||||||
|
|
||||||
// misc.
|
// misc.
|
||||||
.add("clean-tmp", ¶m.clean_tmp, 1, "remove temporary files after conversion")
|
.add("clean-tmp", ¶m.clean_tmp, 1, "remove temporary files after conversion")
|
||||||
|
#ifdef _WIN32
|
||||||
|
.add("data-dir", ¶m.data_dir, data_dir, "specify data directory")
|
||||||
|
#else
|
||||||
.add("data-dir", ¶m.data_dir, PDF2HTMLEX_DATA_PATH, "specify data directory")
|
.add("data-dir", ¶m.data_dir, PDF2HTMLEX_DATA_PATH, "specify data directory")
|
||||||
|
#endif
|
||||||
// TODO: css drawings are hidden on print, for annot links, need to fix it for other drawings
|
// TODO: css drawings are hidden on print, for annot links, need to fix it for other drawings
|
||||||
// .add("css-draw", ¶m.css_draw, 0, "[experimental and unsupported] CSS drawing")
|
// .add("css-draw", ¶m.css_draw, 0, "[experimental and unsupported] CSS drawing")
|
||||||
.add("debug", ¶m.debug, 0, "print debugging information")
|
.add("debug", ¶m.debug, 0, "print debugging information")
|
||||||
|
|
||||||
// meta
|
// meta
|
||||||
.add("version,v", "print copyright and version info", &show_version_and_exit)
|
.add("version,v", "print copyright and version info", &show_version_and_exit)
|
||||||
.add("help,h", "print usage information", &show_usage_and_exit)
|
.add("help,h", "print usage information", &show_usage_and_exit)
|
||||||
@ -342,6 +353,15 @@ void check_param()
|
|||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
#ifdef _WIN32
|
||||||
|
{
|
||||||
|
// Under Windows, the default data_dir is under /data in the pdf2htmlEX directory
|
||||||
|
stringstream ss;
|
||||||
|
ss << dirname(argv[0]) << "/data";
|
||||||
|
data_dir = ss.str();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
parse_options(argc, argv);
|
parse_options(argc, argv);
|
||||||
check_param();
|
check_param();
|
||||||
|
|
||||||
@ -394,11 +414,11 @@ int main(int argc, char **argv)
|
|||||||
delete ownerPW;
|
delete ownerPW;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!doc->isOk())
|
if (!doc->isOk())
|
||||||
throw "Cannot read the file";
|
throw "Cannot read the file";
|
||||||
|
|
||||||
// check for copy permission
|
// check for copy permission
|
||||||
if (!doc->okToCopy())
|
if (!doc->okToCopy())
|
||||||
{
|
{
|
||||||
if (param.no_drm == 0)
|
if (param.no_drm == 0)
|
||||||
throw "Copying of text from this document is not allowed.";
|
throw "Copying of text from this document is not allowed.";
|
||||||
|
Loading…
Reference in New Issue
Block a user