diff --git a/TODO b/TODO
index faf9ff4..4246d7b 100644
--- a/TODO
+++ b/TODO
@@ -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
diff --git a/src/HTMLRenderer/draw.cc b/src/HTMLRenderer/draw.cc
index c311931..9e3d611 100644
--- a/src/HTMLRenderer/draw.cc
+++ b/src/HTMLRenderer/draw.cc
@@ -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 << "
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 << "
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 << "\">
";
}
diff --git a/src/HTMLRenderer/general.cc b/src/HTMLRenderer/general.cc
index a79627a..b48227c 100644
--- a/src/HTMLRenderer/general.cc
+++ b/src/HTMLRenderer/general.cc
@@ -84,17 +84,17 @@ void HTMLRenderer::process(PDFDoc *doc)
vector
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());
}
diff --git a/src/HTMLRenderer/state.cc b/src/HTMLRenderer/state.cc
index 054a807..862d7d8 100644
--- a/src/HTMLRenderer/state.cc
+++ b/src/HTMLRenderer/state.cc
@@ -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;
diff --git a/src/include/Param.h b/src/include/Param.h
index db90188..6136a55 100644
--- a/src/include/Param.h
+++ b/src/include/Param.h
@@ -55,6 +55,9 @@ struct Param
int debug;
int clean_tmp;
+
+ // experimental
+ int css_draw;
};
} // namespace pdf2htmlEX
diff --git a/src/pdf2htmlEX.cc b/src/pdf2htmlEX.cc
index 03fbc08..d95c70e 100644
--- a/src/pdf2htmlEX.cc
+++ b/src/pdf2htmlEX.cc
@@ -91,6 +91,7 @@ void parse_options (int argc, char **argv)
.add("debug", ¶m.debug, 0, "output debug information")
.add("clean-tmp", ¶m.clean_tmp, 1, "clean temporary files after processing")
+ .add("css-draw", ¶m.css_draw, 0, "[Experimental and Unsupported] CSS Drawing")
.add("", ¶m.input_filename, "", "")
.add("", ¶m.output_filename, "", "")
;