mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
left
This commit is contained in:
parent
6c7229f514
commit
fc1fbf2e40
@ -167,8 +167,6 @@ class HTMLRenderer : public OutputDev
|
||||
long long install_transform_matrix(const double * tm);
|
||||
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_left(double left);
|
||||
|
||||
////////////////////////////////////////////////////
|
||||
// export css styles
|
||||
@ -184,8 +182,6 @@ class HTMLRenderer : public OutputDev
|
||||
void export_transform_matrix(long long tm_id, const double * tm);
|
||||
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_left(long long left_id, double left);
|
||||
|
||||
// depending on single-html, to embed the content or add a link to it
|
||||
// "type": specify the file type, usually it's the suffix, in which case this parameter could be ""
|
||||
@ -320,6 +316,7 @@ class HTMLRenderer : public OutputDev
|
||||
|
||||
WhitespaceManager whitespace_manager;
|
||||
HeightManager height_manager;
|
||||
LeftManager left_manager;
|
||||
|
||||
// optimize for web
|
||||
// we try to render the final font size directly
|
||||
@ -359,7 +356,6 @@ class HTMLRenderer : public OutputDev
|
||||
std::unordered_map<long long, FontInfo> font_name_map;
|
||||
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> left_map;
|
||||
|
||||
const Param * param;
|
||||
|
||||
|
@ -84,13 +84,14 @@ void HTMLRenderer::TextLineBuffer::flush(void)
|
||||
|
||||
ostream & out = renderer->f_pages.fs;
|
||||
renderer->height_manager.install(max_ascent);
|
||||
renderer->left_manager.install(x);
|
||||
|
||||
out << "<div style=\""
|
||||
<< "bottom:" << round(y) << "px;"
|
||||
<< "\""
|
||||
<< " class=\"l"
|
||||
<< " t" << tm_id
|
||||
<< " L" << renderer->install_left(x)
|
||||
<< " L" << renderer->left_manager.get_id()
|
||||
<< " h" << renderer->height_manager.get_id()
|
||||
<< "\">";
|
||||
|
||||
|
@ -185,20 +185,7 @@ void HTMLRenderer::export_stroke_color (long long color_id, const GfxRGB * rgb)
|
||||
// WebKit
|
||||
f_css.fs << "@media screen and (-webkit-min-device-pixel-ratio:0) {";
|
||||
f_css.fs << ".C" << color_id << "{-webkit-text-stroke: 0.015em " << *rgb << ";text-shadow: none;}";
|
||||
f_css.fs << "}";
|
||||
}
|
||||
|
||||
void HTMLRenderer::export_whitespace (long long ws_id, double ws_width)
|
||||
{
|
||||
if(ws_width > 0)
|
||||
f_css.fs << "._" << ws_id << "{display:inline-block;width:" << round(ws_width) << "px;}" << endl;
|
||||
else
|
||||
f_css.fs << "._" << ws_id << "{display:inline;margin-left:" << round(ws_width) << "px;}" << endl;
|
||||
}
|
||||
|
||||
void HTMLRenderer::export_left (long long left_id, double left)
|
||||
{
|
||||
f_css.fs << ".L" << left_id << "{left:" << round(left) << "px;}" << endl;
|
||||
f_css.fs << "}" << endl;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ HTMLRenderer::HTMLRenderer(const Param * param)
|
||||
rise_manager .set_param(CSS::RISE_CN , param->v_eps);
|
||||
whitespace_manager .set_param(CSS::WHITESPACE_CN , param->h_eps);
|
||||
height_manager .set_param(CSS::HEIGHT_CN , EPS );
|
||||
left_manager .set_param(CSS::LEFT_CN , param->h_eps);
|
||||
}
|
||||
|
||||
HTMLRenderer::~HTMLRenderer()
|
||||
@ -345,6 +346,7 @@ void HTMLRenderer::post_process()
|
||||
rise_manager .dump_css(f_css.fs);
|
||||
whitespace_manager .dump_css(f_css.fs);
|
||||
height_manager .dump_css(f_css.fs);
|
||||
left_manager .dump_css(f_css.fs);
|
||||
|
||||
// close files
|
||||
f_outline.fs.close();
|
||||
|
@ -263,18 +263,4 @@ long long HTMLRenderer::install_stroke_color(const GfxRGB * rgb)
|
||||
return new_color_id;
|
||||
}
|
||||
|
||||
long long HTMLRenderer::install_left(double left)
|
||||
{
|
||||
auto iter = left_map.lower_bound(left - param->h_eps);
|
||||
if((iter != left_map.end()) && (abs(iter->first - left) <= param->h_eps))
|
||||
{
|
||||
return iter->second;
|
||||
}
|
||||
|
||||
long long new_left_id = left_map.size();
|
||||
left_map.insert(make_pair(left, new_left_id));
|
||||
export_left(new_left_id, left);
|
||||
return new_left_id;
|
||||
}
|
||||
|
||||
} // namespace pdf2htmlEX
|
||||
|
@ -125,7 +125,11 @@ class WhitespaceManager : public StateManager<double, WhitespaceManager>
|
||||
{
|
||||
public:
|
||||
double default_value(void) { return 0; }
|
||||
void dump_value(std::ostream & out, double value) { out << "top:" << round(-value) << "px;"; }
|
||||
void dump_value(std::ostream & out, double value) {
|
||||
out << ((value > 0) ? "display:inline-block;width:"
|
||||
: "display:inline;margin-left:")
|
||||
<< round(value) << "px;";
|
||||
}
|
||||
};
|
||||
|
||||
class HeightManager : public StateManager<double, HeightManager>
|
||||
@ -135,6 +139,13 @@ public:
|
||||
void dump_value(std::ostream & out, double value) { out << "height:" << round(value) << "px;"; }
|
||||
};
|
||||
|
||||
class LeftManager : public StateManager<double, LeftManager>
|
||||
{
|
||||
public:
|
||||
double default_value(void) { return 0; }
|
||||
void dump_value(std::ostream & out, double value) { out << "left:" << round(value) << "px;"; }
|
||||
};
|
||||
|
||||
} // namespace pdf2htmlEX
|
||||
|
||||
#endif //STATEMANAGER_H__
|
||||
|
Loading…
Reference in New Issue
Block a user