From ba1358c241a94e1b5a917ddf3099a9b2e69074e8 Mon Sep 17 00:00:00 2001 From: Duan Yao Date: Wed, 11 Jun 2014 23:20:09 +0800 Subject: [PATCH] Improve help texts for --svg-node-count-limit and --svg-embed-bitmap; rename --svg-nodes-limit to --svg-node-count-limit. --- pdf2htmlEX.1.in | 10 ++++++++++ src/BackgroundRenderer/BackgroundRenderer.cc | 2 +- src/BackgroundRenderer/CairoBackgroundRenderer.cc | 8 ++++---- src/Param.h | 2 +- src/pdf2htmlEX.cc | 7 +++---- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pdf2htmlEX.1.in b/pdf2htmlEX.1.in index 8b01c34..b63b1d9 100644 --- a/pdf2htmlEX.1.in +++ b/pdf2htmlEX.1.in @@ -248,6 +248,16 @@ If set to 1, pdf2htmlEX will try to reduce the number of HTML elements used for .B --bg-format (Default: png) Specify the background image format. Run `pdf2htmlEX -v` to check all supported formats. +.TP +.B --svg-node-count-limit (Default: -1) +If node count in a svg background image exceeds this limit, fall back this page to bitmap background; negative value means no limit. +This option is only useful when '--bg-format svg' is specified. Note that node count in svg is just calculated approximately. + +.TP +.B --svg-embed-bitmap <0|1> (Default: 1) +Whether embed bitmaps in svg background image. 1: embed bitmaps in svg background; 0: dump bitmaps to external files if possible. +JPEG images in a PDF are most possibly dumped. This option is only useful when '--bg-format svg' is specified. + .SS PDF Protection .TP diff --git a/src/BackgroundRenderer/BackgroundRenderer.cc b/src/BackgroundRenderer/BackgroundRenderer.cc index 5c37fde..1ae298c 100644 --- a/src/BackgroundRenderer/BackgroundRenderer.cc +++ b/src/BackgroundRenderer/BackgroundRenderer.cc @@ -44,7 +44,7 @@ BackgroundRenderer * BackgroundRenderer::getBackgroundRenderer(const std::string BackgroundRenderer * BackgroundRenderer::getFallbackBackgroundRenderer(HTMLRenderer * html_renderer, const Param & param) { - if (param.bg_format == "svg" && param.svg_nodes_limit > 0) + if (param.bg_format == "svg" && param.svg_node_count_limit >= 0) return new SplashBackgroundRenderer("", html_renderer, param); return nullptr; } diff --git a/src/BackgroundRenderer/CairoBackgroundRenderer.cc b/src/BackgroundRenderer/CairoBackgroundRenderer.cc index 56c8596..4279d3a 100644 --- a/src/BackgroundRenderer/CairoBackgroundRenderer.cc +++ b/src/BackgroundRenderer/CairoBackgroundRenderer.cc @@ -130,7 +130,7 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno) } //check node count in the svg file, fall back to bitmap_renderer if necessary. - if (param.svg_nodes_limit > 0) + if (param.svg_node_count_limit >= 0) { int n = 0; char c; @@ -140,7 +140,7 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno) { if (c == '<') ++n; - if (n > param.svg_nodes_limit) + if (n > param.svg_node_count_limit) { html_renderer->tmp_files.add(fn); return false; @@ -149,8 +149,8 @@ bool CairoBackgroundRenderer::render_page(PDFDoc * doc, int pageno) } // the svg file is actually used, so add its bitmaps' ref count. - for (auto i = bitmaps_in_current_page.begin(); i != bitmaps_in_current_page.end(); i++) - ++bitmaps_ref_count[*i]; + for (auto itr = bitmaps_in_current_page.begin(); itr != bitmaps_in_current_page.end(); itr++) + ++bitmaps_ref_count[*itr]; return true; } diff --git a/src/Param.h b/src/Param.h index 3f20eca..8c16802 100644 --- a/src/Param.h +++ b/src/Param.h @@ -63,7 +63,7 @@ struct Param // background image std::string bg_format; - int svg_nodes_limit; + int svg_node_count_limit; int svg_embed_bitmap; // encryption diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index ccb426d..f20dc2b 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -190,10 +190,9 @@ void parse_options (int argc, char **argv) // background image .add("bg-format", ¶m.bg_format, "png", "specify background image format") - .add("svg-nodes-limit", ¶m.svg_nodes_limit, 0, "if node count in a svg background image exceeds this limit," - " fall back to bitmap background. 0 or negative means no limit.") - .add("svg-embed-bitmap", ¶m.svg_embed_bitmap, 1, "embed bitmaps in svg files or save them as external files" - " (even if 0 is specified, some bitmaps may still be embedded)") + .add("svg-node-count-limit", ¶m.svg_node_count_limit, -1, "if node count in a svg background image exceeds this limit," + " fall back this page to bitmap background; negative value means no limit.") + .add("svg-embed-bitmap", ¶m.svg_embed_bitmap, 1, "1: embed bitmaps in svg background; 0: dump bitmaps to external files if possible.") // encryption .add("owner-password,o", ¶m.owner_password, "", "owner password (for encrypted files)", true)