mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 04:50:09 +00:00
more state managers
This commit is contained in:
parent
b98ab8781e
commit
a2ed253454
2
TODO
2
TODO
@ -1,5 +1,5 @@
|
|||||||
optimize font_size & transform matrix tracking
|
optimize font_size & transform matrix tracking
|
||||||
c++ classes for different states
|
print css for draw/link/image...
|
||||||
|
|
||||||
== Future: ==
|
== Future: ==
|
||||||
|
|
||||||
|
@ -225,11 +225,6 @@ protected:
|
|||||||
|
|
||||||
double default_ctm[6];
|
double default_ctm[6];
|
||||||
|
|
||||||
// page info
|
|
||||||
int pageNum;
|
|
||||||
double pageWidth ;
|
|
||||||
double pageHeight ;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The content of each page is first scaled with factor1 (>=1), then scale back with factor2(<=1)
|
* The content of each page is first scaled with factor1 (>=1), then scale back with factor2(<=1)
|
||||||
*
|
*
|
||||||
@ -292,7 +287,9 @@ protected:
|
|||||||
WordSpaceManager word_space_manager;
|
WordSpaceManager word_space_manager;
|
||||||
FillColorManager fill_color_manager;
|
FillColorManager fill_color_manager;
|
||||||
FontSizeManager font_size_manager;
|
FontSizeManager font_size_manager;
|
||||||
|
BottomManager bottom_manager;
|
||||||
HeightManager height_manager;
|
HeightManager height_manager;
|
||||||
|
WidthManager width_manager;
|
||||||
RiseManager rise_manager;
|
RiseManager rise_manager;
|
||||||
LeftManager left_manager;
|
LeftManager left_manager;
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
|
@ -85,15 +85,14 @@ void HTMLRenderer::TextLineBuffer::flush(void)
|
|||||||
|
|
||||||
ostream & out = renderer->f_pages.fs;
|
ostream & out = renderer->f_pages.fs;
|
||||||
renderer->height_manager.install(max_ascent);
|
renderer->height_manager.install(max_ascent);
|
||||||
renderer->left_manager.install(x);
|
renderer->left_manager .install(x);
|
||||||
|
renderer->bottom_manager.install(y);
|
||||||
|
|
||||||
out << "<div style=\""
|
out << "<div class=\"" << CSS::LINE_CN
|
||||||
<< "bottom:" << round(y) << "px;"
|
<< " " << CSS::TRANSFORM_MATRIX_CN << tm_id
|
||||||
<< "\""
|
<< " " << CSS::LEFT_CN << renderer->left_manager .get_id()
|
||||||
<< " class=\"" << CSS::LINE_CN
|
<< " " << CSS::HEIGHT_CN << renderer->height_manager.get_id()
|
||||||
<< " " << CSS::TRANSFORM_MATRIX_CN << tm_id
|
<< " " << CSS::BOTTOM_CN << renderer->bottom_manager.get_id()
|
||||||
<< " " << CSS::LEFT_CN << renderer->left_manager.get_id()
|
|
||||||
<< " " << CSS::HEIGHT_CN << renderer->height_manager.get_id()
|
|
||||||
<< "\">";
|
<< "\">";
|
||||||
|
|
||||||
auto cur_state_iter = states.begin();
|
auto cur_state_iter = states.begin();
|
||||||
|
@ -61,8 +61,10 @@ HTMLRenderer::HTMLRenderer(const Param * param)
|
|||||||
word_space_manager .set_eps(EPS);
|
word_space_manager .set_eps(EPS);
|
||||||
rise_manager .set_eps(param->v_eps);
|
rise_manager .set_eps(param->v_eps);
|
||||||
whitespace_manager .set_eps(param->h_eps);
|
whitespace_manager .set_eps(param->h_eps);
|
||||||
height_manager .set_eps(EPS);
|
|
||||||
left_manager .set_eps(param->h_eps);
|
left_manager .set_eps(param->h_eps);
|
||||||
|
height_manager .set_eps(EPS);
|
||||||
|
width_manager .set_eps(EPS);
|
||||||
|
bottom_manager .set_eps(EPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
HTMLRenderer::~HTMLRenderer()
|
HTMLRenderer::~HTMLRenderer()
|
||||||
@ -156,18 +158,17 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state)
|
|||||||
|
|
||||||
void HTMLRenderer::startPage(int pageNum, GfxState *state, XRef * xref)
|
void HTMLRenderer::startPage(int pageNum, GfxState *state, XRef * xref)
|
||||||
{
|
{
|
||||||
this->pageNum = pageNum;
|
|
||||||
this->pageWidth = state->getPageWidth();
|
|
||||||
this->pageHeight = state->getPageHeight();
|
|
||||||
|
|
||||||
assert((!line_opened) && "Open line in startPage detected!");
|
assert((!line_opened) && "Open line in startPage detected!");
|
||||||
|
|
||||||
|
height_manager.install(state->getPageWidth());
|
||||||
|
width_maanger.install(state->getPageHeight());
|
||||||
f_pages.fs
|
f_pages.fs
|
||||||
<< "<div class=\"" << CSS::PAGE_DECORATION_CN
|
<< "<div class=\"" << CSS::PAGE_DECORATION_CN
|
||||||
<< "\" style=\"width:"
|
<< " " << CSS::WIDTH_CN << width_manager.get_id()
|
||||||
<< (pageWidth) << "px;height:"
|
<< " " << CSS::HEIGHT_CN << height_manager.get_id()
|
||||||
<< (pageHeight) << "px;\">"
|
<< "\">"
|
||||||
<< "<div id=\"" << CSS::PAGE_FRAME_CN << pageNum << "\" data-page-no=\"" << pageNum << "\" class=\"p\">"
|
<< "<div id=\"" << CSS::PAGE_FRAME_CN << pageNum
|
||||||
|
<< "\" data-page-no=\"" << pageNum << "\" class=\"p\">"
|
||||||
<< "<div class=\"" << CSS::PAGE_CONTENT_BOX_CN << "\" style=\"";
|
<< "<div class=\"" << CSS::PAGE_CONTENT_BOX_CN << "\" style=\"";
|
||||||
|
|
||||||
if(param->process_nontext)
|
if(param->process_nontext)
|
||||||
@ -189,6 +190,7 @@ void HTMLRenderer::startPage(int pageNum, GfxState *state, XRef * xref)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO print css
|
||||||
f_pages.fs << ");background-position:0 0;background-size:" << pageWidth << "px " << pageHeight << "px;background-repeat:no-repeat;";
|
f_pages.fs << ");background-position:0 0;background-size:" << pageWidth << "px " << pageHeight << "px;background-repeat:no-repeat;";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +350,9 @@ void HTMLRenderer::post_process()
|
|||||||
whitespace_manager .dump_css(f_css.fs);
|
whitespace_manager .dump_css(f_css.fs);
|
||||||
fill_color_manager .dump_css(f_css.fs);
|
fill_color_manager .dump_css(f_css.fs);
|
||||||
font_size_manager .dump_css(f_css.fs);
|
font_size_manager .dump_css(f_css.fs);
|
||||||
|
bottom_manager .dump_css(f_css.fs);
|
||||||
height_manager .dump_css(f_css.fs);
|
height_manager .dump_css(f_css.fs);
|
||||||
|
width_manager .dump_css(f_css.fs);
|
||||||
rise_manager .dump_css(f_css.fs);
|
rise_manager .dump_css(f_css.fs);
|
||||||
left_manager .dump_css(f_css.fs);
|
left_manager .dump_css(f_css.fs);
|
||||||
|
|
||||||
|
@ -109,7 +109,9 @@ void HTMLRenderer::reset_state()
|
|||||||
whitespace_manager .reset();
|
whitespace_manager .reset();
|
||||||
fill_color_manager .reset();
|
fill_color_manager .reset();
|
||||||
font_size_manager .reset();
|
font_size_manager .reset();
|
||||||
|
bottom_manager .reset();
|
||||||
height_manager .reset();
|
height_manager .reset();
|
||||||
|
width_manager .reset();
|
||||||
rise_manager .reset();
|
rise_manager .reset();
|
||||||
left_manager .reset();
|
left_manager .reset();
|
||||||
|
|
||||||
|
@ -46,8 +46,10 @@ const char * const LETTER_SPACE_CN = "l";
|
|||||||
const char * const WORD_SPACE_CN = "w";
|
const char * const WORD_SPACE_CN = "w";
|
||||||
const char * const RISE_CN = "r";
|
const char * const RISE_CN = "r";
|
||||||
const char * const WHITESPACE_CN = "_";
|
const char * const WHITESPACE_CN = "_";
|
||||||
const char * const HEIGHT_CN = "h";
|
|
||||||
const char * const LEFT_CN = "L";
|
const char * const LEFT_CN = "L";
|
||||||
|
const char * const HEIGHT_CN = "h";
|
||||||
|
const char * const WIDTH_CN = "W";
|
||||||
|
const char * const BOTTOM_CN = "B";
|
||||||
|
|
||||||
const char * const CSS_DRAW_CN = "Cd";
|
const char * const CSS_DRAW_CN = "Cd";
|
||||||
const char * const LINK_CN = "a";
|
const char * const LINK_CN = "a";
|
||||||
|
@ -314,6 +314,22 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WidthManager : public StateManager<double, WidthManager>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const char * get_css_class_name (void) { return CSS::WIDTH_CN; }
|
||||||
|
double default_value(void) { return 0; }
|
||||||
|
void dump_value(std::ostream & out, double value) { out << "width:" << round(value) << "px;"; }
|
||||||
|
};
|
||||||
|
|
||||||
|
class BottomManager : public StateManager<double, BottomManager>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static const char * get_css_class_name (void) { return CSS::BOTTOM_CN; }
|
||||||
|
double default_value(void) { return 0; }
|
||||||
|
void dump_value(std::ostream & out, double value) { out << "bottom:" << round(value) << "px;"; }
|
||||||
|
};
|
||||||
|
|
||||||
class HeightManager : public StateManager<double, HeightManager>
|
class HeightManager : public StateManager<double, HeightManager>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user