1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 13:00:08 +00:00
This commit is contained in:
Lu Wang 2013-02-05 14:51:00 +08:00
parent 82c0e28853
commit b18f59af6d
7 changed files with 16 additions and 22 deletions

View File

@ -168,7 +168,6 @@ class HTMLRenderer : public OutputDev
long long install_fill_color(const GfxRGB * rgb);
long long install_stroke_color(const GfxRGB * rgb);
long long install_whitespace(double ws_width, double & actual_width);
long long install_height(double height);
long long install_left(double left);
////////////////////////////////////////////////////
@ -186,7 +185,6 @@ class HTMLRenderer : public OutputDev
void export_fill_color(long long color_id, const GfxRGB * rgb);
void export_stroke_color(long long color_id, const GfxRGB * rgb);
void export_whitespace(long long ws_id, double ws_width);
void export_height(long long height_id, double height);
void export_left(long long left_id, double left);
// depending on single-html, to embed the content or add a link to it
@ -320,6 +318,8 @@ class HTMLRenderer : public OutputDev
bool rise_changed;
RiseManager rise_manager;
HeightManager height_manager;
// optimize for web
// we try to render the final font size directly
// to reduce the effect of ctm as much as possible
@ -359,7 +359,6 @@ class HTMLRenderer : public OutputDev
std::map<Matrix, long long, Matrix_less> transform_matrix_map;
std::unordered_map<GfxRGB, long long, GfxRGB_hash, GfxRGB_equal> fill_color_map, stroke_color_map;
std::map<double, long long> whitespace_map;
std::map<double, long long> height_map;
std::map<double, long long> left_map;
const Param * param;

View File

@ -83,13 +83,15 @@ void HTMLRenderer::TextLineBuffer::flush(void)
}
ostream & out = renderer->f_pages.fs;
renderer->height_manager.install(max_ascent);
out << "<div style=\""
<< "bottom:" << round(y) << "px;"
<< "\""
<< " class=\"l"
<< " t" << tm_id
<< " L" << renderer->install_left(x)
<< " h" << renderer->install_height(max_ascent)
<< " h" << renderer->height_manager.get_id()
<< "\">";
auto cur_state_iter = states.begin();

View File

@ -196,10 +196,6 @@ void HTMLRenderer::export_whitespace (long long ws_id, double ws_width)
f_css.fs << "._" << ws_id << "{display:inline;margin-left:" << round(ws_width) << "px;}" << endl;
}
void HTMLRenderer::export_height (long long height_id, double height)
{
f_css.fs << ".h" << height_id << "{height:" << round(height) << "px;}" << endl;
}
void HTMLRenderer::export_left (long long left_id, double left)
{
f_css.fs << ".L" << left_id << "{left:" << round(left) << "px;}" << endl;

View File

@ -60,6 +60,7 @@ HTMLRenderer::HTMLRenderer(const Param * param)
letter_space_manager.set_param(CSS::LETTER_SPACE_CN, EPS );
word_space_manager .set_param(CSS::WORD_SPACE_CN , EPS );
rise_manager .set_param(CSS::RISE_CN , param->v_eps);
height_manager .set_param(CSS::HEIGHT_CN , EPS );
}
HTMLRenderer::~HTMLRenderer()
@ -341,6 +342,7 @@ void HTMLRenderer::post_process()
letter_space_manager.dump_css(f_css.fs);
word_space_manager .dump_css(f_css.fs);
rise_manager .dump_css(f_css.fs);
height_manager .dump_css(f_css.fs);
// close files
f_outline.fs.close();

View File

@ -280,19 +280,6 @@ long long HTMLRenderer::install_whitespace(double ws_width, double & actual_widt
return new_ws_id;
}
long long HTMLRenderer::install_height(double height)
{
auto iter = height_map.lower_bound(height - EPS);
if((iter != height_map.end()) && (abs(iter->first - height) <= EPS))
{
return iter->second;
}
long long new_height_id = height_map.size();
height_map.insert(make_pair(height, new_height_id));
export_height(new_height_id, height);
return new_height_id;
}
long long HTMLRenderer::install_left(double left)
{
auto iter = left_map.lower_bound(left - param->h_eps);

View File

@ -116,7 +116,8 @@ void HTMLRenderer::reset_state()
cur_stroke_color_id = install_stroke_color(&cur_stroke_color);
cur_has_stroke = false;
rise_manager.reset();
rise_manager .reset();
height_manager.reset();
cur_tx = cur_ty = 0;
draw_tx = draw_ty = 0;

View File

@ -121,6 +121,13 @@ public:
void dump_value(std::ostream & out, double value) { out << "top:" << round(-value) << "px;"; }
};
class HeightManager : public StateManager<double, HeightManager>
{
public:
double default_value(void) { return 0; }
void dump_value(std::ostream & out, double value) { out << "height:" << round(value) << "px;"; }
};
} // namespace pdf2htmlEX
#endif //STATEMANAGER_H__