1
0
mirror of https://github.com/pdf2htmlEX/pdf2htmlEX.git synced 2024-12-21 20:50:07 +00:00
This commit is contained in:
Lu Wang 2012-10-02 16:06:08 +08:00
parent 779c91f81e
commit 2b06319207
6 changed files with 41 additions and 15 deletions

5
TODO
View File

@ -1,3 +1,6 @@
Integrate splash/cairo
native support for image
native support for draw
about glyph width:
- IE
@ -29,5 +32,3 @@ combine lines (unwarp)
Printing
multiple charcode mapped to a same glyph
check if we can add information to the font, and let browsers show ligatures automatically
native support for image
native support for draw

View File

@ -48,6 +48,8 @@ static bool is_rectangle(GfxSubpath * path)
//TODO connection style
void HTMLRenderer::css_draw(GfxState *state, bool fill)
{
if(!(param->css_draw)) return;
GfxPath * path = state->getPath();
for(int i = 0; i < path->getNumSubpaths(); ++i)
{
@ -120,7 +122,28 @@ void HTMLRenderer::css_draw_rectangle(double x, double y, double w, double h,
{
close_text_line();
html_fout << "<div class=\"Cd t" << install_transform_matrix(state->getCTM()) << "\" style=\"";
double ctm[6];
memcpy(ctm, state->getCTM(), sizeof(ctm));
_transform(ctm, x, y);
double scale = 1.0;
{
double i1 = ctm[0] + ctm[2];
double i2 = ctm[1] + ctm[3];
scale = sqrt((i1 * i1 + i2 * i2) / 2.0);
if(_is_positive(scale))
{
for(int i = 0; i < 4; ++i)
ctm[i] /= scale;
}
else
{
scale = 1.0;
}
}
html_fout << "<div class=\"Cd t" << install_transform_matrix(ctm) << "\" style=\"";
if(line_color)
{
@ -131,9 +154,9 @@ void HTMLRenderer::css_draw_rectangle(double x, double y, double w, double h,
{
if(i > 0) html_fout << ' ';
double lw = line_width_array[i];
double lw = line_width_array[i] * scale;
html_fout << _round(lw);
if(lw > EPS) html_fout << "px";
if(_is_positive(lw)) html_fout << "px";
}
html_fout << ";";
}
@ -151,12 +174,10 @@ void HTMLRenderer::css_draw_rectangle(double x, double y, double w, double h,
html_fout << "background-color:transparent;";
}
_transform(state->getCTM(), x, y);
html_fout << "bottom:" << _round(y) << "px;"
<< "left:" << _round(x) << "px;"
<< "width:" << _round(w) << "px;"
<< "height:" << _round(h) << "px;";
<< "width:" << _round(w * scale) << "px;"
<< "height:" << _round(h * scale) << "px;";
html_fout << "\"></div>";
}

View File

@ -84,17 +84,17 @@ void HTMLRenderer::process(PDFDoc *doc)
vector<double> zoom_factors;
if(abs(param->zoom) > EPS)
if(_is_positive(param->zoom))
{
zoom_factors.push_back(param->zoom);
}
if(abs(param->fit_width) > EPS)
if(_is_positive(param->fit_width))
{
zoom_factors.push_back((param->fit_width) / preprocessor.get_max_width());
}
if(abs(param->fit_height) > EPS)
if(_is_positive(param->fit_height))
{
zoom_factors.push_back((param->fit_height) / preprocessor.get_max_height());
}

View File

@ -206,13 +206,13 @@ void HTMLRenderer::check_state_change(GfxState * state)
if(_equal(cur_text_tm[0] * tdy, cur_text_tm[1] * tdx))
{
if(abs(cur_text_tm[0]) > EPS)
if(_is_positive(cur_text_tm[0]))
{
draw_tx += tdx / cur_text_tm[0];
draw_ty += dy;
merged = true;
}
else if (abs(cur_text_tm[1]) > EPS)
else if (_is_positive(cur_text_tm[1]))
{
draw_tx += tdy / cur_text_tm[1];
draw_ty += dy;
@ -220,7 +220,7 @@ void HTMLRenderer::check_state_change(GfxState * state)
}
else
{
if((abs(tdx) < EPS) && (abs(tdy) < EPS))
if((_equal(tdx,0)) && (_equal(tdy,0)))
{
// free
draw_tx = cur_tx;

View File

@ -55,6 +55,9 @@ struct Param
int debug;
int clean_tmp;
// experimental
int css_draw;
};
} // namespace pdf2htmlEX

View File

@ -91,6 +91,7 @@ void parse_options (int argc, char **argv)
.add("debug", &param.debug, 0, "output debug information")
.add("clean-tmp", &param.clean_tmp, 1, "clean temporary files after processing")
.add("css-draw", &param.css_draw, 0, "[Experimental and Unsupported] CSS Drawing")
.add("", &param.input_filename, "", "")
.add("", &param.output_filename, "", "")
;