feature: add bbox support in koptreader

Reflow can be configured to use bbox which could remove
side comments and defects in the margin and get much better reflowed
page in some documents. Currently the bbox is only set in PDFReader or
DJVUReader reader. But eventually there will be bbox setting routines in
KOPTReader.
Thirdparty should be cleaned and refetched and remake to get
this feature in operation.
pull/2/merge
chrox 12 years ago
parent a5b28ff6f2
commit 97066cfdb0

@ -42,6 +42,7 @@ static int newKOPTContext(lua_State *L) {
double word_spacing = luaL_optnumber(L, 20, (double) 1.375);
uint8_t *data = NULL;
fz_rect bbox = {0, 0, 0, 0};
KOPTContext *kc = (KOPTContext*) lua_newuserdata(L, sizeof(KOPTContext));
@ -68,6 +69,7 @@ static int newKOPTContext(lua_State *L) {
kc->word_spacing = word_spacing;
kc->data = data;
kc->bbox = bbox;
luaL_getmetatable(L, "koptcontext");
lua_setmetatable(L, -2);
@ -75,12 +77,27 @@ static int newKOPTContext(lua_State *L) {
return 1;
}
static int kcSetBBox(lua_State *L) {
KOPTContext *kc = (KOPTContext*) luaL_checkudata(L, 1, "koptcontext");
kc->bbox.x0 = luaL_checknumber(L, 2);
kc->bbox.y0 = luaL_checknumber(L, 3);
kc->bbox.x1 = luaL_checknumber(L, 4);
kc->bbox.y1 = luaL_checknumber(L, 5);
return 0;
}
static int kcSetTrim(lua_State *L) {
KOPTContext *kc = (KOPTContext*) luaL_checkudata(L, 1, "koptcontext");
kc->trim = luaL_checkint(L, 2);
return 0;
}
static int kcGetTrim(lua_State *L) {
KOPTContext *kc = (KOPTContext*) luaL_checkudata(L, 1, "koptcontext");
lua_pushinteger(L, kc->trim);
return 1;
}
static int kcSetWrap(lua_State *L) {
KOPTContext *kc = (KOPTContext*) luaL_checkudata(L, 1, "koptcontext");
kc->wrap = luaL_checkint(L, 2);
@ -194,7 +211,9 @@ static int kcSetWordSpacing(lua_State *L) {
}
static const struct luaL_Reg koptcontext_meth[] = {
{"setBBox", kcSetBBox},
{"setTrim", kcSetTrim},
{"getTrim", kcGetTrim},
{"setWrap", kcSetWrap},
{"setIndent", kcSetIndent},
{"setRotate", kcSetRotate},

Loading…
Cancel
Save