From bd1c9c138fd037623a12711c87f7c5c23ea616da Mon Sep 17 00:00:00 2001 From: Lu Wang Date: Sat, 9 Mar 2013 01:45:13 +0800 Subject: [PATCH] fallback mode --- pdf2htmlEX.1.in | 4 ++++ share/base.css.in | 5 +++-- .../SplashBackgroundRenderer.cc | 18 ++++++++++-------- src/HTMLRenderer/general.cc | 2 +- src/HTMLRenderer/state.cc | 4 ++-- src/Param.h | 1 + src/pdf2htmlEX.cc | 1 + 7 files changed, 22 insertions(+), 13 deletions(-) diff --git a/pdf2htmlEX.1.in b/pdf2htmlEX.1.in index 645c0aa..14d8917 100644 --- a/pdf2htmlEX.1.in +++ b/pdf2htmlEX.1.in @@ -87,6 +87,10 @@ 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) diff --git a/share/base.css.in b/share/base.css.in index d7ad8c4..59ac4ed 100644 --- a/share/base.css.in +++ b/share/base.css.in @@ -164,11 +164,12 @@ span { /* text blocks within a line */ color:transparent; z-index:-1; } +/* selection background should not be opaque, for fallback mode */ ::selection{ - background: rgba(127,255,255,1); + background: rgba(127,255,255,0.4); } ::-moz-selection{ - background: rgba(127,255,255,1); + background: rgba(127,255,255,0.4); } .@CSS_PAGE_DATA_CN@ { /* info for Javascript */ display:none; diff --git a/src/BackgroundRenderer/SplashBackgroundRenderer.cc b/src/BackgroundRenderer/SplashBackgroundRenderer.cc index ea5281a..28e5900 100644 --- a/src/BackgroundRenderer/SplashBackgroundRenderer.cc +++ b/src/BackgroundRenderer/SplashBackgroundRenderer.cc @@ -20,17 +20,19 @@ void SplashBackgroundRenderer::drawChar(GfxState *state, double x, double y, CharCode code, int nBytes, Unicode *u, int uLen) { // draw characters as image when - // - there is special filling method + // - in fallback mode + // - OR there is special filling method // - OR using a writing mode font // - OR using a Type 3 font - if(( (state->getFont()) - && ( (state->getFont()->getWMode()) - || (state->getFont()->getType() == fontType3) - ) - ) + if((param->fallback) + || ( (state->getFont()) + && ( (state->getFont()->getWMode()) + || (state->getFont()->getType() == fontType3) + ) + ) ) { - SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code, nBytes, u, uLen); + SplashOutputDev::drawChar(state,x,y,dx,dy,originX,originY,code,nBytes,u,uLen); } } @@ -42,7 +44,7 @@ void SplashBackgroundRenderer::render_page(PDFDoc * doc, int pageno, const strin { doc->displayPage(this, pageno, param->h_dpi, param->v_dpi, 0, - (param->use_cropbox == 0), + (!(param->use_cropbox)), false, false, nullptr, nullptr, &annot_cb, nullptr); diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc index ae3a056..2875adf 100644 --- a/src/HTMLRenderer/general.cc +++ b/src/HTMLRenderer/general.cc @@ -120,7 +120,7 @@ void HTMLRenderer::process(PDFDoc *doc) doc->displayPage(this, i, text_zoom_factor() * DEFAULT_DPI, text_zoom_factor() * DEFAULT_DPI, 0, - (param->use_cropbox == 0), + (!(param->use_cropbox)), false, false, nullptr, nullptr, nullptr, nullptr); diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc index 92ceabb..aea5113 100644 --- a/src/HTMLRenderer/state.cc +++ b/src/HTMLRenderer/state.cc @@ -346,7 +346,7 @@ void HTMLRenderer::check_state_change(GfxState * state) } // fill color - if(all_changed || fill_color_changed) + if((!(param->fallback)) && (all_changed || fill_color_changed)) { // * PDF Spec. Table 106 – Text rendering modes static const char FILL[8] = { true, false, true, false, true, false, true, false }; @@ -369,7 +369,7 @@ void HTMLRenderer::check_state_change(GfxState * state) } // stroke color - if(all_changed || stroke_color_changed) + if((!(param->fallback)) && (all_changed || stroke_color_changed)) { // * PDF Spec. Table 106 – Text rendering modes static const char STROKE[8] = { false, true, true, false, false, true, true, false }; diff --git a/src/Param.h b/src/Param.h index 2155f8a..c6e9964 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 fallback; // fonts int embed_base_font; diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc index 471c0e9..bae0100 100644 --- a/src/pdf2htmlEX.cc +++ b/src/pdf2htmlEX.cc @@ -75,6 +75,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("fallback", ¶m.fallback, 0, "output in fallback mode") // fonts .add("embed-base-font", ¶m.embed_base_font, 0, "embed local match for standard 14 fonts")