From 4d3f4655e596d6ff0daec215a77c46a2c04f2905 Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Tue, 30 Apr 2013 19:07:55 +0800 Subject: [PATCH] new option --printing --- pdf2htmlEX.1.in | 18 ++++++++++++------ src/HTMLRenderer/general.cc | 35 +++++++++++++++++++---------------- src/Param.h | 1 + src/pdf2htmlEX.cc | 1 + 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/pdf2htmlEX.1.in b/pdf2htmlEX.1.in index f426509..99d193b 100644 --- a/pdf2htmlEX.1.in +++ b/pdf2htmlEX.1.in @@ -43,7 +43,7 @@ If multiple values are specified, the minimum one will be used. If none is specified, pages will be rendered as 72DPI. .TP -.B --use-cropbox <0|1> (Default: 0) +.B --use-cropbox <0|1> (Default: 1) Use CropBox instead of MediaBox for output. .TP @@ -95,7 +95,7 @@ This switch is useful if you want pages to be loaded separately & dynamically -- .TP .B --dest-dir (Default: .) -Specify destination folder +Specify destination folder. .TP .B --css-filename (Default: ) @@ -109,10 +109,6 @@ Specify the filename of the generated outline file, if not embedded. If it's empty, the file name will be determined automatically. -.TP -.B --fallback <0|1> (Deafult: 0) -Output in fallback mode, for better accuracy and browser compatibility, but the size becomes larger. - .TP .B --process-nontext <0|1> (Default: 1) Whether to process non-text objects (as images) @@ -121,6 +117,14 @@ Whether to process non-text objects (as images) .B --process-outline <0|1> (Default: 1) Whether to show outline in the generated HTML +.TP +.B --printing <0|1> (Default: 1) +Enable printing support. Disabling this option may reduce the size of CSS. + +.TP +.B --fallback <0|1> (Deafult: 0) +Output in fallback mode, for better accuracy and browser compatibility, but the size becomes larger. + .SS Fonts .TP @@ -148,6 +152,8 @@ Decompose ligatures. For example 'fi' -> 'f''i'. .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. +Try turning it off if you encounter segmentation fault or debris-like fonts. + .TP .B --auto-hint <0|1> (Default: 0) If set to 1, hints will be generated for the fonts using fontforge. diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc index bdfc24f..03eeaa7 100644 --- a/src/HTMLRenderer/general.cc +++ b/src/HTMLRenderer/general.cc @@ -460,22 +460,25 @@ void HTMLRenderer::dump_css (void) all_manager.bgimage_size .dump_css(f_css.fs); // print css - double ps = print_scale(); - f_css.fs << CSS::PRINT_ONLY << "{" << endl; - all_manager.transform_matrix.dump_print_css(f_css.fs, ps); - all_manager.vertical_align .dump_print_css(f_css.fs, ps); - all_manager.letter_space .dump_print_css(f_css.fs, ps); - all_manager.stroke_color .dump_print_css(f_css.fs, ps); - all_manager.word_space .dump_print_css(f_css.fs, ps); - all_manager.whitespace .dump_print_css(f_css.fs, ps); - all_manager.fill_color .dump_print_css(f_css.fs, ps); - all_manager.font_size .dump_print_css(f_css.fs, ps); - all_manager.bottom .dump_print_css(f_css.fs, ps); - all_manager.height .dump_print_css(f_css.fs, ps); - all_manager.width .dump_print_css(f_css.fs, ps); - all_manager.left .dump_print_css(f_css.fs, ps); - all_manager.bgimage_size .dump_print_css(f_css.fs, ps); - f_css.fs << "}" << endl; + if(param.printing) + { + double ps = print_scale(); + f_css.fs << CSS::PRINT_ONLY << "{" << endl; + all_manager.transform_matrix.dump_print_css(f_css.fs, ps); + all_manager.vertical_align .dump_print_css(f_css.fs, ps); + all_manager.letter_space .dump_print_css(f_css.fs, ps); + all_manager.stroke_color .dump_print_css(f_css.fs, ps); + all_manager.word_space .dump_print_css(f_css.fs, ps); + all_manager.whitespace .dump_print_css(f_css.fs, ps); + all_manager.fill_color .dump_print_css(f_css.fs, ps); + all_manager.font_size .dump_print_css(f_css.fs, ps); + all_manager.bottom .dump_print_css(f_css.fs, ps); + all_manager.height .dump_print_css(f_css.fs, ps); + all_manager.width .dump_print_css(f_css.fs, ps); + all_manager.left .dump_print_css(f_css.fs, ps); + all_manager.bgimage_size .dump_print_css(f_css.fs, ps); + f_css.fs << "}" << endl; + } } void HTMLRenderer::embed_file(ostream & out, const string & path, const string & type, bool copy) diff --git a/src/Param.h b/src/Param.h index 3362d48..0178ec3 100644 --- a/src/Param.h +++ b/src/Param.h @@ -32,6 +32,7 @@ struct Param std::string outline_filename; int process_nontext; int process_outline; + int printing; int fallback; // fonts diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index d2cdccf..5283c35 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -77,6 +77,7 @@ void parse_options (int argc, char **argv) .add("outline-filename", ¶m.outline_filename, "", "filename of the generated outline file") .add("process-nontext", ¶m.process_nontext, 1, "render graphics in addition to text") .add("process-outline", ¶m.process_outline, 1, "show outline in HTML") + .add("printing", ¶m.printing, 1, "enable printing support") .add("fallback", ¶m.fallback, 0, "output in fallback mode") // fonts