mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-07-05 09:38:40 +00:00
Merge pull request #78 from jahewson/master
clean-up command-line arguments
This commit is contained in:
commit
2f1c8170bf
182
pdf2htmlEX.1.in
182
pdf2htmlEX.1.in
|
@ -22,49 +22,42 @@ Fonts are extracted form PDF and then embedded into HTML (Type 3 fonts are not s
|
||||||
Other objects are rendered as images and also embedded.
|
Other objects are rendered as images and also embedded.
|
||||||
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --help
|
.B Pages
|
||||||
Show all options
|
|
||||||
.TP
|
|
||||||
.B -v, --version
|
|
||||||
Show copyright and version
|
|
||||||
.TP
|
|
||||||
.B -o, --owner-password <password>
|
|
||||||
Specify owner password
|
|
||||||
.TP
|
|
||||||
.B -u, --user-password <password>
|
|
||||||
Specify user password
|
|
||||||
.TP
|
|
||||||
.B --no-drm <0|1> (Default: 0)
|
|
||||||
Override document DRM settings
|
|
||||||
.TP
|
|
||||||
.B --dest-dir <dir> (Default: .)
|
|
||||||
Specify destination folder
|
|
||||||
.TP
|
|
||||||
.B --data-dir <dir> (Default: @CMAKE_INSTALL_PREFIX@/share/pdf2htmlEX)
|
|
||||||
Specify the folder holding the manifest and other files
|
|
||||||
.TP
|
.TP
|
||||||
.B -f, --first-page <num> (Default: 1)
|
.B -f, --first-page <num> (Default: 1)
|
||||||
Specify the first page to process
|
Specify the first page to process
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B -l, --last-page <num> (Default: last page)
|
.B -l, --last-page <num> (Default: last page)
|
||||||
Specify the last page to process
|
Specify the last page to process
|
||||||
|
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
|
.B Dimensions
|
||||||
|
|
||||||
.B --zoom <ratio>, --fit-width <width>, --fit-height <height>
|
.B --zoom <ratio>, --fit-width <width>, --fit-height <height>
|
||||||
--zoom specifies the zoom factor directly; --fit-width/height specifies the maximum width/height of a page, the values are in pixels.
|
--zoom specifies the zoom factor directly; --fit-width/height specifies the maximum width/height of a page, the values are in pixels.
|
||||||
|
|
||||||
If multiple values are specified, the minimum one will be used.
|
If multiple values are specified, the minimum one will be used.
|
||||||
|
|
||||||
If none is specified, pages will be rendered as 72DPI.
|
If none is specified, pages will be rendered as 72DPI.
|
||||||
.TP
|
|
||||||
.B --hdpi <dpi>, --vdpi <dpi> (Default: 144)
|
|
||||||
Specify the horizontal and vertical DPI for images
|
|
||||||
.TP
|
.TP
|
||||||
.B --use-cropbox <0|1> (Default: 0)
|
.B --use-cropbox <0|1> (Default: 0)
|
||||||
Use CropBox instead of MediaBox for output.
|
Use CropBox instead of MediaBox for output.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --process-nontext <0|1> (Default: 1)
|
.B --hdpi <dpi>, --vdpi <dpi> (Default: 144)
|
||||||
Whether to process non-text objects (as images)
|
Specify the horizontal and vertical DPI for images
|
||||||
|
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B Output Files
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --single-html <0|1> (Default: 1)
|
.B --single-html <0|1> (Default: 1)
|
||||||
Whether to embed everything into one HTML file.
|
Whether to embed everything into one HTML file.
|
||||||
|
@ -74,6 +67,7 @@ If switched off, there will be several files generated along with the HTML file
|
||||||
Note that the outline will always be embedded into the main HTML file no matter if this switch is on or not.
|
Note that the outline will always be embedded into the main HTML file no matter if this switch is on or not.
|
||||||
And only when this switch is off will there be a separate .outline file contains the outline.
|
And only when this switch is off will there be a separate .outline file contains the outline.
|
||||||
You need to modify the manifest if you do not want outline embedded.
|
You need to modify the manifest if you do not want outline embedded.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --split-pages <0|1> (Default: 0)
|
.B --split-pages <0|1> (Default: 0)
|
||||||
If turned on, pages will be stored into separated files named as <output-filename>0.page, <output-filename>1.page, ...
|
If turned on, pages will be stored into separated files named as <output-filename>0.page, <output-filename>1.page, ...
|
||||||
|
@ -81,6 +75,27 @@ If turned on, pages will be stored into separated files named as <output-filenam
|
||||||
Also the css and outline will be stored into separated files, and the will be no <output-filename>.html generated.
|
Also the css and outline will be stored into separated files, and the will be no <output-filename>.html generated.
|
||||||
|
|
||||||
This switch is useful if you want pages to be loaded separately & dynamically -- in which case you need to compose the page yourself, and a supporting backend might be necessary.
|
This switch is useful if you want pages to be loaded separately & dynamically -- in which case you need to compose the page yourself, and a supporting backend might be necessary.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --dest-dir <dir> (Default: .)
|
||||||
|
Specify destination folder
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --css-filename <filename> (Default: <none>)
|
||||||
|
Specify the filename of the generated css file, if not embedded.
|
||||||
|
|
||||||
|
If it's empty, the file name will be determined automatically.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --outline-filename <filename> (Default: <none>)
|
||||||
|
Specify the filename of the generated outline file, if not embedded.
|
||||||
|
|
||||||
|
If it's empty, the file name will be determined automatically.
|
||||||
|
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B Fonts
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --embed-base-font <0|1> (Default: 1)
|
.B --embed-base-font <0|1> (Default: 1)
|
||||||
Whether to embed base 14 fonts.
|
Whether to embed base 14 fonts.
|
||||||
|
@ -88,20 +103,57 @@ Whether to embed base 14 fonts.
|
||||||
There are several base font defined in PDF standards, which are supposed to be provided by the PDF reader.
|
There are several base font defined in PDF standards, which are supposed to be provided by the PDF reader.
|
||||||
|
|
||||||
If this switch is on, local matched font will be used and embedded; otherwise only font names are exported such that web browsers may try to find proper fonts themselves.
|
If this switch is on, local matched font will be used and embedded; otherwise only font names are exported such that web browsers may try to find proper fonts themselves.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --embed-external-font <0|1> (Default: 0)
|
.B --embed-external-font <0|1> (Default: 0)
|
||||||
Similar as above but for non-base fonts.
|
Similar as above but for non-base fonts.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --font-suffix <suffix> (Default: .ttf), --font-format <format> (Default: truetype)
|
||||||
|
Specify the suffix and format of fonts extracted from the PDF file. They should be consistent.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --decompose-ligature <0|1> (Default: 0)
|
.B --decompose-ligature <0|1> (Default: 0)
|
||||||
Decompose ligatures. For example 'fi' -> 'f''i'.
|
Decompose ligatures. For example 'fi' -> 'f''i'.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --remove-unused-glyph <0|1> (Default: 1)
|
||||||
|
If set to 1, remove unused glyphs in embedded fonts in order to reduce the file size.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --auto-hint <0|1> (Default: 0)
|
||||||
|
If set to 1, hints will be generated for the fonts using fontforge.
|
||||||
|
|
||||||
|
This may be preceded by --external-hint-tool.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --external-hint-tool <tool> (Default: <none>)
|
||||||
|
If specified, the tool will be called in order to enhanced hinting for fonts, this will precede --auto-hint.
|
||||||
|
|
||||||
|
The tool will be called as '<tool> <in.suffix> <out.suffix>', where suffix will be the same as specified for --font-suffix.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --stretch-narrow-glyph <0|1> (Default: 0)
|
||||||
|
If set to 1, glyphs narrower than described in PDF will be stretched; otherwise space will be padded to the right of the glyphs
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --squeeze-wide-glyph <0|1> (Default: 1)
|
||||||
|
If set to 1, glyphs wider than described in PDF will be squeezed; otherwise it will be truncated.
|
||||||
|
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B Text
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --heps <len>, --veps <len> (Default: 1)
|
.B --heps <len>, --veps <len> (Default: 1)
|
||||||
Specify the maximum tolerable horizontal/vertical offset (in pixels).
|
Specify the maximum tolerable horizontal/vertical offset (in pixels).
|
||||||
|
|
||||||
pdf2htmlEX would try to optimize the generated HTML file moving Text within this distance.
|
pdf2htmlEX would try to optimize the generated HTML file moving Text within this distance.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --space-threshold <ratio> (Default: 1.0/6)
|
.B --space-threshold <ratio> (Default: 1.0/6)
|
||||||
pdf2htmlEX would insert a whitespace character ' ' if the distance between two consecutive letters in the same line is wider than ratio * font_size.
|
pdf2htmlEX would insert a whitespace character ' ' if the distance between two consecutive letters in the same line is wider than ratio * font_size.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --font-size-multiplier <ratio> (Default: 4.0)
|
.B --font-size-multiplier <ratio> (Default: 4.0)
|
||||||
Many web browsers limit the minimum font size, and many would round the given font size, which results in incorrect rendering.
|
Many web browsers limit the minimum font size, and many would round the given font size, which results in incorrect rendering.
|
||||||
|
@ -109,11 +161,13 @@ Many web browsers limit the minimum font size, and many would round the given fo
|
||||||
Specify a ratio greater than 1 would resolve this issue, however it might freeze some browsers.
|
Specify a ratio greater than 1 would resolve this issue, however it might freeze some browsers.
|
||||||
|
|
||||||
For some versions of Firefox, however, there will be a problem when the font size is too large, in which case a smaller value should be specified here.
|
For some versions of Firefox, however, there will be a problem when the font size is too large, in which case a smaller value should be specified here.
|
||||||
.TP
|
|
||||||
.B --auto-hint <0|1> (Default: 0)
|
|
||||||
If set to 1, hints will be generated for the fonts using fontforge.
|
|
||||||
|
|
||||||
This may be preceded by --external-hint-tool.
|
.TP
|
||||||
|
.B --space-as-offset <0|1> (Default: 0)
|
||||||
|
Treat space characters as offsets, which may increase the size of the output.
|
||||||
|
|
||||||
|
Turn it on if space characters are not displayed correctly, or you want to remove positional spaces.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --tounicode <-1|0|1> (Default: 0)
|
.B --tounicode <-1|0|1> (Default: 0)
|
||||||
A ToUnicode map may be provided for each font in PDF which indicates the 'meaning' of the characters. However often there is better "ToUnicode" info in Type 0/1 fonts, and sometimes the ToUnicode map provided is wrong.
|
A ToUnicode map may be provided for each font in PDF which indicates the 'meaning' of the characters. However often there is better "ToUnicode" info in Type 0/1 fonts, and sometimes the ToUnicode map provided is wrong.
|
||||||
|
@ -123,40 +177,60 @@ If this value is set to 1, the ToUnicode Map is always applied, if provided in P
|
||||||
If set to -1, a customized map is used such that rendering will be correct in HTML (visually the same), but you may not get correct characters by select & copy & paste.
|
If set to -1, a customized map is used such that rendering will be correct in HTML (visually the same), but you may not get correct characters by select & copy & paste.
|
||||||
|
|
||||||
If set to 0, pdf2htmlEX would try its best to balance the two methods above.
|
If set to 0, pdf2htmlEX would try its best to balance the two methods above.
|
||||||
.TP
|
|
||||||
.B --space-as-offset <0|1> (Default: 0)
|
|
||||||
Treat space characters as offsets, which may increase the size of the output.
|
|
||||||
|
|
||||||
Turn it on if space characters are not displayed correctly, or you want to remove positional spaces.
|
|
||||||
.TP
|
|
||||||
.B --stretch-narrow-glyph <0|1> (Default: 0)
|
|
||||||
If set to 1, glyphs narrower than described in PDF will be stretched; otherwise space will be padded to the right of the glyphs
|
|
||||||
.TP
|
|
||||||
.B --squeeze-wide-glyph <0|1> (Default: 1)
|
|
||||||
If set to 1, glyphs wider than described in PDF will be squeezed; otherwise it will be truncated.
|
|
||||||
.TP
|
|
||||||
.B --remove-unused-glyph <0|1> (Default: 1)
|
|
||||||
If set to 1, remove unused glyphs in embedded fonts in order to reduce the file size.
|
|
||||||
.TP
|
|
||||||
.B --font-suffix <suffix> (Default: .ttf), --font-format <format> (Default: truetype)
|
|
||||||
Specify the suffix and format of fonts extracted from the PDF file. They should be consistent.
|
|
||||||
.TP
|
|
||||||
.B --external-hint-tool <tool> (Default: <none>)
|
|
||||||
If specified, the tool will be called in order to enhanced hinting for fonts, this will precede --auto-hint.
|
|
||||||
|
|
||||||
The tool will be called as '<tool> <in.suffix> <out.suffix>', where suffix will be the same as specified for --font-suffix.
|
|
||||||
.TP
|
.TP
|
||||||
.B --css-filename <filename> (Default: <none>)
|
.B Encryption
|
||||||
Specify the filename of the generated css file, if not embedded.
|
|
||||||
|
|
||||||
If it's empty, the file name will be determined automatically.
|
|
||||||
.TP
|
.TP
|
||||||
.B --debug <0|1> (Default: 0)
|
.B -o, --owner-password <password>
|
||||||
Show debug information.
|
Specify owner password
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B -u, --user-password <password>
|
||||||
|
Specify user password
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --no-drm <0|1> (Default: 0)
|
||||||
|
Override document DRM settings
|
||||||
|
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B Misc.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --clean-tmp <0|1> (Default: 1)
|
.B --clean-tmp <0|1> (Default: 1)
|
||||||
If switched off, intermediate files won't be cleaned in the end.
|
If switched off, intermediate files won't be cleaned in the end.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --process-nontext <0|1> (Default: 1)
|
||||||
|
Whether to process non-text objects (as images)
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --data-dir <dir> (Default: @CMAKE_INSTALL_PREFIX@/share/pdf2htmlEX)
|
||||||
|
Specify the folder holding the manifest and other files
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --css-draw <0|1> (Default: 0)
|
||||||
|
Experimental and unsupported CSS drawing
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --debug <0|1> (Default: 0)
|
||||||
|
Print debug information.
|
||||||
|
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B Meta
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B -v, --version
|
||||||
|
Print copyright and version info
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B --help
|
||||||
|
Print usage information
|
||||||
|
|
||||||
|
|
||||||
.SH EXAMPLE
|
.SH EXAMPLE
|
||||||
.TP
|
.TP
|
||||||
.B pdf2htmlEX /path/to/file.pdf
|
.B pdf2htmlEX /path/to/file.pdf
|
||||||
|
|
82
src/Param.h
82
src/Param.h
|
@ -15,64 +15,56 @@ namespace pdf2htmlEX {
|
||||||
|
|
||||||
struct Param
|
struct Param
|
||||||
{
|
{
|
||||||
// PDF stuff
|
// pages
|
||||||
std::string owner_password, user_password;
|
|
||||||
std::string input_filename, output_filename;
|
|
||||||
int no_drm;
|
|
||||||
|
|
||||||
// path
|
|
||||||
std::string dest_dir, tmp_dir, data_dir;
|
|
||||||
|
|
||||||
// normal parameters
|
|
||||||
int first_page, last_page;
|
int first_page, last_page;
|
||||||
|
|
||||||
|
// dimensions
|
||||||
double zoom;
|
double zoom;
|
||||||
double fit_width, fit_height;
|
double fit_width, fit_height;
|
||||||
double h_dpi, v_dpi;
|
|
||||||
int use_cropbox;
|
int use_cropbox;
|
||||||
|
double h_dpi, v_dpi;
|
||||||
|
|
||||||
int process_nontext;
|
// output files
|
||||||
int single_html;
|
int single_html;
|
||||||
int split_pages;
|
int split_pages;
|
||||||
int embed_base_font;
|
std::string dest_dir;
|
||||||
int embed_external_font;
|
|
||||||
int decompose_ligature;
|
|
||||||
|
|
||||||
// Advanced tweak
|
|
||||||
/*
|
|
||||||
* Position & Size
|
|
||||||
*/
|
|
||||||
double h_eps, v_eps;
|
|
||||||
double space_threshold;
|
|
||||||
double font_size_multiplier;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Font
|
|
||||||
*/
|
|
||||||
int auto_hint;
|
|
||||||
int tounicode;
|
|
||||||
int space_as_offset;
|
|
||||||
int stretch_narrow_glyph;
|
|
||||||
int squeeze_wide_glyph;
|
|
||||||
int remove_unused_glyph;
|
|
||||||
|
|
||||||
std::string font_suffix, font_format;
|
|
||||||
std::string external_hint_tool;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Output
|
|
||||||
*/
|
|
||||||
std::string css_filename;
|
std::string css_filename;
|
||||||
std::string outline_filename;
|
std::string outline_filename;
|
||||||
|
|
||||||
/*
|
// fonts
|
||||||
* Debug
|
int embed_base_font;
|
||||||
*/
|
int embed_external_font;
|
||||||
int debug;
|
std::string font_suffix, font_format;
|
||||||
int clean_tmp;
|
int decompose_ligature;
|
||||||
|
int remove_unused_glyph;
|
||||||
|
int auto_hint;
|
||||||
|
std::string external_hint_tool;
|
||||||
|
int stretch_narrow_glyph;
|
||||||
|
int squeeze_wide_glyph;
|
||||||
|
|
||||||
// experimental
|
// text
|
||||||
|
double h_eps, v_eps;
|
||||||
|
double space_threshold;
|
||||||
|
double font_size_multiplier;
|
||||||
|
int space_as_offset;
|
||||||
|
int tounicode;
|
||||||
|
|
||||||
|
// encryption
|
||||||
|
std::string owner_password, user_password;
|
||||||
|
int no_drm;
|
||||||
|
|
||||||
|
// misc.
|
||||||
|
int clean_tmp;
|
||||||
|
int process_nontext;
|
||||||
|
std::string data_dir;
|
||||||
int css_draw;
|
int css_draw;
|
||||||
|
int debug;
|
||||||
|
|
||||||
|
// non-optional
|
||||||
|
std::string input_filename, output_filename;
|
||||||
|
|
||||||
|
// not a paramater
|
||||||
|
std::string tmp_dir;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pdf2htmlEX
|
} // namespace pdf2htmlEX
|
||||||
|
|
|
@ -36,13 +36,8 @@ ArgParser argparser;
|
||||||
|
|
||||||
void show_usage_and_exit(const char * dummy = nullptr)
|
void show_usage_and_exit(const char * dummy = nullptr)
|
||||||
{
|
{
|
||||||
cerr << "Usage: pdf2htmlEX [Options] <input.pdf> [<output.html>]" << endl;
|
cerr << "Usage: pdf2htmlEX [options] <input.pdf> [<output.html>]" << endl;
|
||||||
cerr << endl;
|
|
||||||
cerr << "Options:" << endl;
|
|
||||||
argparser.show_usage(cerr);
|
argparser.show_usage(cerr);
|
||||||
cerr << endl;
|
|
||||||
cerr << "Run 'man pdf2htmlEX' for detailed information" << endl;
|
|
||||||
cerr << endl;
|
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,53 +54,61 @@ void show_version_and_exit(const char * dummy = nullptr)
|
||||||
void parse_options (int argc, char **argv)
|
void parse_options (int argc, char **argv)
|
||||||
{
|
{
|
||||||
argparser
|
argparser
|
||||||
.add("help,h", "show all options", &show_usage_and_exit)
|
// pages
|
||||||
.add("version,v", "show copyright and version info", &show_version_and_exit)
|
.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")
|
||||||
|
|
||||||
|
// dimensions
|
||||||
|
.add("zoom", ¶m.zoom, 0, "zoom ratio", nullptr, true)
|
||||||
|
.add("fit-width", ¶m.fit_width, 0, "fit width to <fp> pixels", nullptr, true)
|
||||||
|
.add("fit-height", ¶m.fit_height, 0, "fit height to <fp> pixels", nullptr, true)
|
||||||
|
.add("use-cropbox", ¶m.use_cropbox, 0, "use CropBox instead of MediaBox")
|
||||||
|
.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")
|
||||||
|
|
||||||
|
// output files
|
||||||
|
.add("single-html", ¶m.single_html, 1, "generate a single HTML file")
|
||||||
|
.add("split-pages", ¶m.split_pages, 0, "split pages into separate files")
|
||||||
|
.add("dest-dir", ¶m.dest_dir, ".", "specify destination directory")
|
||||||
|
.add("css-filename", ¶m.css_filename, "", "filename of the generated css file")
|
||||||
|
.add("outline-filename", ¶m.outline_filename, "", "filename of the generated outline file")
|
||||||
|
|
||||||
|
// fonts
|
||||||
|
.add("embed-base-font", ¶m.embed_base_font, 0, "embed local match for standard 14 fonts")
|
||||||
|
.add("embed-external-font", ¶m.embed_external_font, 0, "embed local match for external fonts")
|
||||||
|
.add("font-suffix", ¶m.font_suffix, ".ttf", "suffix for embedded font files (.ttf,.otf,.woff,.svg)")
|
||||||
|
.add("font-format", ¶m.font_format, "opentype", "CSS @font-face format for embedded fonts")
|
||||||
|
.add("decompose-ligature", ¶m.decompose_ligature, 0, "decompose ligatures, such as \uFB01 -> fi")
|
||||||
|
.add("remove-unused-glyph", ¶m.remove_unused_glyph, 1, "remove unused glyphs in embedded fonts")
|
||||||
|
.add("auto-hint", ¶m.auto_hint, 0, "use fontforge autohint on fonts without hints")
|
||||||
|
.add("external-hint-tool", ¶m.external_hint_tool, "", "external tool for hinting fonts (overrides --auto-hint)")
|
||||||
|
.add("stretch-narrow-glyph", ¶m.stretch_narrow_glyph, 0, "stretch narrow glyphs instead of padding them")
|
||||||
|
.add("squeeze-wide-glyph", ¶m.squeeze_wide_glyph, 1, "shrink wide glyphs instead of truncating them")
|
||||||
|
|
||||||
|
// text
|
||||||
|
.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("space-threshold", ¶m.space_threshold, (1.0/8), "word break threshold (threshold * em)")
|
||||||
|
.add("font-size-multiplier", ¶m.font_size_multiplier, 4.0, "a value greater than 1 increases the rendering accuracy")
|
||||||
|
.add("space-as-offset", ¶m.space_as_offset, 0, "treat space characters as offsets")
|
||||||
|
.add("tounicode", ¶m.tounicode, 0, "how to handle ToUnicode CMaps (0=auto, 1=force, -1=ignore)")
|
||||||
|
|
||||||
|
// encryption
|
||||||
.add("owner-password,o", ¶m.owner_password, "", "owner password (for encrypted files)", nullptr, true)
|
.add("owner-password,o", ¶m.owner_password, "", "owner password (for encrypted files)", nullptr, true)
|
||||||
.add("user-password,u", ¶m.user_password, "", "user password (for encrypted files)", nullptr, true)
|
.add("user-password,u", ¶m.user_password, "", "user password (for encrypted files)", nullptr, true)
|
||||||
.add("no-drm", ¶m.no_drm, 0, "override document DRM settings")
|
.add("no-drm", ¶m.no_drm, 0, "override document DRM settings")
|
||||||
|
|
||||||
.add("dest-dir", ¶m.dest_dir, ".", "specify destination directory")
|
// misc.
|
||||||
|
.add("clean-tmp", ¶m.clean_tmp, 1, "remove temporary files after conversion")
|
||||||
|
.add("process-nontext", ¶m.process_nontext, 1, "render graphics in addition to text")
|
||||||
.add("data-dir", ¶m.data_dir, PDF2HTMLEX_DATA_PATH, "specify data directory")
|
.add("data-dir", ¶m.data_dir, PDF2HTMLEX_DATA_PATH, "specify data directory")
|
||||||
|
.add("css-draw", ¶m.css_draw, 0, "[experimental and unsupported] CSS drawing")
|
||||||
|
.add("debug", ¶m.debug, 0, "print debugging information")
|
||||||
|
|
||||||
.add("first-page,f", ¶m.first_page, 1, "first page to process")
|
// meta
|
||||||
.add("last-page,l", ¶m.last_page, numeric_limits<int>::max(), "last page to process")
|
.add("version,v", "print copyright and version info", &show_version_and_exit)
|
||||||
|
.add("help,h", "print usage information", &show_usage_and_exit)
|
||||||
|
|
||||||
.add("zoom", ¶m.zoom, 0, "zoom ratio", nullptr, true)
|
|
||||||
.add("fit-width", ¶m.fit_width, 0, "fit width to <arg> pixels", nullptr, true)
|
|
||||||
.add("fit-height", ¶m.fit_height, 0, "fit height to <arg> pixels", nullptr, true)
|
|
||||||
.add("hdpi", ¶m.h_dpi, 144.0, "horizontal DPI for non-text")
|
|
||||||
.add("vdpi", ¶m.v_dpi, 144.0, "vertical DPI for non-text")
|
|
||||||
.add("use-cropbox", ¶m.use_cropbox, 0, "use CropBox instead of MediaBox")
|
|
||||||
|
|
||||||
.add("process-nontext", ¶m.process_nontext, 1, "process nontext objects")
|
|
||||||
.add("single-html", ¶m.single_html, 1, "combine everything into one single HTML file")
|
|
||||||
.add("split-pages", ¶m.split_pages, 0, "split pages into separated files")
|
|
||||||
.add("embed-base-font", ¶m.embed_base_font, 0, "embed local matched font for base 14 fonts in the PDF file")
|
|
||||||
.add("embed-external-font", ¶m.embed_external_font, 0, "embed local matched font for external fonts in the PDF file")
|
|
||||||
.add("decompose-ligature", ¶m.decompose_ligature, 0, "decompose ligatures, for example 'fi' -> 'f''i'")
|
|
||||||
|
|
||||||
.add("heps", ¶m.h_eps, 1.0, "max tolerated horizontal offset (in pixels)")
|
|
||||||
.add("veps", ¶m.v_eps, 1.0, "max tolerated vertical offset (in pixels)")
|
|
||||||
.add("space-threshold", ¶m.space_threshold, (1.0/8), "distance no thiner than (threshold * em) will be considered as a space character")
|
|
||||||
.add("font-size-multiplier", ¶m.font_size_multiplier, 4.0, "setting a value greater than 1 would increase the rendering accuracy")
|
|
||||||
.add("auto-hint", ¶m.auto_hint, 0, "Whether to generate hints for fonts")
|
|
||||||
.add("tounicode", ¶m.tounicode, 0, "Specify how to deal with ToUnicode map, 0 for auto, 1 for forced, -1 for disabled")
|
|
||||||
.add("space-as-offset", ¶m.space_as_offset, 0, "treat space characters as offsets")
|
|
||||||
.add("stretch-narrow-glyph", ¶m.stretch_narrow_glyph, 0, "stretch narrow glyphs instead of padding space")
|
|
||||||
.add("squeeze-wide-glyph", ¶m.squeeze_wide_glyph, 1, "squeeze wide glyphs instead of truncating")
|
|
||||||
.add("remove-unused-glyph", ¶m.remove_unused_glyph, 1, "remove unused glyphs in embedded fonts")
|
|
||||||
|
|
||||||
.add("font-suffix", ¶m.font_suffix, ".ttf", "suffix for extracted font files")
|
|
||||||
.add("font-format", ¶m.font_format, "opentype", "format for extracted font files")
|
|
||||||
.add("external-hint-tool", ¶m.external_hint_tool, "", "external tool for hintting fonts.(overrides --auto-hint)")
|
|
||||||
.add("css-filename", ¶m.css_filename, "", "Specify the file name of the generated css file")
|
|
||||||
.add("outline-filename", ¶m.outline_filename, "", "Specify the file name of the generated outline file")
|
|
||||||
|
|
||||||
.add("debug", ¶m.debug, 0, "output debug information")
|
|
||||||
.add("clean-tmp", ¶m.clean_tmp, 1, "clean temporary files after processing")
|
|
||||||
.add("css-draw", ¶m.css_draw, 0, "[Experimental and Unsupported] CSS Drawing")
|
|
||||||
.add("", ¶m.input_filename, "", "")
|
.add("", ¶m.input_filename, "", "")
|
||||||
.add("", ¶m.output_filename, "", "")
|
.add("", ¶m.output_filename, "", "")
|
||||||
;
|
;
|
||||||
|
@ -141,8 +144,7 @@ int main(int argc, char **argv)
|
||||||
parse_options(argc, argv);
|
parse_options(argc, argv);
|
||||||
if (param.input_filename == "")
|
if (param.input_filename == "")
|
||||||
{
|
{
|
||||||
cerr << "Missing input filename" << endl;
|
show_usage_and_exit();
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//prepare the directories
|
//prepare the directories
|
||||||
|
|
|
@ -164,6 +164,6 @@ ArgParser::ArgEntryBase::ArgEntryBase(const char * name, const char * descriptio
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const int ArgParser::arg_col_width = 40;
|
const int ArgParser::arg_col_width = 31;
|
||||||
|
|
||||||
} // namespace pdf2htmlEX
|
} // namespace pdf2htmlEX
|
||||||
|
|
|
@ -39,6 +39,23 @@ void dump_value(std::ostream & out, const T & v)
|
||||||
|
|
||||||
extern void dump_value(std::ostream & out, const std::string & v);
|
extern void dump_value(std::ostream & out, const std::string & v);
|
||||||
|
|
||||||
|
// type names helper
|
||||||
|
template<typename>
|
||||||
|
struct type_name {
|
||||||
|
static char const* value() { return "unknown"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct type_name<int> {
|
||||||
|
static char const* value() { return "int"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct type_name<double> {
|
||||||
|
static char const* value() { return "fp"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<> struct type_name<std::string> {
|
||||||
|
static char const* value() { return "string"; }
|
||||||
|
};
|
||||||
|
|
||||||
class ArgParser
|
class ArgParser
|
||||||
{
|
{
|
||||||
|
@ -161,13 +178,7 @@ void ArgParser::ArgEntry<T, Tv>::show_usage(std::ostream & out) const
|
||||||
|
|
||||||
if(need_arg)
|
if(need_arg)
|
||||||
{
|
{
|
||||||
sout << " <arg>";
|
sout << " <" << type_name<T>::value() << ">";
|
||||||
if(!dont_show_default)
|
|
||||||
{
|
|
||||||
sout << " (=";
|
|
||||||
dump_value(sout, default_value);
|
|
||||||
sout << ")";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string s = sout.str();
|
std::string s = sout.str();
|
||||||
|
@ -176,7 +187,16 @@ void ArgParser::ArgEntry<T, Tv>::show_usage(std::ostream & out) const
|
||||||
for(int i = s.size(); i < arg_col_width; ++i)
|
for(int i = s.size(); i < arg_col_width; ++i)
|
||||||
out << ' ';
|
out << ' ';
|
||||||
|
|
||||||
out << " " << description << std::endl;
|
out << " " << description;
|
||||||
|
|
||||||
|
if(need_arg && !dont_show_default)
|
||||||
|
{
|
||||||
|
out << " (default: ";
|
||||||
|
dump_value(out, default_value);
|
||||||
|
out << ")";
|
||||||
|
}
|
||||||
|
|
||||||
|
out << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ArgParser
|
} // namespace ArgParser
|
||||||
|
|
Loading…
Reference in New Issue
Block a user