1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-07-04 17:18:40 +00:00

add class for height

This commit is contained in:
Lu Wang 2012-09-16 15:53:41 +08:00
parent bae60e96c7
commit 7ee0cc0111
4 changed files with 28 additions and 5 deletions

View File

@ -78,13 +78,14 @@ void HTMLRenderer::LineBuffer::flush(void)
max_ascent = max(max_ascent, s.ascent * s.draw_font_size);
}
// TODO: class for height ?
ostream & out = renderer->html_fout;
out << "<div style=\"left:"
<< _round(x) << "px;bottom:"
<< _round(y) << "px;height:"
<< _round(max_ascent) << "px;\" class=\"l t"
<< tm_id << "\">";
<< _round(y) << "px;"
<< "\""
<< " class=\"l t" << tm_id
<< " h" << renderer->install_height(max_ascent)
<< "\">";
auto cur_state_iter = states.begin();
auto cur_offset_iter = offsets.begin();

View File

@ -135,4 +135,9 @@ void HTMLRenderer::export_rise (long long rise_id, double rise)
css_fout << ".r" << rise_id << "{top:" << _round(-rise) << "px;}" << endl;
}
void HTMLRenderer::export_height (long long height_id, double height)
{
css_fout << ".h" << height_id << "{height:" << _round(height) << "px;}" << endl;
}
}

View File

@ -293,4 +293,18 @@ long long HTMLRenderer::install_rise(double rise)
return new_rise_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;
}
} // namespace pdf2htmlEX

View File

@ -51,6 +51,7 @@
* c<hex> - Color
* _<hex> - white space
* r<hex> - Rise
* h<hex> - Height
*
*/
@ -148,6 +149,7 @@ class HTMLRenderer : public OutputDev
long long install_color(const GfxRGB * rgb);
long long install_whitespace(double ws_width, double & actual_width);
long long install_rise(double rise);
long long install_height(double height);
////////////////////////////////////////////////////
// export css styles
@ -167,7 +169,7 @@ class HTMLRenderer : public OutputDev
void export_color(long long color_id, const GfxRGB * rgb);
void export_whitespace(long long ws_id, double ws_width);
void export_rise(long long rise_id, double rise);
void export_height(long long height_id, double height);
// 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 ""
@ -360,6 +362,7 @@ class HTMLRenderer : public OutputDev
std::unordered_map<GfxRGB, long long, GfxRGB_hash, GfxRGB_equal> color_map;
std::map<double, long long> whitespace_map;
std::map<double, long long> rise_map;
std::map<double, long long> height_map;
int image_count;