1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-22 04:50:09 +00:00

add a class for 'left'

This commit is contained in:
Lu Wang 2013-01-25 16:39:20 +08:00
parent 369f6f0624
commit f9399859e4
4 changed files with 28 additions and 5 deletions

View File

@ -45,7 +45,8 @@
*
* Cd - CSS Draw
*
* Reusable CSS classes
* Numbered CSS classes
* See also: HTMLRenderer::TextLineBuffer::format_str
*
* t<hex> - Transform matrix
* f<hex> - Font (also for font names)
@ -56,6 +57,7 @@
* _<hex> - white space
* r<hex> - Rise
* h<hex> - Height
* L<hex> - Left
*
*/
@ -230,6 +232,7 @@ class HTMLRenderer : public OutputDev
long long install_whitespace(double ws_width, double & actual_width);
long long install_rise(double rise);
long long install_height(double height);
long long install_left(double left);
////////////////////////////////////////////////////
// export css styles
@ -250,6 +253,7 @@ class HTMLRenderer : public OutputDev
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);
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 ""
@ -417,6 +421,7 @@ class HTMLRenderer : public OutputDev
std::map<double, long long> whitespace_map;
std::map<double, long long> rise_map;
std::map<double, long long> height_map;
std::map<double, long long> left_map;
const Param * param;
std::ofstream html_fout, css_fout;

View File

@ -84,11 +84,12 @@ void HTMLRenderer::TextLineBuffer::flush(void)
}
ostream & out = renderer->html_fout;
out << "<div style=\"left:"
<< round(x) << "px;bottom:"
<< round(y) << "px;"
out << "<div style=\""
<< "bottom:" << round(y) << "px;"
<< "\""
<< " class=\"l t" << tm_id
<< " class=\"l"
<< " t" << tm_id
<< " L" << renderer->install_left(x)
<< " h" << renderer->install_height(max_ascent)
<< "\">";

View File

@ -166,5 +166,9 @@ void HTMLRenderer::export_height (long long height_id, double height)
{
css_fout << ".h" << height_id << "{height:" << round(height) << "px;}" << endl;
}
void HTMLRenderer::export_left (long long left_id, double left)
{
css_fout << ".L" << left_id << "{left:" << round(left) << "px;}" << endl;
}
}

View File

@ -321,5 +321,18 @@ long long HTMLRenderer::install_height(double height)
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);
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